0

我创建了一个 Microsoft Bot,并希望将其部署在我的网站上。您如何将聊天机器人固定/固定到网站上的某个位置,即使您浏览不同的页面,它也会保持可见。我正在使用 iFrame 进行网络聊天,并希望在网站的右下角显示聊天。之前我正在测试机器人,所以我在网站上创建了一个示例页面并将可折叠的 iFrame 放在那里。这是我正在使用的代码:

<div id="bot" />
    <Script>
    (function () {
        var div = document.createElement("div");
        document.getElementsByTagName('body')[0].appendChild(div);
        div.outerHTML = "<div id='botDiv' style='height: 38px; position: fixed; 
        right: 0; bottom: 0; z-index: 1000; background-color: #fff'><div 
        id='botTitleBar' style='height: 38px; width: 400px; position:fixed; cursor: 
        pointer;'></div><iframe width='400px' height='600px' 
        src='https://webchat.botframework.com/embed/sec key'></iframe></div>";
        document.querySelector('body').addEventListener('click', function (e) {
        e.target.matches = e.target.matches || e.target.msMatchesSelector;
         if (e.target.matches('#botTitleBar')) {
           var botDiv = document.querySelector('#botDiv');
           botDiv.style.height = botDiv.style.height == '600px' ? '38px' : '600px';
             };
           });
       }());
    </script>
这似乎在该页面上完美运行,但我希望它在索引上,即使有人浏览不同的页面,它也应该保留在那里。

4

1 回答 1

0

很抱歉,目前这不是 WebChat 控件本身支持的功能。每次 iframe 加载时,它都会创建一个新对话,并且没有内置方法可以重新连接到与 WebChat 的先前对话。

这里有关于在启动时提供历史的广泛讨论:https ://github.com/Microsoft/BotFramework-WebChat/issues/365

以及这个拉取请求: https ://github.com/Microsoft/BotFramework-WebChat/pull/615

于 2018-02-06T01:16:18.770 回答