Directline机器人在实施令牌而不是秘密后回显输入的消息?

issue我已经开发了自己的API,该API使用Directline API生成并刷新令牌。问题出在那之后,当我在上面的代码中集成令牌而不是Secret时,我的机器人正确地回答了问题,而且回显了所提供的输入。没有用代码完成的实现,并且使用secret和emulator都可以正常工作。

(function () {

    $('head').append('<link rel="stylesheet" type="text/css" href="https://static2.sharepointonline.com/files/fabric/office-ui-fabric-core/9.6.0/css/fabric.min.css">');
    $('head').append('<link rel="stylesheet" type="text/css" href="https://cdn.botframework.com/botframework-webchat/latest/botchat.css">');
    $('head').append('<link rel="stylesheet" type="text/css" href="chatbot.css">');


    var chatIsVisible = false;

    $(function () {

        $(".botwrapper").toggle();



        $('<i class="ms-Icon ms-Icon--ChromeMinimize minimizeIcon" aria-hidden="true"></i>').appendTo(".wc-header");

        $("#botbutton").click(function () {
            chatIsVisible = true;
            $("#botbutton").toggle("fade",function () {
                $("#BotChatGoesHere").toggle("fade",function () {
                    $(".chatbot .wc-shellinput").focus();
                });
            });

        });

        $(".wc-header .minimizeIcon").click(function () {
            $("#BotChatGoesHere").toggle("fade",function () { $("#botbutton").toggle("fade"); chatIsVisible = false; });

        });

        setTimeout(showBot,3000);
        setInterval(shakeBot,10000);


        function showBot() {
            $("#botbutton").toggle("fade").effect("bounce",{ times: 3 },"slow");
        }

        function shakeBot() {

            if (!chatIsVisible) {
                $("#botbutton").effect("bounce","slow");
            }
        }


    });

    const params = BotChat.queryParams(location.search);

    const user = {
        id: params['userid'] || 'userid',name: params['username'] || 'User'
    };

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

    const speechOptions = {
        speechRecognizer: new CognitiveServices.SpeechRecognizer({ locale: 'de-DE',subscriptionKey: '' }),speechsynthesizer: new CognitiveServices.Speechsynthesizer({
            gender: CognitiveServices.SynthesisGender.Female,subscriptionKey: '',voiceName: 'microsoft Server Speech Text to Speech Voice (de-DE,Stefan,Apollo)'
        })
    };

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

    function ConnectWebBotChat() {
        let headers = {
        };
        if (botConnection !== null) {
            // for refresh token
            headers = {
                old_token: TokenResult.token,user_id: TokenResult.userId
            };
        }
        $.ajax({
            url: "http://localhost:64102/api/DLToken",//async: "false",method: "POST",data: "",dataType: 'json',contentType: "application/json",headers: headers,success: function (result,status,jqXHR) {
                TokenResult = result;
                botConnection = new BotChat.DirectLine({
                    domain: params['domain'],secret: result.token,token: result.token,webSocket: params['webSocket'] && params['webSocket'] === 'true'
                });
                BotChat.App({
                    bot: bot,resize: 'detect',user: user,speechOptions: speechOptions,directLine: botConnection
                },document.getElementById('BotChatGoesHere'));
                PingBotConnection(true);
                console.log("SAM Connection Refreshed : " + status);
            },error(jqXHR,textStatus,errorThrown) {
                console.log("SAM Connection Refresh : " + errorThrown);
            }
        });
    }
    function PingBotConnection(_IsFirstTime = false) {
        botConnection
            .postactivity({
                from: user,name: 'Connection Test',type: 'event',value: ''
            })
            .subscribe(function (id) {
                console.log('SAM Pinged OK!');
            });
        botConnection.connectionStatus$
            .subscribe(connectionStatus => {
                handleConnection(connectionStatus);
                if (!_IsFirstTime)
                    ConnectWebBotChat();
            });
    }
    function handleConnection(connectionStatus) {
        switch (connectionStatus) {
            case 0:
                console.log("SAM Uninitialized");
                break;
            case 1:
                console.log("SAM Connecting");
                break;
            case 2:
                console.log("SAM Online");
                break;
            case 3:
                console.log("SAM ExpiredToken");
                break;
            case 4:
                console.log("SAM FailedToConnect");
                break;
            case 5:
                console.log("SAM Ended");
                break;
        }
    }

    let botConnection = null;
    let TokenResult = null;
    ConnectWebBotChat();
    setInterval(() => { PingBotConnection(false); },1780000);

})();

在使用Directline令牌时,Bot不应回显输入的消息。

在此先感谢

kjhsdgfhkjshfuwerytu 回答:Directline机器人在实施令牌而不是秘密后回显输入的消息?

看上面发布的代码,您好像将令牌作为秘密传递了。我建议您只通过一个而不是全部。

enter image description here

此外,我建议您升级到Web chat v4,因为它在自定义方面提供了更多支持。 sample提供了有关如何从Web Chat v3迁移到v4的详细指南。

本文链接:https://www.f2er.com/3166969.html

大家都在问