botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

Bot c#: How to restart the conversation with the last input from user

Open msBot1111 opened this issue 9 years ago • 6 comments

In my Bot I use prompt.text and in the ResumeAfter method I want to check if user said yes, no or something else, and if it's not yes or no to call again my Root dialog(which is Luis class) with the input from the user. Here is the code: PromptDialog.Text(context, ResumeAfterAsync, $"Was this helpful?");
private async Task ResumeAfterAsync(IDialogContext context, IAwaitable result) { string msg = await result; if(msg=="yes") { await context.PostAsync($"Ok, thanks."); } else if(msg=="no") { await context.PostAsync($"another"); } else { context.Wait(MessageReceived); //-Here I need to send msg and to start again the conversation }

msBot1111 avatar Jan 25 '17 15:01 msBot1111

You might consider using IDialogStack.Forward to forward the message on to the LUIS dialog as a new child (instead of the existing root): https://docs.botframework.com/en-us/technical-faq/#what-is-idialogstack-forward-in-the-c-builder-sdk

But what are you going to do if the user said "yes" or "no"? You have to go somewhere next: https://docs.botframework.com/en-us/technical-faq/#ensure-all-dialog-methods-end-with-a-plan-to-handle-the-next-message

and would that place be the initial root LUIS dialog?

willportnoy avatar Jan 25 '17 22:01 willportnoy

If user said "yes" or "no", I'm calling different methods, It's working well. I've changed the else statment with this: context.Forward(new MainDialog(),ResumeCopleted,msg,System.Threading.CancellationToken.None); MainDialog is my LuisDIalog And now in ResumeCopleted what should I do?? I've tried private Task ResumeCopleted(IDialogContext context, IAwaitable result) { context.Wait(MessageReceived); } but that's not the right implementation because this returns status 200 ok and i need to give me the result from Luis search(with the msg as entity) i want to send msg to MainDialog and continue the conversation without waiting the user to type again

msBot1111 avatar Jan 26 '17 09:01 msBot1111

The IAwaitable in "ResumeCopleted" carries the result (of type T) from the MainDialog, so that you can post a message to the user or take some other action before resuming the wait for the next user message.

willportnoy avatar Jan 30 '17 02:01 willportnoy

Ok, thanks It's working now

msBot1111 avatar Jan 30 '17 12:01 msBot1111

Hi msBot1111 Could you please share code snippet how did u pass the user input back to Luis dialog. Even I want map user prompt to one of the entity in the luis and set it to a variable.

ghadshivedika avatar Apr 09 '17 06:04 ghadshivedika

how to achieve the same in v4

alokraj68 avatar Oct 10 '19 11:10 alokraj68