Search code examples
botframeworkazure-qna-maker

Bot Framework V4 (Node.js) : QnA maker triggering


I'm in the process of migrating a bot which is currently in V3, to V4 in Node.js. I want to make every user utterance go through QnA maker (even in the middle of dialog flows) which was done using bot.use() function in V3. Is there a way to solve this problem?


Solution

  • If you haven't already, setup your bot to match this sample from the Botbuilder-Samples repo. In this way, every utterance will be passed thru QnAMaker.

    The key piece is to include the following code in your onTurn handler within the check for ActivityTypes.Messages. In this way, every message will be parsed by QnAMaker and the result captured which you can then act against.

    const qnaResults = await this.qnaMaker.getAnswers(turnContext);
    

    Hope of help!