1

Hello everyone I'm building a bot using the Microsoft Bot Framework and I made a dispatch dialog which calls another dialog when it receives results from LUIS, but when I called the next dialog using the context.Forward() method, and it goes though the public async Task StartAsync(IDialogContext context) but though I use context.Wait(MessageReceivedAsync); method, my dialog never waits for the user's message continues execution by going back to the dialog which called it.

I read answers this similar question but it does not resolve my problem.

This is how I call the Dialog:

await context.Forward(scheduleDialog,ScheduleDialogTerminated,context.MakeMessage(), CancellationToken.None);

Here is the Dialog called:

public class ScheduleDialog : IDialog
    {
        IScheduler scheduler;
        string timeEntity;
        string appointmentEntity;
        string dateEntity;

        public ScheduleDialog(IScheduler scheduler, string date, string time, string appointment) : base()
        {
            dateEntity = date;
            timeEntity = time;
            appointmentEntity = appointment;

            this.scheduler = scheduler;
        }

        public async Task StartAsync(IDialogContext context)
        {
            string message = context.Activity.AsMessageActivity().Text;
            await context.PostAsync($"Scheduling... {message}");
            context.Wait(MessageReceivedAsync);
        }

        public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> argument)
        {
            await context.PostAsync("Waiting for message...");
        }
    }

the MessageReceivedAsync method never gets called wereas I specified that the context should wait for it in the StartAsync method

Community
  • 1
  • 1
Damien Doumer
  • 1,991
  • 1
  • 18
  • 33

1 Answers1

1

You need to add a context.Wait(MessageReceivedAsync); at the end of your MessageReceivedAsync method.

Ezequiel Jadib
  • 14,767
  • 2
  • 38
  • 43