Search code examples
javascriptchatbotframeworkchatbotdirect-line-botframework

How to load the chat application in an iframe without using the <iframe> tag?


I am trying to make a multi tenant Chatbot application using microsoft's Bot Framework webchat, So I want my clients to include this kind of code which I think is standard for such applications:

<script src="link to the cdn" ></script> 
<script> 
    BotfuelWebChat.init({ appToken: '444107', 
    size: { width: 500, height: 600 }, 
    startOpen: false,
    startFullScreen: false, 
      theme: { colors: { background: '#faf3db', main: '#244891', 
      primary: '#0084f4' }, layout: { compact: false, rounded: false, 
      shadowed: false, noHeader: false, noBorder: false, 
      noHelpMessage: false } } }); 
</script>

Now my question is what javascript or jquery code should be written in the CDN included above such that my application gets loaded in the chatbox of the client.

I am using Node.js for backend of the application.


Solution

  • Just for your reference, and for more the details your requirements, I think you should implememnt yourself.

    var BotfuelWebChat = {
        init:(options)=>{
            const params = BotChat.queryParams(location.search);
            var div = document.createElement('div');
            div.id='bot';
            div.style.width =options.size.width+"px";
            div.style.height =options.size.height+"px";
            div.style.position ="relative";
            document.body.appendChild(div);
    
            BotChat.App({
                  bot: {id: 'botid'},
                  locale: params['locale'],
                  resize: 'detect',
                  user: {id:'userid'},
                  directLine: {
                    secret: options.appSecret,
                    token: options.appToken
                  }
                }, div);
            }
    }
    

    And in your html script:

    <script>
    
        BotfuelWebChat.init({
          appToken:'directline secret',
          size: { width: 500, height: 600 }
          })
        </script>