将QNA maker bot与硬编码响应混合

时间:2017-08-29 08:26:09

标签: node.js botframework chatbot

我正在尝试制作一个具有硬编码欢迎的机器人,然后与QNA制造商进行对话。我下面的代码不起作用。最终发送案件' Vraagen'到QNA制造商,而不是等待用户的回应。我还希望有一个硬编码对话框,例如'请问你的问题:"与QNA制造商对话,但我还没有找到如何做到这一点。提前致谢。

var bot = new builder.UniversalBot(connector);

bot.dialog('/', [
    function(session){
        session.beginDialog('welcome');
    }
]);

bot.dialog('welcome',
    [
        function (session) {
        builder.Prompts.choice(session, 
                            'Hallo, Ik ben de citybot, U kunt mij vragen stellen of contactgegevens ontvangen. Om het gesprek op elk moment opnieuw te starten, zeg alsjeblieft stop.',
                            'Vraagen|Contact Info',
                            {listStyle: builder.ListStyle.button});
        },
        function (session, results){
            var selection = results.response.entity;
            switch(selection){
                case "Vraagen":
                    return session.beginDialog('qna');
                case "Contact Info":
                    return session.beginDialog('contact');
            }
        }
    ]
);

bot.dialog('restart-welcome',
[
    function (session) {
    builder.Prompts.choice(session, 
                        'Is er nog iets waarmee ik je kan helpen?',
                        'Vraagen|Contact Info',
                        {listStyle: builder.ListStyle.button});
    },
    function (session, results){
        var selection = results.response.entity;
        switch(selection){
            case "Vraagen":
                return basicQnAMakerDialog.beginDialog;
            case "Contact Info":
                return session.beginDialog('contact');
        }
    }
]
).triggerAction({
    matches: /^stop$/i,
});;

//=========================================================
// Recognizers
//=========================================================

var qnarecognizer = new builder_cognitiveservice.QnAMakerRecognizer({
    knowledgeBaseId: 'XXXX', 
    subscriptionKey: 'XXXX',
    top: 4});

    var basicQnAMakerDialog = new builder_cognitiveservice.QnAMakerDialog({
        recognizers: [qnarecognizer],
        defaultMessage: 'No match! Try changing the query terms!',
        qnaThreshold: 0.3
    });

bot.dialog('qna', basicQnAMakerDialog);

basicQnAMakerDialog.beginDialog

0 个答案:

没有答案