1

我们正在构建一个 MS botframework 机器人,它将托管在我们控制的网站上。

有没有办法将会话 ID 从主机网站传递到网络聊天机器人小部件,以便在处理来自机器人内部的消息时可以访问它?

如果没有,是否可以访问此处描述的“t”令牌参数 http://docs.botframework.com/connector/embed-chat-c​​ontrol /

谢谢

4

3 回答 3

3

目前无法使用聊天控件执行此操作。

如果您想要更紧密的集成,您应该考虑使用 DirectLINE API 并通过它构建您自己的 UX 体验。

于 2016-04-21T17:43:51.427 回答
1

可以检索对话 ID,它在您的机器人的消息中可用。为此,您应该向https://webchat.botframework.com/api/conversations发出带有值“BOTCONNECTOR {您的安全代码}”的标头授权的POST 请求

作为结果或请求,您应该会收到新的令牌和 conversationId。该令牌用于创建 iframe 标记,conversationId 可用作您的会话令牌。

于 2016-06-03T13:10:45.650 回答
0

Using DirectLine and Backchannel might help you here. You'll find the info in the readme on this repo if you scroll to the last section. It allows Webchat and the host can send/receive whatever you want from each other.

<body onload="postLoadMessage()">
    <div id="BotChatGoesHere" class="wc-narrow"></div>
    <script src="botchat.js"></script>
    <script>
        var params = BotChat.queryParams(location.search);
        var user = { id: '***' };
        var bot = { id: '***' };
        window['botchatDebug'] = params['debug'] && params['debug'] === "true";
        var botConnection = new BotChat.DirectLine({
            secret: '****',
            token: params['t'],
            domain: params['domain'],
            webSocket: params['webSocket'] && params['webSocket'] === "true" // defaults to true
        });
        BotChat.App({
            botConnection: botConnection,
            user: user,
            bot: bot
        }, document.getElementById("BotChatGoesHere"));
       
        //var x= whatever value you want to send;
        const postLoadMessage = () => {
            botConnection
                .postActivity({type: "event", value: x , from: {id: "me" }, name: "PageLoaded"})
                .subscribe(id => console.log("success"));
        }
    </script>
</body>

The code given above is how i used it to send value x when the page with the bot is loaded.

I hope this helps :)

于 2017-06-22T06:10:29.063 回答