<!DOCTYPE html>
<html>
<head>
<link href="https://cdn.botframework.com/botframework-webchat/latest/botchat.css" rel="stylesheet" />
</head>
<body>
<div id="bot"/>
<script src="https://cdn.botframework.com/botframework-webchat/latest/botchat.js"></script>
<script>
BotChat.App({
directLine: { secret: direct_line_secret },
user: { id: 'userid' },
bot: { id: 'botid' },
resize: 'detect'
}, document.getElementById("bot"));
</script>
</body>
</html>
我有这段代码可以使用直接 Line API 而不是通常的 iframe 将机器人嵌入为实时聊天,但是当我输入我的直接 key 时,机器人会占据整个网页。我需要它出现在网页的右下角,并在用户点击它时作为生活聊天弹出。请有人指导我实现这一目标。谢谢
最佳答案
您的问题与您显示 div 的方式有关,包括机器人:<div id="bot"/>
你可以设置这个 div 的样式,让它看起来像你想要的那样; bot Webchat Github 项目上提供了几个示例:
用于侧边栏显示:https://github.com/Microsoft/BotFramework-WebChat/blob/master/samples/sidebar/index.html
对于全窗口:https://github.com/Microsoft/BotFramework-WebChat/tree/master/samples/fullwindow
我强烈建议您看一下第一个示例,其中包含窄、正常和宽 div 的演示
关于botframework - 如何使用直线 API 使聊天机器人显示为实时聊天?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50927479/