how to close a QnAMaker dialog?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


how to close a QnAMaker dialog?



I am trying to closing a QnAMaker dialog so that user can go back to the Luis dialog and use it again.



here is my code that i use
in luisdialog.cs:


[LuisIntent("FAQ")]
public async Task FAQ(IDialogContext context, LuisResult result)
{
await context.PostAsync("FAQ");
var userQuestion = (context.Activity as Activity).Text;
await context.Forward(new QnADialog(), ResumeAfterQnA, context.Activity, CancellationToken.None);

//await Task.Run(() => context.Call(new QnADialog(), Callback));
}
private async Task ResumeAfterQnA(IDialogContext context, IAwaitable<object> result)
{
context.Done<object>(null);
}



While here is the QnA dialog:


[Serializable]
[QnAMakerService("endpoint", "knowledge base id", "subscription key")]
public class QnADialog : QnAMakerDialog<object>
{

}



I tried to override the start async method so that it will quit the dialog by using context.done(0) if the user type "done" but the QnA maker doesn't start at all which is confusing.



Also why is that by calling the luis intent using "FAQ" it also tried to go to the knowledge base without the user typing it again is it possible to fix that ?




1 Answer
1



I am trying to closing a QnAMaker dialog so that user can go back to the Luis dialog and use it again.



You can try to override the DefaultMatchHandler and call context.Done to close QnAMaker dialog and pass control back to the parent dialog. The following modified code snippet work for me, please refer to it.


DefaultMatchHandler


context.Done



In LuisDialog:


[LuisIntent("FAQ")]
public async Task HelpIntent(IDialogContext context, LuisResult result)
{
await context.PostAsync("FAQ");
await context.Forward(new QnADialog(), ResumeAfterQnA, context.Activity, CancellationToken.None);
}

private async Task ResumeAfterQnA(IDialogContext context, IAwaitable<object> result)
{
//context.Done<object>(null);
context.Wait(MessageReceived);
}



In QnADialog:


public override async Task DefaultMatchHandler(IDialogContext context, string originalQueryText, QnAMakerResult result)
{
await context.PostAsync($"I found {result.Answers.Length} answer(s) that might help...{result.Answers.First().Answer}.");
context.Done(true);
}



Test result:



enter image description here






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

C# - How to create a semi transparent or blurred backcolor on windows form

Will Oldham

Makefile test if variable is not empty