feat: add suggestionsActivityFactory & tests, fix QnAMakerDialog bugs #3475
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes part of #3464
Description
Adds
type QnASuggestionsActivityFactory
for developers to create a custom QnA Maker Active Learning Suggestions Activity to send to users. This provides a more extensive solution to customizing the Activity sent from the QnACardBuilder.getSuggestionsCard which relies on sending Hero Cards.Through the use of a new constructor overload, developers can pass in this factory instead of the normal
activeLearningCardTitle
parameter. When developers use the factory, they must pass in the next parameter,cardNoMatchText
. This parameter is used in both overloads by the dialog to allow users to indicate that the suggestions from QnA Maker didn't match what the user is asking.There's a bug fix on
onPreBubbleEvent()
which should be ported to the other languages. If the incoming activity was a message but an error was thrown during the dialog's execution, it would try to call QnA Maker again. Which is an issue if the error was thrown while trying to call QnA Maker. I encountered this while usingnock
to ensure an Activity-like value was returned fromQnAMakerdialog.suggestionsActivityFactory and QnACardBuilder.getSuggestionsCard. The latter of which is a public static method, so it can be modified by Typescript developers during bot development.
Testing
Added unit tests
FYI @HesselWellema