QnAmaker.ai与ms botframework node.js:欢迎消息和得分答案

问题描述 投票:0回答:1

我正在使用QnAmaker.ai进行使用node.js msbotframework开发的FAQ bot。我想实现更多其他功能:

  1. 机器人连接时向用户发送欢迎消息。
  2. 为每个答案提供分数。对于例如这是有用的“是”和“否”。有没有办法将此信息存储在QnAmaker KB中。
  3. 此外,我已启用chit-chat以及我自定义的问题和答案集。然而,chit-chat的答案优先于自定义的答案。我希望自定义答案覆盖chit-chat。

我现在使用的代码非常基础,并从教程中获取:

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

谢谢

node.js botframework azure-bot-service azure-cognitive-services qnamaker
1个回答
0
投票

我发现你现在正在使用BotBuilder SDK v3,其中v4是最新版本。我在下面的回答集中在v3,但是对于这样一个简单的机器人升级到v4并不是很难。从现在开始,v3将不会获得功能更新。

  1. 机器人连接时向用户发送欢迎消息。 此功能可以在每个通道的基础上有所不同。您可以收听conversationUpdate event来触发消息,或者您可以在WebChat中发布事件活动。以下链接描述了两种方式: Handle user and conversation events (v3) How to properly send a greeting message and common issues from customers

  1. 为每个答案提供分数 目前QnaMaker尚无法做到这一点。我建议使用自定义存储,例如Application Insights或CosmosDB。 看看新宣布的Active Learning possibilities of QnAMaker。他们还没有提供适用于Node的SDK,但如果您有兴趣获得更多见解(并使用它来训练您的模型),则此功能可能对您有用。

  1. 我希望自定义答案覆盖chit-chat Chit-chat功能只是在您的知识库中添加了一组预先填充的内容,这与您自己添加的QnA集没有任何不同。默认情况下,您无法通过自己的答案“覆盖”ChitChat。 你可以删除你想要覆盖的特定ChitChat QnA集,或者你可以删除correct the top scoring answer
© www.soinside.com 2019 - 2024. All rights reserved.