0

I've created a Microsoft Bot and want to deploy it on my website. How do you keep a chat bot fixed/pinned to a certain location on the website, that it stays there visible even if you browse through different pages. I am using iFrame for the web chat and want to display the chat at the bottom right corner of the website.Previously I was in testing the bot so I created a sample page on the website and put the collapsible iFrame there. This is the code I am using:

<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>
This seems to run perfectly on that page, but I want it on the index and it should stay there even if someone browses a different page.
Bibhas
  • 1
  • 3
  • Please provide an example of what the current result is, and what the desired result would be. Also, please include the code you have already tried. – fin444 Feb 02 '18 at 02:22
  • 3
    Some code would be nice, anyways, I would try to set its styles to something close to the following `.chat-bot { position: fixed; bottom: 0; right: 0 }` – David Lee Feb 02 '18 at 02:27
  • you can probably find more help if needed in the [webchat repository](https://github.com/Microsoft/BotFramework-WebChat) – D4RKCIDE Feb 02 '18 at 21:30

1 Answers1

0

I'm sorry but, this is not currently a feature supported by the WebChat control inherently. Every time the iframe loads, it creates a new conversation and there is no built-in method for re-connecting to a previous conversation with WebChat.

There is extensive discussion about supplying history on startup here: https://github.com/Microsoft/BotFramework-WebChat/issues/365

as well as this pull request: https://github.com/Microsoft/BotFramework-WebChat/pull/615

Eric Dahlvang
  • 8,252
  • 4
  • 29
  • 50