0

I am using QnAmaker.ai for FAQ bot developed using node.js msbotframework. I want to implement few more additional features:

  1. Welcome message to the user when the bot connects.
  2. Provide scores for every answer. For e.g. Was this useful "Yes" and "No". Is there a way to store this information in the QnAmaker KB.
  3. Also, I have enabled chit-chat along with my custom set of question and answers. However answers from chit-chat are taking preference over the custom ones. I want the custom answers to override the chit-chat.

The code I am using as of now is very basic and picked up from the tutorial:

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

Thanks

Ashy Ashcsi
  • 1,529
  • 7
  • 22
  • 54

1 Answers1

0

I see that you are using BotBuilder SDK v3 at the moment, where v4 is the newest release. My answers below are focussed on v3, however for such a simple bot upgrading to v4 wouldn't be really hard. v3 won't get feature updates from now on.

  1. Welcome message to the user when the bot connects.

    This functionality can differ on a per channel basis. You could listen to the conversationUpdate event to trigger a message or you could post an event activity in the WebChat for example. Links below describe both ways:


  1. Provide scores for every answer

    This isn't possible yet in QnaMaker at the moment. I would advise to use custom storage for this, like Application Insights or CosmosDB.

    Take a look at the newly announced Active Learning possibilities of QnAMaker. They don't offer an SDK for Node yet, but this functionality might be of your interest if you are interested in getting more insights (and using it to train your model).


  1. I want the custom answers to override the chit-chat

    The Chit-chat feature just adds a pre-populated set of in your knowledge base, which isn't any different than the QnA sets you added yourself. It isn't possible to 'override' the ChitChat by your own answers by default.

    You could remove the specific ChitChat QnA sets which you would like to override or you could correct the top scoring answer.

Mick
  • 2,946
  • 14
  • 19
  • Hi Mick, thanks for the answer. With #2, I actually meant adding suggested actions for every question and answer pair. They do have this feature for bot built using Qnamaker + csharp. https://blog.botframework.com/2017/09/28/qna-maker-revisited-suggested-actions-app-insights/ I am looking for nodejs version of this code to implement it in my FAQ bot. – Ashy Ashcsi Mar 05 '19 at 06:51
  • @AshyAshcsi, as far as I know the blogpost you provided is focussed on the preview version of QnAMaker. The Active Learning link I provided is focussed on the GA version. At the moment the example is only for BotBuilder v4 and C#, but they are working on a v4 Node sample. – Mick Mar 05 '19 at 12:26