自动将消息发送到 Bot Framework 中的 WebChat window

Automatically send a message into the WebChat window in Bot Framework

我正在使用 Microsoft Bot Framework 并创建了两个机器人。

我正在尝试构建一个简单的 HTML 页面,它将并排显示两个网络聊天 windows,每个用于两个机器人之一。

想法是在页面中有一个输入框,当有人在其中输入时,文本会同时发送到两个网络聊天中。

但是,由于网络聊天基本上是 iframe,除非我让网络聊天 iframe 向父框架公开一些方法,否则我无能为力。这是预期的浏览器行为。

所以我的问题是:有没有办法从父框架控制网络聊天 iframe,或者机器人框架的网络聊天不支持?

readme for webchat 开始 您不需要将网络聊天用作 Iframe。您可以像这样实现非 Iframe 网络聊天:

<!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>

这样您就可以访问 Javascript 和 CSS,因此您可以根据自己的需要对其进行自定义。有一个很好的概述页面 here