Esempio n. 1
0
        private async Task ResumeAfterQnaMakerDialog(IDialogContext context, IAwaitable <object> result)
        {
            var messageResult = await result;

            if (messageResult.ToString().ToLower().Contains("nomatch"))
            {
                var messageActivity = context.MakeMessage();
                await context.PostAsync(MessageUtility.GetSimpleTextMessage(messageActivity, "We could not find answer to your question"));

                await context.PostAsync(GetMessage(context, ""));

                await context.PostAsync(MessageUtility.GetWelcomeOptionsMessage((Activity)context.Activity, "Or you can look for more options below"));

                context.Done("null");
            }
            else if (messageResult.ToString().ToLower().Contains("retailer"))
            {
                await context.PostAsync(MessageUtility.GetWelcomeOptionsMessage((Activity)context.Activity, "Looking for"));

                context.Done("null");
            }
            else
            {
                context.Wait(MessageReceivedAsync);
            }
        }
        public static IForm <RetailerFinderFormDialog> BuildForm()
        {
            OnCompletionAsyncDelegate <RetailerFinderFormDialog> processOrder = async(context, state) =>
            {
                // call service api and get the Retailers
                var retailers = await GetRetailerFinderApiResponse(state.Location);

                var messageActivity = CreateRetailerMessage(context, retailers);
                state.ResultCount = retailers.ResultCount;
                if (retailers.ResultCount > TakeResultCount)
                {
                    await context.PostAsync(MessageUtility.GetSimpleTextMessage(context.MakeMessage(), $"Here is the list of top {TakeResultCount} nearest locations..."));
                }
                await context.PostAsync(messageActivity);
            };

            return(new FormBuilder <RetailerFinderFormDialog>()
                   .Field(nameof(Location))
                   .OnCompletion(processOrder)
                   .Build());
        }
Esempio n. 3
0
        public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            var message = await result;

            try
            {
                if (message.Text.ToLower().Contains("retailer finder"))
                {
                    try
                    {
                        await context.Forward(Chain.From(() => FormDialog.FromForm(RetailerFinderFormDialog.BuildForm)), ResumeAfterFormDialog, message, CancellationToken.None);
                    }
                    catch (Exception)
                    {
                        await context.PostAsync(MessageUtility.GetWelcomeOptionsMessage((Activity)context.Activity.AsMessageActivity(), $"We could not find retailers for your location. Please try with another Zip/City/State by selecting 'Retailer Finder'."));

                        context.Wait(MessageReceivedAsync);
                    }
                }
                else if (message.Text.ToLower().Contains("faq"))
                {
                    await context.PostAsync(MessageUtility.GetSimpleTextMessage(context.MakeMessage(), "Please enter your question"));

                    await context.Forward(new BasicQnAMakerDialog(), ResumeAfterQnaMakerDialog, message, CancellationToken.None);
                }
                else
                {
                    await context.Forward(new CommonResponsesDialog(), ResumeAfterCommonResponseDialog, message, CancellationToken.None);
                }
            }
            catch (Exception ex)
            {
                //await context.PostAsync(ex.Message);
                //context.Wait(MessageReceivedAsync);
            }
        }
Esempio n. 4
0
        public async Task HandleGoodbye(IDialogContext context, string messageText)
        {
            await context.PostAsync(MessageUtility.GetSimpleTextMessage(context.MakeMessage(), "Bye. Looking forward to our next awesome conversation already."));

            context.Wait(MessageReceived);
        }