本文介绍了Bot框架:同时具有QnA Maker和IntentDialogs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能否同时使QnAMakerDialog和自定义IntentDialog一起工作?因此,QnA Maker会回答知识库中所有与FAQ相关的查询,我也可以将一些自定义命令硬编码到BotFramework中.

Is it possible to have both QnAMakerDialog and custom IntentDialog to work together? So, the QnA Maker will answer all FAQ related queries from the knowledge base and I can also hardcode some custom commands into the BotFramework.

类似的东西:

var basicQnAMakerDialog = new cognitiveservices.QnAMakerDialog({
    recognizers: [recognizer],
    defaultMessage: 'Sorry, I did not understand that.',
    qnaThreshold: 0.3
});

bot.dialog('/', basicQnAMakerDialog);

bot.dialog( new builder.IntentDialog()
.matchesAny([/Test/i], [
        function (session) {
           session.send('This is not from QnA Maker');
        }
])
);

我输入"Test"时的当前输出是QnA制造商的defaultMessage

My current output when I type 'Test' is the defaultMessage from QnA maker

推荐答案

我知道了.这段代码给了我想要的输出:

I figured it out. This code gave me the desired output:

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

var intentrecognizer = new builder.IntentDialog();

var intents = new builder.IntentDialog({ recognizers: [intentrecognizer, qnarecognizer] });
bot.dialog('/', intents);

intents.matches('qna', [
    function (session, args, next) {
        var answerEntity = builder.EntityRecognizer.findEntity(args.entities, 'answer');
        session.send(answerEntity.entity);
    }
]);

intents.matchesAny([/Test/i], [
        function (session) {
           session.send('This is not from QnA Maker.');
        }
]);

intents.onDefault( [
        function (session) {
           session.send('Sorry, I don\'t know that.');
        }
]);

这篇关于Bot框架:同时具有QnA Maker和IntentDialogs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 00:30