Exemple #1
0
        // Waterfall Step 2
        private async Task <DialogTurnResult> OpenSignInDialogAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var command = ((FoundChoice)stepContext.Result).Value;

            stepContext.Values["command"] = command;

            if (!_signInRequiredCommands.Contains(command))
            {
                return(await stepContext.ContinueDialogAsync(cancellationToken : cancellationToken));
            }

            return(await stepContext.BeginDialogAsync(nameof(SignInDialog), null, cancellationToken));
        }
        private async Task <DialogTurnResult> ValidateOptionsAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var options = stepContext.Context.Activity.Text;
            await stepContext.Context.SendActivityAsync($"Obrigado por você {options}", cancellationToken : cancellationToken);

            await Task.Delay(1000);

            await stepContext.Context.SendActivityAsync("Em que mais posso ajudar?", cancellationToken : cancellationToken);

            //Salvando Avaliação
            await SaveAvaliacao(stepContext, options);

            return(await stepContext.ContinueDialogAsync(cancellationToken : cancellationToken));
        }
Exemple #3
0
        private async Task <DialogTurnResult> ValidateOption(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var options = stepContext.Context.Activity.Text;
            await stepContext.Context.SendActivityAsync($"Gracias por tu {options}", cancellationToken : cancellationToken);

            await Task.Delay(1000);

            //GUARDAR CALIFICACION
            await SaveQualification(stepContext, options);

            await stepContext.Context.SendActivityAsync("¿En que mas te puedo ayudar?", cancellationToken : cancellationToken);

            return(await stepContext.ContinueDialogAsync(cancellationToken : cancellationToken));
        }
        private async Task <DialogTurnResult> FinalProcess(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var userConfirmation = stepContext.Context.Activity.Text;

            if (userConfirmation.ToLower().Equals("sim"))
            {
                //Save DataBase
                string userId    = stepContext.Context.Activity.From.Id;
                var    userModel = await _databaseService.User.FirstOrDefaultAsync(x => x.id == userId);

                // Update user
                userModel.phone    = newUserModel.phone;
                userModel.fullName = newUserModel.fullName;
                userModel.email    = newUserModel.email;

                _databaseService.User.Update(userModel);
                await _databaseService.SaveAsync();

                //Save medical appointment
                medicalAppointment.id     = Guid.NewGuid().ToString();
                medicalAppointment.idUser = userId;
                await _databaseService.MedicalAppointments.AddAsync(medicalAppointment);

                await _databaseService.SaveAsync();

                await stepContext.Context.SendActivityAsync("Sua consulta foi salva com êxito!", cancellationToken : cancellationToken);

                //Show sumary
                string sumaryMedical = $"Para: {userModel.fullName}" +
                                       $"{Environment.NewLine} 📞 Telefone: {userModel.phone}" +
                                       $"{Environment.NewLine} 📧 Email: {userModel.email}" +
                                       $"{Environment.NewLine} 📅 Data: {medicalAppointment.date}" +
                                       $"{Environment.NewLine} ⏰ Hora: {medicalAppointment.time}";



                await stepContext.Context.SendActivityAsync(sumaryMedical, cancellationToken : cancellationToken);

                await Task.Delay(1000);

                await stepContext.Context.SendActivityAsync("Em que mais posso ajudar?", cancellationToken : cancellationToken);

                medicalAppointment = new MedicalAppointmentModel();
            }
            else
            {
                await stepContext.Context.SendActivityAsync("Não tem problema, será na próxima", cancellationToken : cancellationToken);
            }
            return(await stepContext.ContinueDialogAsync(cancellationToken));
        }
Exemple #5
0
        private async Task <DialogTurnResult> SelectedOption(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            //Preinscripcionª1
            string selected = stepContext.Context.Activity.Text;

            string[] dtr = selected.Split('~');
            if (dtr[0] == "Preinscripcion")
            {
                switch (dtr[1])
                {
                case "11":
                    string curse = "0";
                    return(await stepContext.BeginDialogAsync(nameof(PreinscriptionDialog), curse, cancellationToken : cancellationToken));

                case "21":
                    string curse2 = "1";
                    return(await stepContext.BeginDialogAsync(nameof(PreinscriptionDialog), curse2, cancellationToken : cancellationToken));

                case "22":
                    string curse3 = "2";
                    return(await stepContext.BeginDialogAsync(nameof(PreinscriptionDialog), curse3, cancellationToken : cancellationToken));

                case "23":
                    string curse4 = "3";
                    return(await stepContext.BeginDialogAsync(nameof(PreinscriptionDialog), curse4, cancellationToken : cancellationToken));

                case "31":
                    string curse5 = "4";
                    return(await stepContext.BeginDialogAsync(nameof(PreinscriptionDialog), curse5, cancellationToken : cancellationToken));

                case "32":
                    string curse6 = "5";
                    return(await stepContext.BeginDialogAsync(nameof(PreinscriptionDialog), curse6, cancellationToken : cancellationToken));

                case "33":
                    string curse7 = "6";
                    return(await stepContext.BeginDialogAsync(nameof(PreinscriptionDialog), curse7, cancellationToken : cancellationToken));

                default:
                    break;
                }
            }
            if (selected == "atras")
            {
                return(await stepContext.BeginDialogAsync(nameof(CursesDialog), cancellationToken : cancellationToken));
            }

            return(await stepContext.ContinueDialogAsync(cancellationToken : cancellationToken));
        }
Exemple #6
0
        private async Task <DialogTurnResult> PromptStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var authenticatedUserIsAuthenticated = await _AuthenticatedUserAccessor.GetAsync(stepContext.Context, () => new AuthenticatedUser());

            if (authenticatedUserIsAuthenticated.IsAuthenticated)
            {
                return(await stepContext.ContinueDialogAsync());
            }
            else
            {
                return(await stepContext.BeginDialogAsync(nameof(OAuthPrompt), null, cancellationToken));
            }

            //return await stepContext.BeginDialogAsync(nameof(OAuthPrompt), null, cancellationToken);
        }
Exemple #7
0
        private static async Task <DialogTurnResult> ReemplazarDialog(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            //var reply = stepContext.Context.Activity.CreateReply();
            //reply.Attachments = new List<Attachment> { CreateHeroCard().ToAttachment() };
            //await stepContext.Context.SendActivityAsync(reply, cancellationToken);


            //stepContext.Values["transport"] = ((FoundChoice)dc.).Value;
            if (((FoundChoice)stepContext.Result).Value == "Otro")
            {
                return(await stepContext.ReplaceDialogAsync("waterfallStepsOtro", null, cancellationToken));
            }

            return(await stepContext.ContinueDialogAsync(cancellationToken));
        }
        private async Task <DialogTurnResult> ValidateOption(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var options = stepContext.Context.Activity.Text;
            await stepContext.Context.SendActivityAsync($"<b>Gracias por tu {options}<b>", cancellationToken : cancellationToken);

            await Task.Delay(2000);

            await stepContext.Context.SendActivityAsync("<b>Ten un lindo día 😊, espero verte pronto 😉<b>", cancellationToken : cancellationToken);

            //GUardar calificacion
            await SaveQualification(stepContext, options);


            return(await stepContext.ContinueDialogAsync(cancellationToken : cancellationToken));
        }
        public async Task <DialogTurnResult> CustomerAuthenticationStepAsync(WaterfallStepContext stepContext,
                                                                             CancellationToken cancellationToken)
        {
            var state = await Accessors.CustomerDataState.GetAsync(stepContext.Context,
                                                                   cancellationToken : cancellationToken);

            if (state.Customer != null)
            {
                return(await stepContext.ContinueDialogAsync(cancellationToken));
            }
            return(await stepContext.PromptAsync(VerifyByPicturePromt, new PromptOptions
            {
                Prompt = await Chatter.GetActivityAsync(stepContext.Context, StaticTexts.VerifyByPictureText),
                RetryPrompt = await Chatter.GetActivityAsync(stepContext.Context, StaticTexts.VerifyByPictureText)
            }, cancellationToken));
        }
Exemple #10
0
        private async Task <DialogTurnResult> MessageReceivedSavingAfterFinancing(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            object projectCosts;

            stepContext.Values.TryGetValue("projectCosts", out projectCosts);
            if (Convert.ToBoolean(projectCosts))
            {
                var message = (string)stepContext.Result;

                if (!string.IsNullOrEmpty(message))
                {
                    double.TryParse(message, out this.housingSubsidies);

                    var financingAmount = this.projectCost - (this.ownResources + this.housingSubsidies);
                    this.finAmount = financingAmount;
                    await stepContext.Context.SendActivityAsync($"Financing Amount for your project is: {financingAmount}  €");

                    stepContext.Values["financingAmount"] = true;
                    return(await stepContext.PromptAsync($"{nameof(RenovationDialog)}.confirm",
                                                         new PromptOptions
                    {
                        Prompt = MessageFactory.Text("Do you wish to continue?")
                    }, cancellationToken));
                }
                else
                {
                    this.housingSubsidies = 0;
                    return(await stepContext.ContinueDialogAsync());
                }
            }
            else
            {
                var result = (bool)stepContext.Result;
                if (result)
                {
                    return(await stepContext.PromptAsync($"{nameof(RenovationDialog)}.text",
                                                         new PromptOptions
                    {
                        Prompt = MessageFactory.Text("Please provide your total monthly income:")
                    }, cancellationToken));
                }
                else
                {
                    return(await stepContext.EndDialogAsync());
                }
            }
        }
Exemple #11
0
        private async Task <DialogTurnResult> NameConfirmStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            // Get the current profile object from user state.
            var userProfile = await _accessors.UserProfile.GetAsync(stepContext.Context, () => new UserProfile(), cancellationToken);

            // Update the profile.
            userProfile.Name = (string)stepContext.Result;

            await _accessors.UserProfileAccessor.SetAsync(stepContext.Context, userProfile);

            await _accessors.UserState.SaveChangesAsync(stepContext.Context);

            // We can send messages to the user at any point in the WaterfallStep.
            await stepContext.Context.SendActivityAsync(MessageFactory.Text($"Thanks {stepContext.Result}."), cancellationToken);

            return(await stepContext.ContinueDialogAsync(cancellationToken));
        }
Exemple #12
0
        private async Task <DialogTurnResult> FinalProcess(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var userConfirmation = stepContext.Context.Activity.Text;

            if (userConfirmation.ToLower().Equals("si"))
            {
                //Save Database
                //string userId = stepContext.Context.Activity.From.Id;

                //var newInscriptionModel = new PreinscriptionModel();
                //newInscriptionModel.id = Guid.NewGuid().ToString();
                //newInscriptionModel.idUser = userId;
                //newInscriptionModel.date = DateTime.Now.Date;
                //newInscriptionModel.lastName = preIncriptionModel.lastName;
                //newInscriptionModel.name = preIncriptionModel.name;
                //newInscriptionModel.celular = preIncriptionModel.celular;
                //newInscriptionModel.correo = preIncriptionModel.correo;
                //newInscriptionModel.ci = preIncriptionModel.ci;
                //newInscriptionModel.curso = preIncriptionModel.curso;

                //await _databaseService.Preinscription.AddAsync(newInscriptionModel);
                //await _databaseService.SaveAsync();

                //await stepContext.Context.SendActivityAsync("Tu preinscripcion se guardo con exito.", cancellationToken: cancellationToken);


                ////Show Summary
                //string summaryPreinscription = $"Apellidos: {preIncriptionModel.lastName}" +
                //    $"{Environment.NewLine} Telefono: {preIncriptionModel.celular}" +
                //    $"{Environment.NewLine} Correo: {preIncriptionModel.correo}" +
                //    $"{Environment.NewLine} Ci: {preIncriptionModel.ci}" +
                //    $"{Environment.NewLine} Curso: {preIncriptionModel.curso}" +
                //    $"{Environment.NewLine} Nombres: {preIncriptionModel.name}";

                //await stepContext.Context.SendActivityAsync(summaryPreinscription, cancellationToken: cancellationToken);
                //await Task.Delay(1000);
                //await stepContext.Context.SendActivityAsync("¿En que mas puedo ayudarte?", cancellationToken: cancellationToken);
                //preIncriptionModel = new PreinscriptionModel();
            }
            else
            {
                await stepContext.Context.SendActivityAsync("No hay problema, sera la proxima", cancellationToken : cancellationToken);
            }

            return(await stepContext.ContinueDialogAsync(cancellationToken : cancellationToken));
        }
Exemple #13
0
        private async Task <DialogTurnResult> DescriptionConfirmStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            // Get the current profile object from user state.
            var userProfile = await _accessors.UserProfile.GetAsync(stepContext.Context, () => new UserProfile(), cancellationToken);

            var createNewData = await _accessors.CreateNewData.GetAsync(stepContext.Context, () => new CreateNewData(), cancellationToken);

            createNewData.Description = (string)stepContext.Result;
            await _accessors.CreateNewData.SetAsync(stepContext.Context, createNewData);

            await _accessors.UserState.SaveChangesAsync(stepContext.Context);

            // We can send messages to the user at any point in the WaterfallStep.
            await stepContext.Context.SendActivityAsync(MessageFactory.Text($"Thanks {userProfile.Name}, the description will be '{createNewData.Description}'."), cancellationToken);

            return(await stepContext.ContinueDialogAsync(cancellationToken));
        }
Exemple #14
0
        private async Task <DialogTurnResult> DispatchToTopIntentAsync(WaterfallStepContext stepContext, string intent, RecognizerResult recognizerResult, CancellationToken cancellationToken)
        {
            // find proper Dialog for that intent

            Intent foundIntent = Intents.AllIntents.Find(k => k.IntentName.Equals(intent));

            if (foundIntent != null)
            {
                return(await stepContext.BeginDialogAsync(foundIntent.IntentName, recognizerResult.Entities, cancellationToken));
            }
            else
            {
                await stepContext.Context.SendActivityAsync(MessageFactory.Text($"Sorry. Could not understand your request."), cancellationToken);

                return(await stepContext.ContinueDialogAsync());
            }
        }
Exemple #15
0
        public async Task <DialogTurnResult> AskForContactLegalAttorney(WaterfallStepContext sc, CancellationToken cancellationToken)
        {
            _state = await _accessor.GetAsync(sc.Context, () => new ImmigrationState());

            var travel = _state.LegalContactResponse = (string)sc.Result;

            if (travel.ToLower().Contains("yes"))
            {
                await _responder.ReplyWith(sc.Context, ImmigrationResponses.ResponseIds.HaveLegalMessage, new { travel });
            }

            return(await sc.ContinueDialogAsync());

            //return await sc.PromptAsync(DialogIds.AskForContactLegalAttorney, new PromptOptions()
            //{
            //    Prompt = await _responder.RenderTemplate(sc.Context, sc.Context.Activity.Locale, ImmigrationResponses.ResponseIds.AskForContactLegalAttorney),
            //});
        }
Exemple #16
0
        public async Task <DialogTurnResult> CustomerIdStepAsync(WaterfallStepContext stepContext,
                                                                 CancellationToken cancellationToken)
        {
            var state = await Accessors.CustomerDataState.GetAsync(stepContext.Context,
                                                                   cancellationToken : cancellationToken);

            if (state.Customer != null)
            {
                return(await stepContext.ContinueDialogAsync(cancellationToken));
            }
            await Chatter.SendMessageAsync(stepContext.Context, StaticTexts.WelcomeOrderText);

            return(await stepContext.PromptAsync(CustomerIdPrompt, new PromptOptions
            {
                Prompt = await Chatter.GetActivityAsync(stepContext.Context, StaticTexts.CustomerIdText),
                RetryPrompt = await Chatter.GetActivityAsync(stepContext.Context, StaticTexts.CustomerNotFoundText)
            }, cancellationToken));
        }
Exemple #17
0
        private async Task <DialogTurnResult> MessageReceivedSavingAfterFinancing(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            if (Convert.ToBoolean(stepContext.Values["projectCost"]))
            {
                var message = (decimal)stepContext.Result;

                if (!string.IsNullOrEmpty(message.ToString()))
                {
                    stepContext.Values["wishToContinue"] = true;
                    double.TryParse(message.ToString(), out this.housingSubsidies);
                    var financingAmount = this.projectCost - (this.ownResources + this.housingSubsidies);
                    this.finAmount = financingAmount;
                    await stepContext.Context.SendActivityAsync($"Financing Amount for your project is: {financingAmount}  €");

                    return(await stepContext.PromptAsync($"{nameof(MiscellaneousDialog)}.confirm",
                                                         new PromptOptions
                    {
                        Prompt = MessageFactory.Text("Do you wish to continue?")
                    }, cancellationToken));
                }
                else
                {
                    this.housingSubsidies = 0;
                    stepContext.Values["wishToContinue"] = false;
                    return(await stepContext.ContinueDialogAsync());
                }
            }
            else
            {
                bool result = (bool)stepContext.Result;
                if (result)
                {
                    return(await stepContext.PromptAsync($"{nameof(MiscellaneousDialog)}.number",
                                                         new PromptOptions
                    {
                        Prompt = MessageFactory.Text("Please provide your total monthly income:")
                    }, cancellationToken));
                }
                else
                {
                    return(await stepContext.EndDialogAsync());
                }
            }
        }
        private async Task <DialogTurnResult> GiveFeedback(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            string message = (string)stepContext.Result;

            if (!string.IsNullOrEmpty(message))
            {
                await stepContext.Context.SendActivityAsync(MessageFactory.Text($"Pleased to meet you, {message}."),
                                                            cancellationToken);

                var context        = stepContext.Context;
                var emotionOutcome = await UserProfileAccessor.GetAsync(context, cancellationToken : cancellationToken);

                emotionOutcome.Received = message;

                await context.SendActivityAsync(emotionOutcome.Received, cancellationToken : cancellationToken);
            }

            return(await stepContext.ContinueDialogAsync(cancellationToken));
        }
        private async Task <DialogTurnResult> ActionAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)

        {
            var activity = stepContext.Context.Activity;

            if (activity.Value != null)
            {
                var Value       = JsonConvert.DeserializeObject <JObject>(activity.Value.ToString());
                var ActionValue = Value["Action"];
                if (ActionValue != null)
                {
                    var state = await stepContext.ContinueDialogAsync();
                }
                else
                {
                    ImBackData imBackData = JsonConvert.DeserializeObject <ImBackData>(activity.Value.ToString());
                    activity.Text = imBackData.msteams.value;
                }
            }

            var topScoringintent = LuisData.LuisResult(activity.Text);

            switch (topScoringintent)
            {
            case "Cancel":
                await stepContext.Context.SendActivityAsync(MessageFactory.Text("Cancelling All dialogs please restart the flow"));

                return(await stepContext.CancelAllDialogsAsync(cancellationToken));

            case IntentToken.PTOApply:
                return(await stepContext.ReplaceDialogAsync(nameof(BookTimeOffDialog)));

            case IntentToken.PTOBalance:
                return(await stepContext.ReplaceDialogAsync(nameof(TimeOfBalanceDialog)));

            default:
                string path        = TimeOffBL.GetPath();
                string WelcomeCard = File.ReadAllText(path + "\\Cards\\NoneIntent.json");
                await stepContext.Context.SendActivityAsync(MessageFactory.Attachment(SendCards.SendAdaptiveCard(WelcomeCard)), cancellationToken);

                return(await stepContext.CancelAllDialogsAsync(cancellationToken));
            }
        }
Exemple #20
0
        private async Task <DialogTurnResult> SelectedOption(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            //Preinscripcionª1
            string selected = stepContext.Context.Activity.Text;

            string[] dtr = selected.Split('~');
            if (dtr[0] == "Preinscripcion")
            {
                switch (dtr[1])
                {
                case "1":
                    string curse = "Curso de Microsoft Teams y OneDrive";
                    return(await stepContext.BeginDialogAsync(nameof(PreinscriptionDialog), curse, cancellationToken : cancellationToken));

                case "2":
                    string curse2 = "Diplomado en Educación Superior Universitaria a Distancia";
                    return(await stepContext.BeginDialogAsync(nameof(PreinscriptionDialog), curse2, cancellationToken : cancellationToken));

                case "3":
                    string curse3 = "Diplomado en Planificación y Desarrollo de Competencias Profesionales en Educación Superior";
                    return(await stepContext.BeginDialogAsync(nameof(PreinscriptionDialog), curse3, cancellationToken : cancellationToken));

                case "4":
                    string curse4 = "Maestría en Administración de Empresas";
                    return(await stepContext.BeginDialogAsync(nameof(PreinscriptionDialog), curse4, cancellationToken : cancellationToken));

                case "5":
                    string curse5 = "Maestría en Recursos Naturales y Gestión Ambiental";
                    return(await stepContext.BeginDialogAsync(nameof(PreinscriptionDialog), curse5, cancellationToken : cancellationToken));

                case "6":
                    string curse6 = "Maestría en Educación Superior Universitaria";
                    return(await stepContext.BeginDialogAsync(nameof(PreinscriptionDialog), curse6, cancellationToken : cancellationToken));

                default:
                    break;
                }
            }

            return(await stepContext.ContinueDialogAsync(cancellationToken : cancellationToken));
        }
Exemple #21
0
        private async Task <DialogTurnResult> Process(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            userText = stepContext.Context.Activity.Text;

            var newStepContext = stepContext;

            newStepContext.Context.Activity.Text = userText;

            var luisResult = await _luisService._luisRecognizer.RecognizeAsync(newStepContext.Context, cancellationToken);

            var Entities = luisResult.Entities.ToObject <EntityLuis>();

            if (Entities.Instance.Gestion?.Count > 0)
            {
                // Capturar la entidad
                var entityCapture = Entities.Instance.Gestion.FirstOrDefault();
                await stepContext.Context.SendActivityAsync(entityCapture.Text, cancellationToken : cancellationToken);
            }

            return(await stepContext.ContinueDialogAsync(cancellationToken : cancellationToken));
        }
Exemple #22
0
        private async Task <DialogTurnResult> NameStepAsync(WaterfallStepContext step, CancellationToken cancellationToken = default(CancellationToken))
        {
            var userState = await Accessors.UserInfoAccessor.GetAsync(step.Context, () => null);

            if (!string.IsNullOrEmpty(userState.Guest.Name))
            {
                await step.Context.SendActivityAsync($"Great, we already have your name {userState.Guest.Name}!  Just one more question.");

                return(await step.ContinueDialogAsync());
            }
            else
            {
                return(await step.PromptAsync(
                           NamePrompt,
                           new PromptOptions
                {
                    Prompt = MessageFactory.Text("What is your name?"),
                },
                           cancellationToken));
            }
        }
Exemple #23
0
 private async Task <DialogTurnResult> MessageReceivedReEvaluate(WaterfallStepContext stepContext, CancellationToken cancellationToken)
 {
     if (Convert.ToBoolean(stepContext.Values["projectCost"]))
     {
         var message = (decimal)stepContext.Result;
         if (!string.IsNullOrEmpty(message.ToString()))
         {
             double.TryParse(message.ToString(), out this.ownResources);
             return(await stepContext.PromptAsync($"{nameof(MiscellaneousDialog)}.number",
                                                  new PromptOptions
             {
                 Prompt = MessageFactory.Text("Please provide the amount of housing subsidies:")
             }, cancellationToken));
         }
         else
         {
             this.ownResources = 0;
             return(await stepContext.ContinueDialogAsync());
         }
     }
     else
     {
         stepContext.Values["fanancingEveryMonth"] = false;
         var result = (bool)stepContext.Result;
         if (result)
         {
             return(await StartAsync(stepContext, cancellationToken));
         }
         else
         {
             stepContext.Values["fanancingEveryMonth"] = true;
             return(await stepContext.PromptAsync($"{nameof(MiscellaneousDialog)}.confirm",
                                                  new PromptOptions
             {
                 Prompt = MessageFactory.Text("Do you wish to calculate your saving after fanancing every month?")
             }, cancellationToken));
         }
     }
 }
Exemple #24
0
        private async Task <DialogTurnResult> LoginStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var authenticatedUserIsAuthenticated = await _AuthenticatedUserAccessor.GetAsync(stepContext.Context, () => new AuthenticatedUser());

            if (authenticatedUserIsAuthenticated.IsAuthenticated)
            {
                return(await stepContext.ContinueDialogAsync());
            }

            // Get the token from the previous step. Note that we could also have gotten the
            // token directly from the prompt itself. There is an example of this in the next method.
            var tokenResponse = (TokenResponse)stepContext.Result;

            if (tokenResponse?.Token != null)
            {
                AuthenticatedUser AuthenticatedUser = new AuthenticatedUser();
                AuthenticatedUser.IsAuthenticated  = true;
                AuthenticatedUser.JwtSecurityToken = tokenResponse.Token;

                await _AuthenticatedUserAccessor.SetAsync(stepContext.Context, AuthenticatedUser);

                // Pull in the data from the Microsoft Graph.
                var client = new SimpleGraphClient(tokenResponse.Token);
                var me     = await client.GetMeAsync();

                var title = !string.IsNullOrEmpty(me.JobTitle) ?
                            me.JobTitle : "Unknown";

                await stepContext.Context.SendActivityAsync($"You're logged in as {me.DisplayName} ({me.UserPrincipalName}); you job title is: {title}");

                await stepContext.Context.SendActivityAsync("Your intent please:");

                //return await stepContext.PromptAsync(nameof(ConfirmPrompt), new PromptOptions { Prompt = MessageFactory.Text("Your intent please:") }, cancellationToken);
            }

            //await stepContext.Context.SendActivityAsync(MessageFactory.Text("Login was not successful please try again."), cancellationToken);

            return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));
        }
        /// <summary>
        /// Resolve everything is OK.
        /// </summary>
        private async Task <DialogTurnResult> AskByAttributesDialog(
            WaterfallStepContext stepContext,
            CancellationToken cancellationToken)
        {
            var context = stepContext.Context;

            if (!askedForFeature)
            {
                featuresToAsk = await _itemService.GetAllFeaturesToAsk(pimItems);

                askedForFeature = true;
            }

            if (!featuresToAsk.Any())
            {
                await context.SendActivityAsync(Messages.FindItemNothingToAsk);

                stepContext.ActiveDialog.State["stepIndex"] = ShowItemsDialogIndex;
                return(await stepContext.ContinueDialogAsync());
            }

            var feature = featuresToAsk[0];

            var choices = feature.GetPrintableValues();

            choices.Add(Messages.Skip);
            var prompt = $"{GetPrepositon()} **{feature.Description}**?";

            return(await stepContext.PromptAsync(
                       AskForPropertyPrompt,
                       new PromptOptions
            {
                Prompt = MessageFactory.Text(prompt),
                RetryPrompt = MessageFactory.Text(prompt + Messages.CancelPrompt),
                Choices = ChoiceFactory.ToChoices(choices),
            },
                       cancellationToken));
        }
Exemple #26
0
        private async Task <DialogTurnResult> ValidateOption(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var options = stepContext.Context.Activity.Text;

            switch (options)
            {
            case "Usuarios":
                await stepContext.Context.SendActivityAsync("Actualmente no tenemos cursos disponibles para Doctorados...");

                return(await stepContext.ContinueDialogAsync(cancellationToken : cancellationToken));

            default:
                break;
            }
            //await stepContext.Context.SendActivityAsync($"Gracias por tu {options}", cancellationToken: cancellationToken);
            //await Task.Delay(1000);
            //await stepContext.Context.SendActivityAsync("¿En qué más te puedo ayudar?", cancellationToken: cancellationToken);
            //Save Qualification
            //await SaveQualification(stepContext, options);

            //original
            return(await stepContext.NextAsync(cancellationToken : cancellationToken));
        }
        private async Task <DialogTurnResult> MessageReceivedProjectCost(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            if (Convert.ToBoolean(stepContext.Values["determineValue"]))
            {
                var result = (bool)stepContext.Result;
                if (result)
                {
                    await stepContext.Context.SendActivityAsync("Enter your project cost here:");

                    return(await stepContext.PromptAsync($"{nameof(ProjectCostDialog)}.number",
                                                         new PromptOptions
                    {
                        Prompt = MessageFactory.Text("Please provide purchase price of the land.")
                    }, cancellationToken));
                }
                else
                {
                    return(await stepContext.ContinueDialogAsync());
                }
            }
            else
            {
                var message = (decimal)stepContext.Result;
                if (!string.IsNullOrEmpty(message.ToString()))
                {
                    double projectCost = 0.0;
                    double.TryParse(message.ToString(), out projectCost);
                    //emiModel.ProjectCosts = projectCost;
                    this.projectCost = projectCost;
                }
                else
                {
                    this.projectCost = 0;
                }
                return(await stepContext.EndDialogAsync(this.projectCost.ToString()));
            }
        }
Exemple #28
0
        public async Task <DialogTurnResult> GetNewEventTime(WaterfallStepContext sc, CancellationToken cancellationToken = default(CancellationToken))
        {
            try
            {
                var state = await Accessor.GetAsync(sc.Context);

                if (state.NewStartDate.Any() || state.NewStartTime.Any() || state.MoveTimeSpan != 0)
                {
                    return(await sc.ContinueDialogAsync());
                }

                return(await sc.PromptAsync(Actions.TimePrompt, new PromptOptions
                {
                    Prompt = ResponseManager.GetResponse(UpdateEventResponses.NoNewTime),
                    RetryPrompt = ResponseManager.GetResponse(UpdateEventResponses.NoNewTime_Retry)
                }, cancellationToken));
            }
            catch (Exception ex)
            {
                await HandleDialogExceptions(sc, ex);

                return(new DialogTurnResult(DialogTurnStatus.Cancelled, CommonUtil.DialogTurnResultCancelAllDialogs));
            }
        }
Exemple #29
0
        private async Task <DialogTurnResult> MessageReceivedDuration(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            if (Convert.ToBoolean(stepContext.Values["projectCost"]))
            {
                var message = (decimal)stepContext.Result;
                if (!string.IsNullOrEmpty(message.ToString()))
                {
                    double.TryParse(message.ToString(), out projectCost);
                    return(await stepContext.PromptAsync($"{nameof(MiscellaneousDialog)}.number",
                                                         new PromptOptions
                    {
                        Prompt = MessageFactory.Text("Please provide the amount invested by you (Own Resources):")
                    }, cancellationToken));
                }
                else
                {
                    this.projectCost = 0;
                    return(await stepContext.ContinueDialogAsync());
                }
            }
            else
            {
                var message = (decimal)stepContext.Result;
                int.TryParse(message.ToString(), out numberOfYears);

                var emi = Calculations.CalculateEMI(finAmount, numberOfYears * 12);
                this.EMI = emi;
                await stepContext.Context.SendActivityAsync($"Your monthly installment is: {emi} €");

                return(await stepContext.PromptAsync($"{nameof(MiscellaneousDialog)}.confirm",
                                                     new PromptOptions
                {
                    Prompt = MessageFactory.Text("Do you wish to re-evaluate your installments?")
                }, cancellationToken));
            }
        }
        /// <summary>
        /// Resolve SHIPPING.
        /// </summary>
        private async Task <DialogTurnResult> ResolveShipping(
            WaterfallStepContext stepContext,
            CancellationToken cancellationToken)
        {
            CustomerState customerState =
                await _customerService.GetCustomerStateById(stepContext.Context.Activity.From.Id);

            var context = stepContext.Context;
            var choice  = stepContext.Result as FoundChoice;

            if (customerState.IsShippingAdressMatch == null)
            {
                bool isShippingAdressSet = choice.Value.Contains(Messages.Yes) ? true : false;
                customerState.IsShippingAdressMatch = isShippingAdressSet;
                await _customerService.UpdateCustomerState(customerState);
            }

            if (customerState.IsShippingAdressMatch == true)
            {
                stepContext.ActiveDialog.State["stepIndex"] = DialogIndex["ConfirmCustomerInfo"];
            }

            return(await stepContext.ContinueDialogAsync());
        }