1

我已经创建了一个内部部署的 Microsoft 机器人(即 IIS 中的托管机器人并使用离线 Directline 进行仿真,使用节点包离线-直接线-gss)。

我可以与该服务聊天,但我面临的问题是,由于“ConversationUpdate”在网络聊天中不起作用,我在页面加载和机器人中发布“conversationupdate”类型的活动、文本“conversationupdate”解决方案的 Post 方法,我写了一个条件来检查 activity.text 是否等于 'conversationupdate' 并编写代码来发送欢迎消息。但这并没有发生。

在运行 index.js 的命令提示符中,我可以看到发布的活动,但机器人解决方案没有返回任何(或)东西。

这是html页面代码:

<!DOCTYPE html>
    <html>
      <head>
    <meta name="WebPartPageExpansion" content="full" />
        <link href="BotChat/botchat.css" rel="stylesheet" />
      </head>
      <body>
        <div id="bot"/>
    <script src="Masterfiles/js/jquery-1.11.0.min.js"></script>    
    <script src="BotChat/botchat.js"></script>

            <script>
        $(window).on('load', function () {
            try
            {
                botWindowExpandAndCollapse();
            }
            catch(err)
            {
                console.log(err.message);
            }                       
    });

      function botWindowExpandAndCollapse()
        {
            try
            {

            var directLine = new BotChat.DirectLine({
                        secret: params['s'],
                        user: user,
                        bot: bot,
                        token: params['t'],
                        domain: 'http://127.0.0.1:3000/directline',
                        webSocket: false // defaults to true
                    });

            directLine
            .postActivity({ type: "conversationupdate", from: user, user:user, text:"conversationupdate"})
            .subscribe(id => alert("Conversation updated"));

                $('#bot .wc-chatview-panel').css('height','50px');
                $('#bot .wc-chatview-panel').addClass('IconView');
                //Script to hide
                $( "<span class='DPfigure need-help'>Need Help</span>" ).insertAfter( ".wc-chatview-panel" );
                if ($(".wc-chatview-panel").hasClass("fullHeight")) 
                {
                    $(".need-help").hide();
                    $('#bot .wc-chatview-panel').css('right','17px');
                }
                else
                {
                    $(".need-help").show();
                    $('#bot .wc-chatview-panel').css('right','105px');
                }


                $('.DPfigure').click(function(){
                    $('#bot .wc-chatview-panel').toggleClass('fullHeight');
                    $('#bot .wc-chatview-panel').toggleClass('IconView');
                    if ($(".wc-chatview-panel").hasClass("fullHeight")) 
                    {
                        $(".need-help").hide();
                        $('#bot .wc-chatview-panel').css('right','17px');
                    }
                    else
                    {
                        $(".need-help").show();
                        $('#bot .wc-chatview-panel').css('right','105px');
                    }
                });
            }
            catch(err)
            {
                console.log(err.message);
            }
        }


                var params = BotChat.queryParams(location.search);
    debugger;
                var user = {
                    id: Math.random().toString(36).substring(7),
                    name: params["username"] || 'username'
                    };

                var bot = {
                    id: params['botid'] || 'botid',
                    name: params["botname"] || 'botname'
                };

                window['botchatDebug'] = params['debug'] && params['debug'] === "true";

                    BotChat.App({
                    directLine: {
                        secret: params['s'],
                        token: params['t'],
                        domain: 'http://127.0.0.1:3000/directline',
                        webSocket: false // defaults to true
                    },
                    user: user,
                    bot: bot,
                    locale: params['locale'],
                    resize: 'detect'
                    // sendTyping: true,    // defaults to false. set to true to send 'typing' activities to bot (and other users) when user is typing
                }, document.getElementById("bot"));

            </script>
      </body>
    </html>

这是 index.js 代码:

const url = require("url");
const directline = require("offline-directline-gss/dist/bridge");
const express = require("express");
const app = express();

const config = {
    localDirectLine: {
            hostUrl: "http://localhost",
            port: "3000"
        },
    apbots:[
        {
            botId:"TestingBot",
            botUrl:"http://localhost:3374/api/messages",
            "msaAppId": "",
            "msaPassword": ""
        },
    ]
};

directline.initializeRoutes(app, config);

指示发布消息成功的命令提示符:

指示发布消息成功的命令提示符

任何人都可以请阐明这可能是什么原因。谢谢你!

4

0 回答 0