问题
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?
回答1:
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:
It's open source ! So on GitHub
On Nuget here
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 easilyeven if you hide this method with
new
and copy paste all the method except the line, you will have problems with some properties likeserviceCfg
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:
- https://github.com/Microsoft/BotBuilder-CognitiveServices/issues/50
- https://github.com/Microsoft/BotBuilder-CognitiveServices/issues/58
- https://github.com/Microsoft/BotBuilder-CognitiveServices/issues/75
I hope there will be an integration in the package soon, as several Pull Request have been provided around that
来源:https://stackoverflow.com/questions/49016574/microsoft-bot-builder-cognitiveservices-qnamaker-qnamakerdialog-how-to-override