站长资源
中国站长网站

在线聊天机器人框架BotUI.js

BotUI 是一个有趣的聊天 JS 框架,界面样式像是一个对话聊天界面,使用者可以创建一个对话内容与访客进行互动。

项目名称:BotUI
在线演示:https://botui.org/
下载地址:https://github.com/moinism/botui

当然,这个不是真的能与用户「真实」交流,而是创建者可以自己定制一些有意义、有趣的对话策略来与访客互动起来。

BotUI的对话设定是比较简单的,下面有一个例子,可以参考这个官方的 DEMO 来设置。

HTML 代码:

<div class="botui-app-container" id="botui-app">
  <bot-ui></bot-ui>
</div>

JS 设置:

var botui = new BotUI('botui-app'); // give it the id of container

botui.message.bot({ // show first message
  delay: 200,
  content: 'hello'
}).then(function () {
  return botui.message.bot({ // second one
    delay: 1000, // wait 1 sec.
    content: 'how are you?'
  });
}).then(function () {
  return botui.action.button({ // let user do something
    delay: 1000,
    action: [
      {
        text: 'Good',
        value: 'good'
      },
      {
        text: 'Really Good',
        value: 'really_good'
      }
    ]
  });
}).then(function (res) {
  return botui.message.bot({
    delay: 1000,
    content: 'You are feeling ' + res.text + '!'
  });
});
本文出处:来自互联网信息共享,请勿相信收费信息站长资源 » 在线聊天机器人框架BotUI.js

评论 抢沙发

评论前必须登录!