Bot Framework: Have both QnA Maker and IntentDialogs

余生长醉 提交于 2019-12-12 04:53:35

问题


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.

Something like:

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');
        }
])
);

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


回答1:


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.');
        }
]);


来源:https://stackoverflow.com/questions/46019425/bot-framework-have-both-qna-maker-and-intentdialogs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!