Automatically send a message into the WebChat window in Bot Framework

安稳与你 提交于 2020-01-03 03:15:14

问题


I am using Microsoft Bot Framework and I created two bots.

I am trying to build a simple HTML page that will show two webchat windows side by side, each for one of the two bots.

The idea is to have an input box in the page, and when someone types into it, the text gets sent into both webchats at the same time.

However, since webchats are basically iframes, there is not much I can do unless I make the webchat iframe expose some methods to the parent frame. This is the expected browser behaviour.

So my question is: is there any way to control the webchat iframes from a parent frame, or the bot framework's webchats cannot support that?


回答1:


Start with the readme for webchat You do not need to use webchat as an Iframe. you can implement a non Iframe webchat like this:

<!DOCTYPE html>
<html>
  <head>
    <link href="https://cdn.botframework.com/botframework-webchat/latest/botchat.css" rel="stylesheet" />
  </head>
  <body>
    <div id="bot"/>
    <script src="https://cdn.botframework.com/botframework-webchat/latest/botchat.js"></script>
    <script>
      BotChat.App({
        directLine: { secret: direct_line_secret },
        user: { id: 'userid' },
        bot: { id: 'botid' },
        resize: 'detect'
      }, document.getElementById("bot"));
    </script>
  </body>
</html>

This way you will have access to both the Javascript and the CSS so you can customize it to fit your needs. There is a good overview page here



来源:https://stackoverflow.com/questions/46895279/automatically-send-a-message-into-the-webchat-window-in-bot-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!