【问题标题】:Keep web chat fixed in the entire website在整个网站中保持网络聊天固定
【发布时间】:2018-02-02 02:15:18
【问题描述】:

我创建了一个 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>
这似乎在该页面上完美运行,但我希望它在索引上,即使有人浏览不同的页面,它也应该保留在那里。

【问题讨论】:

  • 请举例说明当前结果是什么,以及期望的结果是什么。另外,请附上您已经尝试过的代码。
  • 一些代码会很好,无论如何,我会尝试将其样式设置为接近以下.chat-bot { position: fixed; bottom: 0; right: 0 }
  • 如果需要,您可以在webchat repository 中找到更多帮助

标签: html css botframework web-chat


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-05
    • 2012-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 2020-12-01
    相关资源
    最近更新 更多