๐–„๐•บ๐ŸŒŽ๐•ฟ๐•ฝ๐•บยฅ

๐–„๐•บ๐ŸŒŽ๐•ฟ๐•ฝ๐•บยฅ

๐•ด ๐–‰๐–” ๐–’๐–†๐–Œ๐–Ž๐–ˆ
github

Configuring botui for the blog - Using Halo blog as an example

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 +'ใ€‚ๆ„Ÿ่ฐขไฝ ๆฅ็œ‹ๆˆ‘๏ผ'
                });
        })
}
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.