2

I'm working with QnAMakerDialog and cannot figure out how to override the "not found". I am able to override RespondFromQnAMakerResultAsync but that is not called when no answer is found. I tried setting the default message to null or empty string but then QnAMakerDialog automatically response "No match found!" when it doesn't find a match!

I don't want a message when no match is found because I'm just forwarding the message to a LuisDialog. How do I stop this message!!!

Side note: I understand that some Gary guy has a different version of a QnAMakerDialog that does this but I'd really like to just use the standard one from Microsoft. Is this possible?

Nicolas R
  • 13,812
  • 2
  • 28
  • 57
Kevin D.
  • 143
  • 8

1 Answers1

4

That "Gary guy" is Gary Pretty. He made a nice job on QnAMaker, especially a few days ago by providing access to QnAMaker API v3 through a package, which provides a lot of new features compared to QnAMakerDialog.

For every user coming to your question and looking for a similar answer, you should definitely have a look to his package:

With his package, you can directly override NoMatchHandler and you're done.


For those who are reluctant to use a third-party package, even if you have the code, the "official" QnAMakerDialog comes from Microsoft.Bot.Builder.CognitiveServices package, which sources are... also on GitHub.

So if you look in QnAMakerDialog.cs you will see that everything you need is inside MessageReceivedAsync method, in particular the message is sent by this line:

await context.PostAsync(qnaMakerResults.ServiceCfg.DefaultMessage);

As you can also see:

  • MessageReceivedAsync can't be overridden easily

  • even if you hide this method with new and copy paste all the method except the line, you will have problems with some properties like serviceCfg that are internal so can't be used in your own namespace

So the last option will be to copy all the QnA classes from Microsoft Github's project just to remove this line...


EDIT:

As you can see on https://github.com/Microsoft/BotBuilder-CognitiveServices, there are several issues pending around this problem:

I hope there will be an integration in the package soon, as several Pull Request have been provided around that

Nicolas R
  • 13,812
  • 2
  • 28
  • 57
  • Yes, after overriding every virtual method in the Microsoft.Bot.Builder.CognitiveServices.QnAMakerDialog I came to the same conclusion as you. It just isn't setup for what I want to do. I installed Gary's code and it works great. It's not that I am against 3rd party code, or open source, I just like to know for sure if I am downloading stuff unnecessarily that I can actually do, easily, without. Thank you, and much thanks to Gary Pretty. – Kevin D. Feb 28 '18 at 18:07