BotUI 是一个有趣的聊天 JS 框架,界面样式像是一个对话聊天界面,使用者可以创建一个对话内容与访客进行互动。
项目名称:BotUI
在线演示:演示1 | 演示2
下载地址: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 框架”的全部内容了,喜欢的小伙伴记得点赞收藏,也可以分享给身边感兴趣的朋友。如果你还想了解更多前端设计的相关内容,可以来AdobeEdu设计联盟官方网站获取