1

Within main prompt I would like to call child dialog that prompts user for input (ChoicePrompt), save that result to a variable and work with that result.

In sample code what actually ends up happening is that child dialog gets fired but code in main dialog continues before child dialog is finished (before user input).

Sample code of what I would like to achieve:

private async Task<DialogTurnResult> IntentCheckStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) { LuisResult = await InDocRecognizer.RecognizeAsync<InDocChatbotService>(stepContext.Context, cancellationToken); var topIntent = LuisResult.TopIntent().intent; if (LuisResult.TopIntent().score < 0.30) { topIntent = InDocChatbotService.Intent.None; } // if first and second option is close in score prompt user choice between them else if (LuisResult.Intents.ElementAt(0).Value.Score - LuisResult.Intents.ElementAt(1).Value.Score < 0.20) { var topIntent = await stepContext.BeginDialogAsync(nameof(ChooseIntentDialog), LuisResult, cancellationToken); // Code in this dialog continues before user gives input to child dialog "ChooseIntentDialog" } // DO MORE STUFF WITH VARIABLE topIntent } 

I do have a workaround but it's ugly and brakes code style. The way I do it is I return the child dialog and then handle things from ChooseIntentDialog in another waterfall step within main dialog.

This is bad because I need to carry multiple variables to that waterfall step and it just seems completely unnecessary. If I could just make waterfall step wait for child dialog and return it's result without having to do that with another waterfall step.

Is this possible? And if not what is the alternative as my solution does not seem to be very efficient code wise.

1 Answer 1

1

You cannot return to the middle of a step in waterfall dialogs. If you return await stepContext.BeginDialogAsync(nameof(ChooseIntentDialog)...) and then pass the chosen value back in return await stepContext.endDialogAsync(topIntent) if a choice needs to be made, or from main dialog just use return await stepContext.next(topIntent) if it does not, you will have access to the top intent in stepContext.result in your next step. You would just move // DO MORE STUFF WITH VARIABLE topIntent to your next step.

Sign up to request clarification or add additional context in comments.

3 Comments

this is my workaround, moving that to next step in main dialog. Problem with that (at least I see it as a problem) is that I have to move multiple variables to that new step (or make them class-wide, which again isn't ideal). I might still be missing something but this does not seem to me like an elegant solution.
I can understand, but at the same time every prompt puts the results into your stepContext, so by returning in this way, you are basically doing the same thing, except you use a different dialog for the prompt if the choice is close or return the result without prompting if it is not.
Why is it not possible to wait on a Dialog that begins (BeginDialogAsync) within a waterfall step unless you add return to the statement? Is that because of a C# mechanism or perhaps a design choice specific to the WaterfallDialog class?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.