示例#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);
            }
        }
示例#2
0
        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);
        }
示例#3
0
        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));
        }
示例#4
0
        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));
        }
示例#5
0
        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);
        }
示例#6
0
        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));
        }
示例#7
0
        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));
        }
示例#8
0
        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));
        }
示例#9
0
        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));
        }
示例#10
0
 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);
     }
 }
示例#11
0
        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);
        }
示例#12
0
        public async override Task <DialogTurnResult> BeginDialogAsync2(DialogContext dc, object options = null, CancellationToken cancellationToken = default)
        {
            await dc.Context.SendActivityAsync("F**k");

            return(dc.Wait(Confirm));
        }
示例#13
0
        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));
        }
示例#14
0
 public override async Task StartAsync(DialogContext context)
 {
     context.Wait(this.MessageReceivedAsync);
 }