0

I'm looking for ways to catch a Qna Maker no match event and then handle it in a customized way. My current Qna Dialog goes like this :

[Serializable]
public class QnaMakerDialog : QnAMakerDialog
{
    public QnaMakerDialog() : base(new QnAMakerService(new QnAMakerAttribute(<<myQnAAuthKey>>, <<myQnAKnowledgebaseId>>, "Answer not found. Please try it again", 0.5, 1, <<myQnAEndpointHostName>>)))
{
}
    protected override async Task RespondFromQnAMakerResultAsync(IDialogContext context, IMessageActivity message, QnAMakerResults result)
{
...
}
}

The no match custom message works fine when QnA Maker cannot find an answer to a given question. However, I'd like to intercept the event and then log the "no matched" answer on the database.

Thanks in advance, Amintas

Nicolas R
  • 13,812
  • 2
  • 28
  • 57
  • Please separate the code from text by using the code formatting button {}. That will make the question more readable. – user15741 Jun 29 '18 at 18:30
  • Possible duplicate of [Microsoft.Bot.Builder.CognitiveServices.QnAMaker.QnAMakerDialog How to override not found?](https://stackoverflow.com/questions/49016574/microsoft-bot-builder-cognitiveservices-qnamaker-qnamakerdialog-how-to-override) – Nicolas R Jul 02 '18 at 08:39

1 Answers1

2

you can use NoMatchhandler method for this.

 public class BotFrameworkFaQDialog:QnAMakerDialog<object>
{
    public override async Task NoMatchHandler(IDialogContext context, string originalQueryText)
    {
        await context.PostAsync($"Sorry i could't find answer for {originalQueryText} .");
        context.Wait(MessageReceived);
    }
}
Ein2012
  • 1,103
  • 1
  • 13
  • 33