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); } }
public async override Task <DialogTurnResult> BeginDialogAsync2(DialogContext dc, object options = null, CancellationToken cancellationToken = default) { await dc.Context.SendActivityAsync("Step One"); return(await dc.Wait(StepTwo, nameof(FuckDialog))); //return dc.Wait(StepTwo); }
public async Task <DialogTurnResult> ToppingStep(DialogContext dc, object options = null, CancellationToken cancellationToken = default) { dc.ActiveDialog.State["stepID"] = "ToppingStep"; await dc.Context.SendActivityAsync("What topping would you like?"); return(dc.Wait(ConfirmationStep)); }
public async Task <DialogTurnResult> SauceStep(DialogContext dc, object options = null, CancellationToken cancellationToken = default) { dc.ActiveDialog.State["stepID"] = "SauceStep"; await dc.Context.SendActivityAsync("What sauce would you like?"); return(dc.Wait(CardSauce)); }
private async Task ResumeAfterSupportDialog(DialogContext context, IMessageActivity result) { var ticketNumber = result; await context.PostAsync($"Thanks for contacting our support team. Your ticket number is {ticketNumber.Text}."); context.Wait(this.MessageReceivedAsync); }
public async Task <DialogTurnResult> DestinationStep(DialogContext dc, object options = null, CancellationToken cancellationToken = default) { dc.ActiveDialog.State["stepID"] = "DestinationStep"; await dc.Context.SendActivityAsync("From where would you like to go?"); return(dc.Wait(CardDestination)); }
public async override Task <DialogTurnResult> BeginDialogAsync2(DialogContext dc, object options = null, CancellationToken cancellationToken = default) { dc.ActiveDialog.State["stepID"] = "SizeStep"; await dc.Context.SendActivityAsync("Welcome to Pizza maker"); await dc.Context.SendActivityAsync("What size would you like?"); return(dc.Wait(SauceStep)); }
public async override Task <DialogTurnResult> BeginDialogAsync2(DialogContext dc, object options = null, CancellationToken cancellationToken = default) { dc.ActiveDialog.State["stepID"] = "OriginStep"; await dc.Context.SendActivityAsync("Welcome to Flight Booker"); await dc.Context.SendActivityAsync("Where would you like to go?"); return(dc.Wait(DestinationStep)); }
public async Task <DialogTurnResult> ConfirmationStep(DialogContext dc, object options = null, CancellationToken cancellationToken = default) { dc.ActiveDialog.State["stepID"] = ""; dc.ActiveDialog.State["Intent"] = nameof(FoodNewDialog); dc.ActiveDialog.State["IntentAction"] = "Confirm"; var reply = MessageFactory.Attachment(new List <Attachment>()); reply.Attachments.Add(Cards.GetThumbnailCard(dc.ActiveDialog.State).ToAttachment()); await dc.Context.SendActivityAsync(reply); return(dc.Wait(CardConfirmed)); }
private async Task ResumeAfterOptionDialog(DialogContext context, object result) { try { var message = result; } catch (Exception ex) { await context.PostAsync($"Failed with message: {ex.Message}"); } finally { context.Wait(this.MessageReceivedAsync); } }
private async Task ShowOptions(DialogContext context) { var options = new PromptOptions() { Choices = new List <Microsoft.Bot.Builder.Dialogs.Choices.Choice>() { new Microsoft.Bot.Builder.Dialogs.Choices.Choice(HotelsOption), new Microsoft.Bot.Builder.Dialogs.Choices.Choice(FlightsOption) }, Prompt = MessageFactory.Text("Are you looking for a flight or a hotel?"), RetryPrompt = MessageFactory.Text("Not a valid option") }; var optionsDialog = this.FindDialog("options"); context.Wait(OnOptionSelected); await optionsDialog.BeginDialogAsync(context, options); //PromptDialog.Choice(context, this.OnOptionSelected, new List<string>() { FlightsOption, HotelsOption }, "Are you looking for a flight or a hotel?", "Not a valid option", 3); }
public async override Task <DialogTurnResult> BeginDialogAsync2(DialogContext dc, object options = null, CancellationToken cancellationToken = default) { await dc.Context.SendActivityAsync("F**k"); return(dc.Wait(Confirm)); }
public async Task <DialogTurnResult> StepTwo(DialogContext dc, object options = null, CancellationToken cancellationToken = default) { await dc.Context.SendActivityAsync("Step Two, " + (string)options + " You wrote : " + dc.Context.Activity.Text); return(dc.Wait(Confirm)); }
public override async Task StartAsync(DialogContext context) { context.Wait(this.MessageReceivedAsync); }