自动向Bot Framework中的WebChat窗口发送消息 [英] Automatically send a message into the WebChat window in Bot Framework

查看:76
本文介绍了自动向Bot Framework中的WebChat窗口发送消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我正在尝试构建一个简单的HTML页面,该页面将并排显示两个webchat窗口,每个窗口分别针对两个漫游器之一.

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

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

所以我的问题是:有什么方法可以从父框架控制webchat iframe,或者bot框架的webchats无法支持它?

解决方案

网络聊天的自述文件开始您无需将网络聊天用作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,因此可以根据需要进行自定义.在此处

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?

解决方案

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

这篇关于自动向Bot Framework中的WebChat窗口发送消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆