我正在使用QnAmaker.ai进行使用node.js msbotframework开发的FAQ bot。我想实现更多其他功能:
我现在使用的代码非常基础,并从教程中获取:
var previewRecognizer = new builder_cognitiveservices.QnAMakerRecognizer({
knowledgeBaseId: process.env.QnAKnowledgebaseId,
authKey: process.env.QnAAuthKey || process.env.QnASubscriptionKey
});
var basicQnAMakerPreviewDialog = new builder_cognitiveservices.QnAMakerDialog({
recognizers: [previewRecognizer],
defaultMessage: 'Sorry, I did not understand. Please say that again.',
qnaThreshold: 0.3
}
);
bot.dialog('basicQnAMakerPreviewDialog', basicQnAMakerPreviewDialog);
// Recognizer and and Dialog for GA QnAMaker service
var recognizer = new builder_cognitiveservices.QnAMakerRecognizer({
knowledgeBaseId: process.env.QnAKnowledgebaseId,
authKey: process.env.QnAAuthKey || process.env.QnASubscriptionKey, // Backward compatibility with QnAMaker (Preview)
endpointHostName: process.env.QnAEndpointHostName
});
var basicQnAMakerDialog = new builder_cognitiveservices.QnAMakerDialog({
recognizers: [recognizer],
defaultMessage: 'Sorry, I did not understand. Please say that again.',
qnaThreshold: 0.3
}
);
bot.dialog('basicQnAMakerDialog', basicQnAMakerDialog);
bot.dialog('/', //basicQnAMakerDialog);
[
function (session) {
var qnaKnowledgebaseId = process.env.QnAKnowledgebaseId;
var qnaAuthKey = process.env.QnAAuthKey || process.env.QnASubscriptionKey;
var endpointHostName = process.env.QnAEndpointHostName;
// QnA Subscription Key and KnowledgeBase Id null verification
if ((qnaAuthKey == null || qnaAuthKey == '') || (qnaKnowledgebaseId == null || qnaKnowledgebaseId == ''))
session.send('Please set QnAKnowledgebaseId, QnAAuthKey and QnAEndpointHostName (if applicable) in App Settings. Learn how to get them at https://aka.ms/qnaabssetup.');
else {
if (endpointHostName == null || endpointHostName == '')
// Replace with Preview QnAMakerDialog service
session.replaceDialog('basicQnAMakerPreviewDialog');
else
// Replace with GA QnAMakerDialog service
session.replaceDialog('basicQnAMakerDialog');
}
}
]);
谢谢
我发现你现在正在使用BotBuilder SDK v3,其中v4是最新版本。我在下面的回答集中在v3,但是对于这样一个简单的机器人升级到v4并不是很难。从现在开始,v3将不会获得功能更新。
conversationUpdate
event来触发消息,或者您可以在WebChat中发布事件活动。以下链接描述了两种方式:
Handle user and conversation events (v3)
How to properly send a greeting message and common issues from customers