Ejemplo n.º 1
0
        public async Task GetApprovalOperations(ITurnContext <IMessageActivity> turnContext, PwdResetConversationStates conversationState, UserPasswordInfo userState, CancellationToken cancellationToken)
        {
            var approveText = turnContext.Activity.Text.Trim().ToLower();
            //TODO: LUIS e input texti gönder....
            var luisResult = await _luisRecognizer.RecognizeAsync(turnContext, cancellationToken);

            // onaylıyorum, tamam gibi intentler luise eklenebilir.
            if (luisResult.Intents.OrderBy(i => i.Value.Score).FirstOrDefault().Key == "Utilities_Confirm")
            {
                await turnContext.SendActivityAsync($"Sayın {userState.UserName}, {userState.Application} uygulaması için şifre reset talebiniz alınmıştır.");

                conversationState.CurrentState = PdwResetStates.Completed;
                Operations.ExcelCreator.Create(userState);
            }
            else if (luisResult.Intents.OrderBy(i => i.Value.Score).FirstOrDefault().Key == "Utilities_Cancel")
            {
                await turnContext.SendActivityAsync($"{userState.UserName} talebiniz iptal edilmiştir.");

                conversationState.CurrentState = PdwResetStates.Completed;
            }
            else
            {
                await turnContext.SendActivityAsync($"Sizi anlayamadım");
            }
        }
Ejemplo n.º 2
0
        private async Task <DialogTurnResult> LuisStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            try
            {
                if (!_luisRecognizer.IsConfigured)
                {
                    var msg = $"LUIS is not configured";
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text(msg), cancellationToken);

                    // LUIS is not configured
                    // WaterfallStep always finishes with the end of the Waterfall or with another dialog, here it is the end.
                    return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));
                }

                // Call LUIS and get the intent. (Note the TurnContext has the response to the prompt.)
                var luisResult = await _luisRecognizer.RecognizeAsync(stepContext.Context, cancellationToken);

                var intent = luisResult.GetTopScoringIntent().intent;

                switch (intent)
                {
                case "Greeting":
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text("Top scoring intent: " + intent), cancellationToken);

                    // WaterfallStep always finishes with the end of the Waterfall or with another dialog
                    // Here pushing a new dialog (MyFirstDialog) into the dialog stack
                    // Run the APICDialog giving it whatever details we have, it will fill out the remainder.
                    return(await stepContext.BeginDialogAsync(nameof(MyFirstDialog), cancellationToken));

                case "Acknowledge":
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text("Top scoring intent: " + intent), cancellationToken);

                    // WaterfallStep always finishes with the end of the Waterfall or with another dialog, here it is the end.
                    return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));

                case "None":
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text("Top scoring intent: " + intent), cancellationToken);

                    // WaterfallStep always finishes with the end of the Waterfall or with another dialog, here it is the end.
                    return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));

                default:
                    break;
                }
                await stepContext.Context.SendActivityAsync(MessageFactory.Text(intent), cancellationToken);

                // WaterfallStep always finishes with the end of the Waterfall or with another dialog, here it is the end.
                return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                // LUIS is not responding correctly
                // WaterfallStep always finishes with the end of the Waterfall or with another dialog, here it is the end.
                return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));
            }
        }
Ejemplo n.º 3
0
        private async Task <DialogTurnResult> SaveInitialIntent(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var options = new QnAMakerOptions {
                Top = 1
            };
            var response = await _qnAMakerRecognizer.GetAnswersAsync(stepContext.Context, options);

            if (response != null && response.Length > 0)
            {
                var suggestedReply = MessageFactory.Text(response[0].Answer);
                suggestedReply.SuggestedActions         = new SuggestedActions();
                suggestedReply.SuggestedActions.Actions = new List <CardAction>();
                for (int i = 0; i < response[0].Context.Prompts.Length; i++)
                {
                    var promptText = response[0].Context.Prompts[i].DisplayText;
                    suggestedReply.SuggestedActions.Actions.Add(new CardAction()
                    {
                        Title = promptText, Type = ActionTypes.ImBack, Value = promptText
                    });
                }
                stepContext.ActiveDialog.State["stepIndex"] = (int)stepContext.ActiveDialog.State["stepIndex"] - 1;
                await stepContext.Context.SendActivityAsync(suggestedReply, cancellationToken);

                return(await InitialStep(stepContext, cancellationToken));
            }
            else
            {
                var luisResult = await _luisRecognizer.RecognizeAsync(stepContext.Context, cancellationToken);

                if (luisResult.Intents.ContainsKey("LogTicketIntent"))
                {
                    return(await stepContext.BeginDialogAsync(nameof(CreateTicketDialog), stepContext.Options, cancellationToken));
                }
                if (luisResult.Intents.ContainsKey("EnquireTicket"))
                {
                    return(await stepContext.BeginDialogAsync(nameof(EnquireTicketDialog), stepContext.Options, cancellationToken));
                }
            }


            GreetTheCustomer = RepeatMessage;
            stepContext.ActiveDialog.State["stepIndex"] = (int)stepContext.ActiveDialog.State["stepIndex"] - 1;
            return(await InitialStep(stepContext, cancellationToken));
        }