Botui#
GitHub - botui/botui: ๐ค A JavaScript framework to create conversational UIs
Configuration#
Refer to the official Github documentation for the solution for halo blog, the demonstration effect, and the code placed at the end of the document.
Configure <head>
#
ใBackend-System-Other Settings-Custom Content Page Headใ
<link rel="stylesheet" href="https://unpkg.com/botui/build/botui.min.css" />
<link rel="stylesheet" href="https:/unpkg.com/botui/build/botui-theme-default.css" />
Configure content page#
Type the following in the content page to apply
<div class="botui-app-container" id="example"><!-- id should correspond -->
<bot-ui></bot-ui>
</div>
<script src="https://cdn.jsdelivr.net/vue/2.0.5/vue.min.js"></script>
<script src="https://unpkg.com/botui/build/botui.js"></script>
<script src="/themes/source/botui/example.js"><!-- location of the interaction js file -->//
</script>
Please modify the location of the interaction js file yourself to prevent accidental deletion during updates.
Interaction js document#
Next is to configure the js interaction file, which requires a certain coding foundation. Refer to the following:
Official documentation https://docs.botui.org/
Github example https://github.com/botui/botui-examples
Bug#
Page flipping occurs when clicking buttons, etc.
Preview#
If not displayed, please refresh the page.
example1
//example1
var botui = new BotUI('example1');//name should correspond with id
botui.message.add({
content: 'Hello World from bot!'
});
botui.message.add({
human: true,
content: 'Hello World from human!'
});
example2
//info
var botui = new BotUI('info');
botui.message.add({
content: '๏ผ'
});
botui.message
.bot({
delay: 1000,
content: 'Hi, ไฝ ๅฅฝๅ!'
}).then(function () {
return botui.action.button({
delay: 1000,
action: [{
text: 'Hi',
value: 'hi'
},{
text: '......',
value: 'no_reply'
}]
})
}).then(function (res) {
if(res.value == 'hi') {
showReminderInput();
} else {
botui.message.bot('ๅฑ้ข ๅฑ้ข ้่ตฐไบ');
}
});
var showReminderInput = function () {
botui.message
.bot({
delay: 500,
content: 'ๆๅซLil Troy๏ผไฝ ๅซไปไนๅ๏ผ'
}).then(function () {
return botui.action.text({
delay: 3000,
action:{
placeholder:'้ฎๅ
ฅไฝ ็ๅๅญ'
}
})
}).then(function (user_name){
botui.message
.bot({
delay: 500,
content: 'ไฝ ๅฅฝๅ๏ผ' + user_name.value +'ใๆ่ฐขไฝ ๆฅ็ๆ๏ผ'
});
})
}