1
votes

I am currently playing around with Bots and LUIS. So I have a running Bot. In my RootDialog, I handle all the intents that I get from LUIS. Now I want to check if an Entity is missing for an intent.

 if (result.Entities.Count == 0) {
 var ct = new CancellationToken();
 await context.Forward(new ParameterDialog(), ResumeAfterParameterDialog, message, ct);

If there is no Entity I'm creating a new child dialog.

public class ParameterDialog : IDialog<object> {
        public async Task StartAsync(IDialogContext context) {
            context.Wait(MessageReceivedAsync);
    }



    public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> argument) {

        argument = new PromptDialog.PromptString("Please enter a parameter", "please try again", 2);

        var prompt = await argument;

        await context.PostAsync($"Your Parameter is: {prompt}");
        context.Done(prompt);
    }             
}

If I could get user input I would then pass it back to my parent dialog.

Now I don't really know how I can stop the Bot and let it wait for user input. Can someone please explain how I can accomplish that? Thank you!

1

1 Answers

3
votes

You are missing a context.Call of the PromptString dialog you are creating.

The context.Call method expects a dialog and a 'callback' method (ResumeAfter) that will be called once the dialog completes (in this case, when PromptString completes).

In your scenario your code should look like:

public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> argument) 
{
   var dialog = new PromptDialog.PromptString("Please enter a parameter", "please try again", 2);

   context.Call(dialog, ResumeAfterPrompt)
}

private Task ResumeAfterPrompt(IDialogContext context, IAwaitable<string> result)
{
    var parameter = await result;
    context.Done(parameter);
}