Botframework 部署自定义webchat bot框架

Botframework 部署自定义webchat bot框架,botframework,bots,web-chat,Botframework,Bots,Web Chat,我克隆了这个repo,并在本地编辑了css。 我想知道我需要部署什么来使用webchat online 如果我想添加这样的小部件,感谢您的帮助 要打开我的聊天机器人,我需要做什么?修改botchat.js文件就足够了吗 如何拥有这样的应用程序 我克隆了这个repo,并在本地编辑了css。我想知道我需要部署什么来使用webchat online 之后,要在网站中嵌入网络聊天,您应该在项目中包含构建的botchat.css和botchat.js文件,并在网页中引用botchat.css和botcha

我克隆了这个repo,并在本地编辑了css。 我想知道我需要部署什么来使用webchat online


如果我想添加这样的小部件,感谢您的帮助 要打开我的聊天机器人,我需要做什么?修改botchat.js文件就足够了吗

如何拥有这样的应用程序

我克隆了这个repo,并在本地编辑了css。我想知道我需要部署什么来使用webchat online

之后,要在网站中嵌入网络聊天,您应该在项目中包含构建的botchat.css和botchat.js文件,并在网页中引用botchat.css和botchat.js

我想添加一个小部件来打开我的聊天机器人,我需要做什么

似乎你想在你的网页上显示聊天图标,允许用户动态打开/折叠你的网络聊天,为了达到这个要求,你不需要修改botchat.js文件,下面的代码示例对我来说很有用,你可以参考一下

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title></title>
    <link href="BotChat/botchat.css" rel="stylesheet" />
    <script src="BotChat/botchat.js"></script>
    <style>
        #mychat {
            margin: 10px;
            position: fixed;
            bottom: 30px;
            right: 10px;
            z-index: 1000000;
        }
    </style>
</head>
<body>
    <div id="container">
        <h1>Hello World</h1>
        <!--other page contents-->
        <img id="mychat" src="https://i.stack.imgur.com/RD7i4.png" style="float:right" />
    </div>
</body>
</html>
<script>
    (function () {
        var div = document.createElement("div");
        document.getElementsByTagName('body')[0].appendChild(div);
        div.outerHTML = "<div id='botDiv' style='width: 400px; height: 0px; margin:10px; position: fixed; bottom: 0; right:0; z-index: 1000;><div  id='botTitleBar' style='height: 40px; width: 400px; position:fixed; cursor: pointer;'></div></div>";
        BotChat.App({
            directLine: { secret: '{directline_secret}' },
            user: { id: 'You' },
            bot: { id: '{your_botid}' }
        }, document.getElementById("botDiv"));

        document.getElementsByClassName("wc-header")[0].setAttribute("id", "chatbotheader");
        document.querySelector('body').addEventListener('click', function (e) {
            e.target.matches = e.target.matches || e.target.msMatchesSelector;
            if (e.target.matches('#chatbotheader')) {
                var botDiv = document.querySelector('#botDiv');

                botDiv.style.height = "0px";

                document.getElementById("mychat").style.display = "block";
            };
        });

        document.getElementById("mychat").addEventListener("click", function (e) {

            document.getElementById("botDiv").style.height = '500px';

            e.target.style.display = "none";
        })
    }());
</script>
测试结果:


如果要使用iframe,则无法自定义设计。对于定制设计,您需要使用Direct line by,您可以更改设计并使机器人完全响应

以下是我正在使用的代码,可以很好地为我工作:

    <!DOCTYPE html>
<html class="no-js lang-en" lang="en">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <title></title>
  <!-- For Bot Frame -->
  <link href="../assets/SCSS/botchat-fullwindow.css" type="text/css" rel="stylesheet" />
  <link href="../assets/SCSS/botchat.css" type="text/css" rel="stylesheet" />
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

</head>
<body class="personal-body">

  <!-- For Bot Code -->
  <div id="BotChatElement">
  </div>
  <img src="../assets/images/chat-2-icon.png" onclick="openchatbot()" class="open-bot" id="button_chat" />

  <script src="../assets/JS/botchat.js"></script>
  <script>

    var model = {
      "userId": "demo1234",
      "userName": "You",
      "botId": "Chatbot Main Tree",
      "botIconUrl": "",
      "botName": "Chatbot Main Tree",
      "secret": "",
      "iconUrl": "",
      "directLineUrl": "https://webchat.botframework.com/v3/directline",
      "webSocketEnabled": "false"
    };[enter image description here][1]

    BotChat.App({
      directLine: {
        secret: model.secret,
        token: model.token,
        domain: model.directLineUrl,
        webSocket: false,
        sendTyping: true
      },
      user: { id: model.userId, name: model.userName },
      bot: { id: model.botId, name: model.botName },
      sendTyping: true,
      resize: 'window'
    },
      document.getElementById("BotChatElement"));

    function openchatbot() {
      $(".wc-chatview-panel *").removeClass("maximizebot");
      $(".wc-chatview-panel").css({ 'bottom': '0', 'display': 'block' });

    }

    $(".minimize-icon").on('click',
      function () {
        $(".wc-chatview-panel").removeClass("minimize-icon");
        $(".wc-chatview-panel ").toggleClass("minimizebot");
        $(".minimize-icon ").toggleClass("maximizebot");

      });
    $(".close-icon").on('click',
      function () {
        $(".wc-chatview-panel ").removeClass("minimizebot");
        $(".wc-chatview-panel ").removeClass("maximizebot");
        $(".wc-chatview-panel").css({ 'bottom': '-500px', 'display': 'none' });
      });
  </script>
</body>

</html>
要部署bot,请执行以下步骤: 创建Azure帐户

您可以从创建免费试用版Azure订阅

将MS Bot框架代码部署到Azure:

您可以看到将MS Bot框架代码部署到Azure的过程 使用VisualStudio的WebChat频道。 你也可以检查这个。但是,本教程使用旧版本的Azure portal。 将bot与WebChat频道连接后,可以在HTML代码中使用嵌入代码


它不工作,机器人显示在整个页面上是的,您需要自定义CSC文件以进行自定义设计