private async Task <DialogTurnResult> WelcomeStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var card = CardUtils.CreateCardFromJson("gretaWelcomeCard");

            var activity = new Microsoft.Bot.Schema.Activity
            {
                Attachments = new List <Attachment>()
                {
                    new Attachment()
                    {
                        Content     = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(card)),
                        ContentType = "application/vnd.microsoft.card.adaptive"
                    }
                },
                Type = ActivityTypes.Message
            };

            var promptOptions = new PromptOptions
            {
                Prompt      = MessageFactory.Text(registeredMsg),
                RetryPrompt = MessageFactory.Text(registeredMsg + " (Yes/No)")
            };

            await stepContext.Context.SendActivityAsync(activity);

            return(await stepContext.PromptAsync(nameof(ConfirmPrompt), promptOptions, cancellationToken));
        }
Exemple #2
0
        private async Task <DialogTurnResult> ConfirmPasswordStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            UserEmail = (string)stepContext.Result;
            var customer = (await PrestashopApi.GetCustomerByEmail(UserEmail)).First();

            stepContext.Values[CUSTOMER] = customer;
            var card = CardUtils.CreateCardFromJson("submitPassword");

            var activity = new Activity
            {
                Attachments = new List <Attachment>()
                {
                    new Attachment()
                    {
                        Content     = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(card)),
                        ContentType = "application/vnd.microsoft.card.adaptive"
                    }
                },
                Type = ActivityTypes.Message
            };

            var promptOptions = new PromptOptions
            {
                Prompt      = activity,
                RetryPrompt = activity
            };

            await stepContext.Context.SendActivityAsync($"Hi, in order to verify you're {customer.GetFullName()}, please enter your password",
                                                        null, InputHints.IgnoringInput, cancellationToken);

            return(await stepContext.PromptAsync("PasswordValidator", promptOptions, cancellationToken));
        }
Exemple #3
0
        private async Task <DialogTurnResult> PromptCardStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var card = CardUtils.CreateCardFromJson("productInfoFillingCard");

            var activity = new Activity
            {
                Attachments = new List <Attachment>()
                {
                    new Attachment()
                    {
                        Content     = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(card)),
                        ContentType = "application/vnd.microsoft.card.adaptive"
                    }
                },
                Type = ActivityTypes.Message
            };

            var opts = new PromptOptions
            {
                Prompt      = activity,
                RetryPrompt = activity
            };

            return(await stepContext.PromptAsync(nameof(TextPrompt), opts));
        }
Exemple #4
0
        public async Task <Attachment> ToAdaptiveCard(IPrestashopApi prestashopApi)
        {
            var card = CardUtils.CreateCardFromJson("confirmOrderCard");

            var user = (await prestashopApi.GetCustomerById(User.PrestashopId.Value)).First();

            //Ara hem convertit el JSON a un AdaptiveCard i editarem els fragments que ens interessen.

            //Primer editem el FactSet (informació de l'usuari que sortirà a la fitxa).
            var containerFact = (card.Body[1] as AdaptiveContainer);
            var factSet       = (containerFact.Items[1] as AdaptiveFactSet);

            factSet.Facts.Add(new AdaptiveFact("Ordered by:", user.GetFullName()));
            factSet.Facts.Add(new AdaptiveFact("Company:", user.Company));

            //Ara editarem la informació que sortirà dels productes
            var containerProducts = (card.Body[3] as AdaptiveContainer);

            foreach (OrderLine orderLine in OrderLine)
            {
                AdaptiveColumnSet columns       = new AdaptiveColumnSet();
                AdaptiveColumn    productColumn = new AdaptiveColumn();

                var product = (await prestashopApi.GetProductById(orderLine.ProductId)).First();

                AdaptiveTextBlock productText = new AdaptiveTextBlock(product.GetNameByLanguage(Languages.English));
                productText.Wrap = true;

                productColumn.Width = "stretch";
                productColumn.Items.Add(productText);
                columns.Columns.Add(productColumn);

                AdaptiveColumn amountColumn = new AdaptiveColumn();

                AdaptiveTextBlock amount = new AdaptiveTextBlock(orderLine.Amount.ToString());
                amount.Wrap = true;

                amountColumn.Width = "auto";
                amountColumn.Items.Add(amount);
                columns.Columns.Add(amountColumn);

                containerProducts.Items.Add(columns);
            }

            var attachment = new Attachment()
            {
                Content     = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(card)),
                ContentType = "application/vnd.microsoft.card.adaptive"
            };

            return(attachment);
        }
        protected virtual async Task DialogHelpMessage(DialogContext innerDc)
        {
            var card = CardUtils.CreateCardFromJson("gretaWelcomeCard");

            var activity = new Activity
            {
                Attachments = new List <Attachment> {
                    new Attachment
                    {
                        Content     = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(card)),
                        ContentType = "application/vnd.microsoft.card.adaptive"
                    }
                },
                Type = ActivityTypes.Message
            };

            await innerDc.Context.SendActivityAsync(activity);
        }