我如何在Microsoft Botframework v4中使用离线直接线? [英] How can I use offline-directline for Microsofts Botframework v4?

查看:124
本文介绍了我如何在Microsoft Botframework v4中使用离线直接线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在内部运行 microsoft botframework v4 ,因为公司内部限制禁止我在Microsoft Azure上注册该bot或在云中使用该连接器. 我的想法是使用 offline-directline 来模拟本地连接器. 据我所知,该软件包是为Microsoft Botframework V3(而非v4)构建的.有人设法将其用于v4吗?

I need to run the microsoft botframework v4 on-premise since company internal restrictions forbid me to register the bot on Microsoft Azure or use the connector in the cloud. My idea is to use offline-directline to emulate the connector locally. To my knowledge, the package has been built for Microsoft Botframework V3 and not v4. Has anybody managed to use it for v4?

我遵循了说明,但是在尝试实现网络聊天客户端时遇到了麻烦.我在哪里以及如何实现

I followed through instructions however got stuck trying to implement the web chat client. Where and how do I implement

BotChat.App({
    directLine: {
        secret: params['s'],
        token: params['t'],
        domain: params['domain'],
        webSocket: false // defaults to true
    },

直线v4的index.html文件中的

吗? "offline-directline"的文档仅适用于Botframework v3.

in the index.html file of directline v4? The documentation of "offline-directline" is only for Botframework v3.

是否有一个示例存储库,我可以从中找到一些信息?

Is there a sample repository where I could find some info from?

推荐答案

请参阅中的说明. BotFramework-WebChat 存储库,以了解如何在网站中托管Web Chat v4.您会发现如下所示:

Please refer to the instructions in the BotFramework-WebChat repo to see how to host Web Chat v4 in a website. You'll find something that looks like this:

<!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.createDirectLine,而不是像传递给BotChat.AppdirectLine参数那样将相同类型的对象传递给window.WebChat.renderWebChatdirectLine参数.有问题的对象是 DirectLineOptions 对象.

Rather than passing the same kind of object to window.WebChat.renderWebChat's directLine parameter as you would to BotChat.App's directLine parameter, you need to pass the object to window.WebChat.createDirectLine. The object in question is a DirectLineOptions object.

    window.WebChat.renderWebChat({
        directLine: window.WebChat.createDirectLine({
            secret: params['s'],
            token: params['t'],
            domain: params['domain'],
            webSocket: false // defaults to true
        }),

如果您不想将任何参数传递给Web聊天客户端,则可以将它们内联:

If you don't want to have to pass in any parameters to your Web Chat client, you can include them inline:

            secret: '',
            token: '',
            domain: 'http://localhost:3000/directline',
            webSocket: false // defaults to true

如果您不太想在自己的HTML页面中运行Web聊天,我建议您使用前述的离线直接线,而只需使用

And if you're not particular about running Web Chat in your own HTML page, I recommend foregoing offline-directline and just using the Bot Emulator, which is great for interacting with local bots.

这篇关于我如何在Microsoft Botframework v4中使用离线直接线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆