Beispiel #1
0
        private async Task OnOptionSelected(DialogContext context, IMessageActivity result)
        {
            try
            {
                if (result.Text.ToLower().Contains("help") || result.Text.ToLower().Contains("support") || result.Text.ToLower().Contains("problem"))
                {
                    await context.Forward <int>(new SupportDialog(), this.ResumeAfterSupportDialog, result, CancellationToken.None);

                    return;
                }

                var optionSelected = result;

                switch (optionSelected.Text)
                {
                case FlightsOption:
                    context.Call <object>(new FlightsDialog(), this.ResumeAfterOptionDialog);
                    break;

                case HotelsOption:
                    context.Call <object>(new HotelsDialog(), this.ResumeAfterOptionDialog);
                    break;
                }
            }
            catch (TooManyAttemptsException ex)
            {
                await context.PostAsync($"Ooops! Too many attempts :(. But don't worry, I'm handling that exception and you can try again!");

                context.Wait(this.MessageReceivedAsync);
            }
        }
Beispiel #2
0
 public static async Task <DialogTurnResult> Call <T>(this DialogContext context, FormDialog <T> form, object entities = null, object options = null, CancellationToken cancellationToken = default)
     where T : class
 {
     Microsoft.Bot.Builder.Dialogs.Dialog diag = context.Dialogs.Find(typeof(T).Name);
     if (diag != null)
     {
         return(await context.Call <T>(entities, options, cancellationToken));
     }
     else
     {
         context.Dialogs.Add(form);
         DialogFormCaching._dialogs.Add(context.Context.Activity.Conversation.Id, form);
         return(await context.Call <T>(entities, options, cancellationToken));
     }
 }