问题
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