我需要在本地运行microsoft botframework v4,因为公司内部限制禁止我在Microsoft Azure上注册机器人或使用云中的连接器。我的想法是使用offline-directline在本地模拟连接器。据我所知,该软件包是为Microsoft Botframework V3而不是v4构建的。有没有人设法将它用于v4?
我按照说明操作,但试图实施网络聊天客户端。我在哪里以及如何实施
BotChat.App({
directLine: {
secret: params['s'],
token: params['t'],
domain: params['domain'],
webSocket: false // defaults to true
},
在directline v4的index.html文件中? “offline-directline”的文档仅适用于Botframework v3。
是否有一个示例存储库,我可以从中找到一些信息?
请参阅BotFramework-WebChat repo中的说明,了解如何在网站中托管Web Chat v4。你会发现这样的东西:
<!DOCTYPE html>
<html>
<body>
<div id="webchat" role="main"></div>
<script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
<script>
window.WebChat.renderWebChat({
directLine: window.WebChat.createDirectLine({ token: 'YOUR_DIRECT_LINE_TOKEN' }),
userID: 'YOUR_USER_ID',
username: 'Web Chat User',
locale: 'en-US',
botAvatarInitials: 'WC',
userAvatarInitials: 'WW'
}, document.getElementById('webchat'));
</script>
</body>
</html>
而不是像window.WebChat.renderWebChat
的directLine
参数那样将相同类型的对象传递给BotChat.App
的directLine
参数,而是需要将对象传递给window.WebChat.createDirectLine
。有问题的对象是DirectLineOptions
对象。
window.WebChat.renderWebChat({
directLine: window.WebChat.createDirectLine({
secret: params['s'],
token: params['t'],
domain: params['domain'],
webSocket: false // defaults to true
}),
如果您不想将任何参数传递到Web Chat客户端,则可以将它们内联:
secret: '',
token: '',
domain: 'http://localhost:3000/directline',
webSocket: false // defaults to true
如果您不是特别关注在自己的HTML页面中运行Web Chat,我建议使用Bot Emulator,这非常适合与本地机器人进行交互。