Exemple #1
0
        private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var profile = await authHelper.GetAuthenticatedProfileAsync(stepContext.Context, cancellationToken);

            if (profile == null)
            {
                return(await stepContext.BeginDialogAsync(nameof(SignInDialog), cancellationToken : cancellationToken));
            }

            // Call LUIS and gather any potential booking details. (Note the TurnContext has the response to the prompt.)
            var recognizerResult = await LuisHelper.ExecuteLuisQuery(TelemetryClient, configuration, this.logger, stepContext.Context, cancellationToken);

            // In this sample we only have a single Intent we are concerned with. However, typically a scenario
            // will have multiple different Intents each corresponding to starting a different child Dialog.

            var(intent, score) = recognizerResult.GetTopScoringIntent();
            if (intent == "getvsoitem")
            {
                // Run the BookingDialog giving it whatever details we have from the LUIS call, it will fill out the remainder.
                return(await stepContext.BeginDialogAsync(nameof(GetWorkItemDialog), recognizerResult, cancellationToken));
            }
            else if (intent == "createvsoitem")
            {
                return(await stepContext.BeginDialogAsync(nameof(CreateWorkItemDialog), recognizerResult, cancellationToken));
            }

            return(await stepContext.EndDialogAsync(null, cancellationToken));
        }
        private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            string     result = stepContext.Context.Activity.Text;
            MainDetail detail = new MainDetail();

            //Luis 연동 체크
            if (string.IsNullOrEmpty(Configuration["LuisAppId"]) || string.IsNullOrEmpty(Configuration["LuisAPIKey"]) || string.IsNullOrEmpty(Configuration["LuisAPIHostName"]))
            {
                detail = null;
            }
            else
            {
                detail = await luisHelper.ExecuteLuisQuery(Logger, stepContext.Context, cancellationToken);
            }
            //대화 의도에 따른 각각의 대화흐름 시작
            switch (detail.intent)
            {
            case "버스":
                return(await stepContext.BeginDialogAsync(nameof(BusInformationDialog), (BusDetails)detail, cancellationToken));

            case "미세먼지":
                return(await stepContext.BeginDialogAsync(nameof(WeatherInformationDialog), (DustDetails)detail, cancellationToken));

            case "직업":
                return(await stepContext.BeginDialogAsync(nameof(WorkDialog), (WorkDetails)detail, cancellationToken));

            case "학식메뉴":
                await stepContext.Context.SendActivityAsync(MessageFactory.Text("https://www.hansung.ac.kr/portlet-repositories/fckeditor/images/7qHyuRAiKcc=/1557707052583.png"));

                return(await stepContext.EndDialogAsync(null, cancellationToken));

            case "트랙정보":
                return(await stepContext.BeginDialogAsync(nameof(TrackInfoDialog), (TrackInfoDetails)detail, cancellationToken));

            case "전화번호":
                return(await stepContext.BeginDialogAsync(nameof(PhoneAdressDialog), (PhoneDetails)detail, cancellationToken));

            case "트랙정보카드":
                return(await stepContext.BeginDialogAsync(nameof(TrackInfoCardDialog), (TrackInfoCardDetail)detail, cancellationToken));

            case "교수님":
                return(await stepContext.BeginDialogAsync(nameof(ProfessorsDialog), (ProfessorsDetail)detail, cancellationToken));

            case "맛집":
                return(await stepContext.BeginDialogAsync(nameof(MatjeepchoochunDialog), (MatjeepchoochunDetail)detail, cancellationToken));

            case "공지사항":
                return(await stepContext.BeginDialogAsync(nameof(NoticeDialog), (NoticeDetail)detail, cancellationToken));

            case "장학제도":
                await stepContext.Context.SendActivityAsync(MessageFactory.Text("https://www.hansung.ac.kr/web/www/life_02_01_t1"));

                return(await stepContext.EndDialogAsync(null, cancellationToken));

            default:
                await stepContext.Context.SendActivityAsync(MessageFactory.Text("잘 이해하지 못했어요. 다시 질문해주세요"));

                return(await stepContext.EndDialogAsync(null, cancellationToken));
            }
        }
Exemple #3
0
        private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            // Call LUIS and gather any potential booking details. (Note the TurnContext has the response to the prompt.)
            var luisResult = stepContext.Result != null
                    ?
                             await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken)
                    :
                             new RecognizerResult();

            detectedIntent = luisResult.GetTopScoringIntent().intent;
            if (detectedIntent == "Open_MS_Facilities_Ticket")
            {
                MSFacilitiesTicket ticketDetails = new MSFacilitiesTicket();
                ticketDetails.IssueName = luisResult.Entities["IssueName"]?.FirstOrDefault()?["text"]?.ToString();
                ticketDetails.Location  = luisResult.Entities["Meeting_Room"]?.First()?.ToString();
                return(await stepContext.BeginDialogAsync(nameof(MSFacilitiesDialog), ticketDetails, cancellationToken));
            }
            if (detectedIntent == "Book_Doctor_Appointment")
            {
                DoctorAppointment doctorAppointment = new DoctorAppointment();
                doctorAppointment.symptom = luisResult.Entities["Symptom"]?.FirstOrDefault()?.FirstOrDefault()?.ToString();
                //doctorAppointment.timeslot = luisResult.Entities[""]?.First()?.ToString();
                return(await stepContext.BeginDialogAsync(nameof(DoctorDialog), doctorAppointment, cancellationToken));
            }
            // In this sample we only have a single Intent we are concerned with. However, typically a scenario
            // will have multiple different Intents each corresponding to starting a different child Dialog.

            // Run the BookingDialog giving it whatever details we have from the LUIS call, it will fill out the remainder.
            return(await stepContext.BeginDialogAsync(nameof(BookingDialog), luisResult, cancellationToken));
        }
Exemple #4
0
        private async Task <DialogTurnResult> InventoryTypeAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var userInput = stepContext.Result != null
                ?
                            await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken)
                :
                            new UserRequest();

            if (userInput.isSKUNumber == true)
            {
                return(await stepContext.BeginDialogAsync(nameof(SKUDialog), userInput, cancellationToken));
            }
            else if (userInput.ispurchaseOrderNumber == true)
            {
                return(await stepContext.BeginDialogAsync(nameof(poNumberDialog), userInput, cancellationToken));
            }
            else if (userInput.cancel == true)
            {
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Thank you for using the GLD Bot") }, cancellationToken));
            }
            else if (userInput.restart == true)
            {
                return(await stepContext.BeginDialogAsync(nameof(UserDialog), userInput, cancellationToken));
            }
            else if (userInput.isjob == true)
            {
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Please visit our jobs website to learn more : https://www.jobs-ups.com") }, cancellationToken));
            }
            else
            {
                return(null);
            }
        }
        private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            // Call LUIS and gather any potential booking details. (Note the TurnContext has the response to the prompt.)
            var projectData = stepContext.Result != null
                    ?
                              await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken)
                    :
                              new ProjectData();

            var temp = projectData.intentIdenified;

            var nameofstatus = "";

            if (temp == "Get_Status")
            {
                nameofstatus = nameof(Getstatus);
            }
            else if (temp == "ReportStatus")
            {
                nameofstatus = nameof(SubmitStatusReqInput);
            }
            else if (temp == "ReportStatusWithInput")
            {
                nameofstatus = nameof(SubmitStatusNLP);
            }

            return(await stepContext.BeginDialogAsync(nameofstatus, projectData, cancellationToken));
        }
        private async Task <DialogTurnResult> ProcessTrackingNumberAsync(WaterfallStepContext stepContext,
                                                                         CancellationToken cancellationToken)
        {
            var userinput = stepContext.Result != null
            ?
                            await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken)
            :
                            new UserRequest();

            var userInput = new UserRequest();

            if (userinput.restart == true)
            {
                return(await stepContext.BeginDialogAsync(nameof(UserDialog), userinput, cancellationToken));
            }
            else if (userinput.cancel == true)
            {
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Thank you for using the GLD Bot") }, cancellationToken));
            }
            else if (stepContext.Result is int || stepContext.Result is string)
            {
                userInput.UPSTrackingNumber = stepContext.Result.ToString();
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text(" Status of Order# " + userInput.UPSTrackingNumber + ":" + "\nShipping Address:\n12380 Morris Road\nAlpharetta GA 30004\nStatus: Delivered by end of day \nIf you would like to check on the status of another order please enter in the number? If not say \"no\"") }, cancellationToken));
            }
            else
            {
                return(await stepContext.BeginDialogAsync(nameof(upsOrderNumberDialog), userInput, cancellationToken));
            }
        }
        private async Task <DialogTurnResult> ProcessInventoryNumberAsync(WaterfallStepContext stepContext,
                                                                          CancellationToken cancellationToken)
        {
            var userinput = stepContext.Result != null
                ?
                            await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken)
                :
                            new UserRequest();

            var userInput = new UserRequest();

            if (userinput.restart == true)
            {
                return(await stepContext.BeginDialogAsync(nameof(UserDialog), userinput, cancellationToken));
            }
            else if (userinput.cancel == true)
            {
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Thank you for using the GLD Bot") }, cancellationToken));
            }
            else if (stepContext.Result is int || stepContext.Result is string)
            {
                userInput.SKUNumber = stepContext.Result.ToString();
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("  Invetory status of Sku# " + userInput.SKUNumber + ":" + "\nItem 1: 65 units\nLocation: Warehouse 1\nIf you would like to check inventory on another Sku# enter in the number? If not say \"no\"") }, cancellationToken));
            }
            else
            {
                return(await stepContext.BeginDialogAsync(nameof(SKUDialog), userInput, cancellationToken));
            }
        }
Exemple #8
0
        private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var luisResult = await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken);

            switch (luisResult.Intent)
            {
            case "Book_flight":
                //We need to return flight details
                // Run the BookingDialog giving it whatever details we have from the LUIS call, it will fill out the remainder.
                return(await stepContext.BeginDialogAsync(nameof(BookingDialog), luisResult, cancellationToken));

            //return await stepContext.BeginDialogAsync(nameof(NewerDialog), luisResult, cancellationToken);
            case "AuthDialog_Intent":
                //Type something like "Oauth card" or "Auth Dialog intent"

                //Run the AuthBot Dialog
                return(await stepContext.BeginDialogAsync(nameof(AuthDialog), luisResult, cancellationToken));

            case "APIDialog_Intent":
                //Type something like "Salesforce query" or "I need to check my quota" "I need to check my sales targets"

                //Run the AuthBot Dialog
                return(await stepContext.BeginDialogAsync(nameof(APIDialog), luisResult, cancellationToken));

            case "None":
            case "Cancel":
            default:
                //Default to QnA
                await QnAHelper.ExecuteQnAQuery(Configuration, Logger, stepContext.Context, cancellationToken);

                return(await stepContext.BeginDialogAsync(nameof(MainDialog), null));
            }
        }
        //QnAMaker BotQNA;
        //private async Task<string> AccessQnAMaker(ITurnContext turnContext, CancellationToken cancellationToken, BotIntent intent)
        //{
        //    try
        //    {
        //        BotQNA = new QnAMaker(new QnAMakerEndpoint
        //        {
        //            EndpointKey = intent.Key,
        //            Host = intent.HostName,
        //            KnowledgeBaseId = intent.Id
        //        });
        //        var results = await BotQNA.GetAnswersAsync(turnContext);
        //        if (results.Any())
        //        {
        //            return JsonConvert.SerializeObject(new IntentWithScore { Result = results.First().Answer, Score = results.First().Score.ToString() });
        //            //await turnContext.SendActivityAsync(MessageFactory.Text("QnA Maker Returned: " + results.First().Answer), cancellationToken);
        //        }
        //        else
        //        {
        //            return JsonConvert.SerializeObject(new IntentWithScore { Result = "Sorry, could not find an answer in the Q and A system.", Score = "0.00" });
        //            //await turnContext.SendActivityAsync(MessageFactory.Text("Sorry, could not find an answer in the Q and A system."), cancellationToken);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        return JsonConvert.SerializeObject(new IntentWithScore { Result = ex.Message, Score = "-1.00" });
        //        //var x = ex.Message;
        //    }
        //}
        private async Task <string> AccessLUIS(ITurnContext turnContext, CancellationToken cancellationToken, BotIntent intent)
        {
            var luisIntent = await LuisHelper.ExecuteLuisQuery(intent, null, turnContext, cancellationToken);

            return(JsonConvert.SerializeObject(luisIntent));
            //await turnContext.SendActivityAsync(MessageFactory.Text($"Luis Intent: {luisIntent.Result} || Score: {luisIntent.Score}"), cancellationToken);
            //LogIntent(luisIntent);
        }
        private async Task <DialogTurnResult> MileageStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            // Call LUIS and gather any potential booking details. (Note the TurnContext has the response to the prompt.)
            var distanceInfo = stepContext.Result != null
                ? await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken)
                : new DistanceInfo();

            // In this sample we only have a single Intent we are concerned with. However, typically a scenario
            // will have multiple different Intents each corresponding to starting a different child Dialog.

            // Run the BookingDialog giving it whatever details we have from the LUIS call, it will fill out the remainder.


            return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text(distanceInfo.Distance.ToString()) }, cancellationToken));
        }
Exemple #11
0
        private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            // Call LUIS and gather any potential booking details. (Note the TurnContext has the response to the prompt.)
            var bookingDetails = stepContext.Result != null
                    ?
                                 await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken)
                    :
                                 new BookingDetails();

            // In this sample we only have a single Intent we are concerned with. However, typically a scenario
            // will have multiple different Intents each corresponding to starting a different child Dialog.

            // Run the BookingDialog giving it whatever details we have from the LUIS call, it will fill out the remainder.
            return(await stepContext.BeginDialogAsync(nameof(BookingDialog), bookingDetails, cancellationToken));
        }
        //查询Luis,返回结果
        private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            //await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("示例:\"北京今天天气如何\"") }, cancellationToken);
            Console.WriteLine("******************************");
            Console.WriteLine(stepContext.Context);
            var QueryDetails = await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken);

            /*
             * var QueryDetails = stepContext.Result != null
             *      ?
             *  await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken)
             *      :
             *  new QueryDetails();
             */
            return(await stepContext.BeginDialogAsync(nameof(DetailQueryDialog), QueryDetails, cancellationToken));
        }
        private async Task<DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            // Chama o LUIS e reúne todas as possíveis intenções. (Observe que o TurnContext tem a resposta para o prompt).
            var LUISResponse = stepContext.Result != null
                    ? await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken)
                    : new LUISResponse();

            if (LUISResponse.Intencao == Intencao.conversa_saudacao)
                return await stepContext.BeginDialogAsync(nameof(SaudacaoDialog), cancellationToken);
            else if (LUISResponse.Intencao == Intencao.conversa_sobre)
                return await stepContext.BeginDialogAsync(nameof(SobreDialog), cancellationToken);
            else if (LUISResponse.Intencao == Intencao.moeda_cotacao)
                return await stepContext.BeginDialogAsync(nameof(CotacaoDialog), LUISResponse, cancellationToken);
            else if (LUISResponse.Intencao == Intencao.moeda_listagem)
                return await stepContext.BeginDialogAsync(nameof(CotacaoListagemDialog), LUISResponse, cancellationToken);
            
            return await stepContext.BeginDialogAsync(nameof(NaoReconhecidoDialog), cancellationToken);
        }
Exemple #14
0
        private async Task <DialogTurnResult> FinalStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            if (!(stepContext.Context.Activity.Text.Trim().ToUpper().Contains("KB0")))
            {
                if (stepContext.Result != null)
                {
                    if (stepContext.Result.Equals(true))
                    {
                        // var bookingDetails = (BookingDetails)stepContext.Options;

                        //return await stepContext.EndDialogAsync(bookingDetails, cancellationToken);
                        await stepContext.Context.SendActivityAsync(
                            MessageFactory.Text("Please enter any other query."), cancellationToken);

                        // return await stepContext.EndDialogAsync(null, cancellationToken);
                        return(await stepContext.NextAsync(null, cancellationToken));
                    }

                    else if (stepContext.Result.Equals(false))
                    {
                        var bookingDetails = stepContext.Result != null
                       ?
                                             await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, /* Recognizerresult,*/ cancellationToken)
                       :
                                             new BookingDetails();

                        //await stepContext.Context.SendActivityAsync(
                        //  MessageFactory.Text("Incident Created..!"), cancellationToken);
                        //return await stepContext.EndDialogAsync(null, cancellationToken);
                        return(await stepContext.BeginDialogAsync(nameof(BookingDialog), bookingDetails, cancellationToken));
                    }
                    else
                    {
                        return(await stepContext.EndDialogAsync(null, cancellationToken));
                    }
                }
                else
                {
                    return(await stepContext.EndDialogAsync(null, cancellationToken));
                }
            }
            return(await stepContext.EndDialogAsync(null, cancellationToken));
        }
        private async Task <DialogTurnResult> ChooseStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var userInput = stepContext.Result != null
                ?
                            await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken)
                :
                            new UserRequest();

            if (userInput.isOrder() == true)
            {
                return(await stepContext.BeginDialogAsync(nameof(OrderDialog), userInput, cancellationToken));
            }
            else if (userInput.isInventory())
            {
                return(await stepContext.BeginDialogAsync(nameof(InventoryDialog), userInput, cancellationToken));
            }
            else if (userInput.cancel == true)
            {
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Thank you for using the GLDBot") }, cancellationToken));
            }
            else if (userInput.is1z == true)
            {
                var input = stepContext.Result.ToString();
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions
                                                     { Prompt = MessageFactory.Text(" Status of Order# " + input + ":" + "\nShipping Address:\n12380 Morris Road\nAlpharetta GA 30004\nStatus: Delivered by end of day") }, cancellationToken));
            }
            else if (userInput.restart == true)
            {
                return(await stepContext.BeginDialogAsync(nameof(UserDialog), userInput, cancellationToken));
            }
            else if (userInput.isjob == true)
            {
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Please visit our jobs website to learn more : https://www.jobs-ups.com") }, cancellationToken));
            }
            else
            {
                return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("I'm sorry something went wrong") }, cancellationToken));
            }
        }
        private async Task <DialogTurnResult> LUISStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken);


            var intentValue = (string)stepContext.Result;


            switch (AzureDetails.Intent)
            {
            case "GetAllResourceGroupsIntent":
                AzureResourceManagerREST.getAllResourceGroupDetails().GetAwaiter().GetResult();
                await stepContext.Context.SendActivityAsync(MessageFactory.Text("Here is the details of all your resource groups:"));

                await stepContext.Context.SendActivityAsync(MessageFactory.Text(AzureDetails.Response));

                break;

            case "Cancel":
                AzureDetails.AccessToken    = null;
                AzureDetails.SubscriptionID = null;
                AzureDetails.TenantID       = null;
                AzureDetails.ClientID       = null;
                AzureDetails.ClientSecret   = null;
                await stepContext.Context.SendActivityAsync(MessageFactory.Text("You are now successfully disconnected from Azure services. Your Azure details has been cleared."));

                break;

            case "CreateResourceGroupIntent":
                return(await stepContext.BeginDialogAsync(nameof(CreateResourceGroupDialog), new User(), cancellationToken));

            default:
                await stepContext.Context.SendActivityAsync(MessageFactory.Text("Kindly rephrase your query."));

                break;
            }

            return(await stepContext.NextAsync(null, cancellationToken));
        }
Exemple #17
0
        private async Task <DialogTurnResult> FinalStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            Localization.Locale = stepContext.Context.Activity.Locale;
            stepContext.Context.Activity.Locale = Localization.Locale;
            var loan = (Loan)stepContext.Options;

            loan.Assurance = (string)stepContext.Result;

            if (!Enum.IsDefined(typeof(Insurance.Type), loan.Assurance))
            {
                var res = await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken, false);

                loan.Assurance = res.Assurance;
                if (loan.Assurance == null)
                {
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text(Resources.BotLanguage.LoanNotUnderstood), cancellationToken);

                    return(await stepContext.MoveAsync(stepContext, -1, loan.Duration, cancellationToken));
                }
            }

            return(await stepContext.EndDialogAsync(loan, cancellationToken));
        }
Exemple #18
0
        private async Task <DialogTurnResult> IntroStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(Configuration["LuisAppId"]) || string.IsNullOrEmpty(Configuration["LuisAPIKey"]) || string.IsNullOrEmpty(Configuration["LuisAPIHostName"]))
            {
                await stepContext.Context.SendActivityAsync(
                    MessageFactory.Text("NOTE: LUIS is not configured. To enable all capabilities, add 'LuisAppId', 'LuisAPIKey' and 'LuisAPIHostName' to the appsettings.json file."), cancellationToken);


                return(await stepContext.NextAsync(null, cancellationToken));
            }
            else
            {
                var bookingDetails = stepContext.Result == null
                  ?
                                     await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, /*Recognizerresult,*/ cancellationToken)
                  :
                                     new BookingDetails();

                //await stepContext.Context.SendActivityAsync(
                //  MessageFactory.Text("Incident Created..!"), cancellationToken);
                //return await stepContext.EndDialogAsync(null, cancellationToken);
                //  return await stepContext.BeginDialogAsync(nameof(BookingDialog), bookingDetails, cancellationToken);



                //   return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("What can I help you with today?\nSay something like \"Book a flight from Paris to Berlin on March 22, 2020\"") }, cancellationToken);


                if (bookingDetails.Create_incident.Equals("true"))
                {
                    //     var bookingDetails = stepContext.Result != null
                    //    ?
                    //await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken)
                    //    :
                    //new BookingDetails();

                    //await stepContext.Context.SendActivityAsync(
                    //  MessageFactory.Text("Incident Created..!"), cancellationToken);
                    //return await stepContext.EndDialogAsync(null, cancellationToken);

                    return(await stepContext.BeginDialogAsync(nameof(BookingDialog), bookingDetails, cancellationToken));
                }
                else if (bookingDetails.None.Equals("true"))
                {
                    bookingDetails.None = "false";
                    CoreBot.models.apiresult incidentno = null;
                    SNOWLogger nOWLogger = new SNOWLogger(Configuration);
                    string     concat    = "";
                    String     userinput = stepContext.Context.Activity.Text.Trim();
                    if (!(userinput.ToUpper().Contains("KB0")))
                    {
                        incidentno = nOWLogger.KBSearchServiceNow("GOTO123TEXTQUERY321=" + stepContext.Context.Activity.Text.Trim());

                        if (incidentno.result != null)
                        {
                            if (incidentno.result.Count != 0)
                            {
                                for (int i = 0; i < incidentno.result.Count; i++)
                                {
                                    concat += "\n" + incidentno.result[i].number + " : " + incidentno.result[i].short_description + "\n";
                                }


                                await stepContext.Context.SendActivityAsync(
                                    MessageFactory.Text(concat), cancellationToken);
                            }
                            else


                            {
                                //                        return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text(" Sorry no details found for " + stepContext.Context.Activity.Text) }, cancellationToken);

                                await stepContext.Context.SendActivityAsync(
                                    MessageFactory.Text(" Sorry no details found for: " + stepContext.Context.Activity.Text.Trim()), cancellationToken);

                                return(await stepContext.EndDialogAsync(null, cancellationToken));
                            }
                        }
                        else
                        {
                            await stepContext.Context.SendActivityAsync(
                                MessageFactory.Text(" Sorry no details found"), cancellationToken);

                            return(await stepContext.EndDialogAsync(null, cancellationToken));
                        }
                    }



                    // string concat = string.Join(" ", myList.ToArray());

                    //  return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text(incidentno.SelectToken("result[" + i + "].number").ToString() + incidentno.SelectToken("result[" + i + "].short_description").ToString()) }, cancellationToken);
                    // return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text(concat) }, cancellationToken);


                    stepContext.Context.TurnState.Add("incID", bookingDetails);

                    return(await stepContext.NextAsync(bookingDetails, cancellationToken));
                }

                else
                {
                    stepContext.Context.TurnState.Add("incID", bookingDetails);

                    return(await stepContext.NextAsync(bookingDetails, cancellationToken));
                }
            }
        }
Exemple #19
0
        private async Task <DialogTurnResult> DbInstanceStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var entitiDetails = (EntitiDetails)stepContext.Options;

            switch (entitiDetails.Intent)
            {
            case "Acronym":
                return(await stepContext.NextAsync(entitiDetails.Acronym, cancellationToken));

            case "Build_Deployment":

                if (entitiDetails.Project == "DB-Deployment")
                {
                    if (entitiDetails.Buildwar == null)
                    {
                        entitiDetails.Buildwar = (string)stepContext.Result;
                    }
                    entitiDetails.DbInstance = entitiDetails.Environment;
                    return(await stepContext.NextAsync(entitiDetails, cancellationToken));

                    //return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Please enter DB Instance name") }, cancellationToken);
                }
                else if (entitiDetails.Project == "RMI-Deployment")
                {
                    entitiDetails.DbInstance = "VPMTST1";
                    return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Please enter the repository for deployment") }, cancellationToken));
                }
                else
                {
                    if (entitiDetails.Buildwar == null)
                    {
                        entitiDetails.Buildwar = (string)stepContext.Result;
                    }
                    return(await stepContext.NextAsync(entitiDetails, cancellationToken));
                }

            case "Trigger_Service":
                if (entitiDetails.Portfolio == "PCA" || entitiDetails.Portfolio == "CCV")
                {
                    if (entitiDetails.Tag == null && entitiDetails.Project.ToUpper() != "PRODUCTIONDAILYHEALTHCHECK")
                    {
                        entitiDetails.Tag = ((FoundChoice)stepContext.Result).Value.ToString();
                    }
                    if (entitiDetails.Tag == "DerivationLogic")
                    {
                        return(await stepContext.PromptAsync(nameof(ChoicePrompt),
                                                             new PromptOptions
                        {
                            Prompt = MessageFactory.Text("Please select the test"),
                            Choices = ChoiceFactory.ToChoices(new List <string> {
                                "DMUVDerivationForSingleSource", "DMUVDerivationForMultipleSources", "SubsetDerivationForSingleSource", "SubsetDerivationForMultipleSources"
                            }),
                            RetryPrompt = MessageFactory.Text("Sorry, I'm still learning. Please provide the valid option or below mentioned Sequence Number."),
                        }, cancellationToken));
                    }
                    else if (entitiDetails.Tag == "DMUVFunctionality")
                    {
                        return(await stepContext.PromptAsync(nameof(ChoicePrompt),
                                                             new PromptOptions
                        {
                            Prompt = MessageFactory.Text("Please select the test"),
                            Choices = ChoiceFactory.ToChoices(new List <string> {
                                "DateBand", "NoChange", "Subset", "SuperPayerDelta", "IndividualDelta", "POS", "CMUS", "MUE/NonMUE", "Undo", "NonMUEStateMedicaid", "SelectAllBulkActions"
                            }),
                            RetryPrompt = MessageFactory.Text("Sorry, I'm still learning. Please provide the valid option or below mentioned Sequence Number."),
                        }, cancellationToken));
                    }
                    else if (entitiDetails.Tag == "Custom")
                    {
                        return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Please enter tag for customized execution.\n\n" + "For Single Ex: @Tag , For Multiple Ex: @Tag1,@Tag2") }, cancellationToken));
                    }
                    else if (entitiDetails.Tag == "AutoDerivation")
                    {
                        var entitiDetails1 = stepContext.Result != null
                                ?
                                             await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken)
                                 :
                                             new EntitiDetails();

                        var eDetails = (EntitiDetails)entitiDetails1;
                        entitiDetails.TravelDate = eDetails.TravelDate;
                    }

                    return(await stepContext.NextAsync(entitiDetails, cancellationToken));
                }
                else
                {
                    if (entitiDetails.Client == null && (entitiDetails.Project.ToUpper() != "PRODUCTIONDAILYHEALTHCHECK"))
                    {
                        if (/*entitiDetails.Project.ToUpper() != "ANNOCODER"&&*/ entitiDetails.Environment != "PROD")
                        {
                            entitiDetails.Client = ((FoundChoice)stepContext.Result).Value.ToString();
                        }
                        return(await stepContext.PromptAsync(nameof(ChoicePrompt),
                                                             new PromptOptions
                        {
                            Prompt = MessageFactory.Text("Please select the test"),
                            Choices = ChoiceFactory.ToChoices((entitiDetails.Project.ToUpper() == "ANNOCODER") ? new List <string> {
                                "Regression"
                            } : new List <string> {
                                "Smoke", "Regression"
                            }),
                            RetryPrompt = MessageFactory.Text("Sorry, I'm still learning. Please provide the valid option or below mentioned Sequence Number."),
                        }, cancellationToken));
                    }
                    else
                    {
                        return(await stepContext.NextAsync(entitiDetails, cancellationToken));
                    }
                }

            default:
                return(await stepContext.NextAsync(entitiDetails, cancellationToken));
            }
        }
Exemple #20
0
        private async Task <DialogTurnResult> TagStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var entitiDetails = (EntitiDetails)stepContext.Options;

            if (!string.IsNullOrEmpty(entitiDetails.Project) && !string.IsNullOrEmpty(entitiDetails.Tag) && entitiDetails.Intent == "Trigger_Service")
            {
                return(await stepContext.NextAsync(entitiDetails, cancellationToken));
            }
            if (!string.IsNullOrEmpty(entitiDetails.Project) && !string.IsNullOrEmpty(entitiDetails.Buildwar) && entitiDetails.Intent == "Build_Deployment")
            {
                return(await stepContext.NextAsync(entitiDetails, cancellationToken));
            }
            else if (!string.IsNullOrEmpty(entitiDetails.Project) && string.IsNullOrEmpty(entitiDetails.Tag))
            {
                if (entitiDetails.Project.ToUpper() == "PRODUCTIONHEALTHCHECK")
                {
                    return(await stepContext.NextAsync(entitiDetails, cancellationToken));
                }
            }
            string[] projectsArray = { "CPW", "INTERPRETIVEUPDATE", "CPTICDLINKS", "CLIENTPROFILE", "MEDICAID", "CPQ", "IMPACTANALYSIS", "CLIENTINQUIRY", "CTA", "PRESENTATIONMANAGER", "PRODUCTIONHEALTHCHECK" };
            bool     isNum         = int.TryParse(stepContext.Result.ToString(), out int num);

            if (!isNum && !projectsArray.Any(x => x == stepContext.Result.ToString().ToUpper()) && entitiDetails.Intent == "Trigger_Service")
            {
                entitiDetails = stepContext.Result != null
                        ?
                                await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken)
                        :
                                new EntitiDetails();

                if (entitiDetails.Intent == "Acronym")
                {
                    entitiDetails.Returnmsg = "Return";
                    entitiDetails.Project   = null;
                    stepContext.ActiveDialog.State["stepIndex"] = (int)stepContext.ActiveDialog.State["stepIndex"] - 1;
                    return(await PortfolioStepAsync(stepContext, cancellationToken));
                }
            }
            var bookingDetails = entitiDetails;

            if (entitiDetails.Intent == "Acronym")
            {
                entitiDetails.Acronym = (string)stepContext.Result;
                return(await stepContext.NextAsync(entitiDetails.Acronym, cancellationToken));
            }
            else
            {
                if (entitiDetails.Project == null)
                {
                    entitiDetails.Project = (string)stepContext.Result;
                }
                //string[] projectsArray = { "CPW", "INTERPRETIVEUPDATE", "CPTICDLINKS", "CLIENTPROFILE", "MEDICAID", "CPQ", "IMPACTANALYSIS", "CLIENTINQUIRY", "CTA", "PRESENTATIONMANAGER" };
                if (!string.IsNullOrEmpty(bookingDetails.Project))
                {
                    if (entitiDetails.Project == "1")
                    {
                        entitiDetails.Project = "CPW";
                    }
                    else if (entitiDetails.Project == "2")
                    {
                        entitiDetails.Project = "InterpretiveUpdate";
                    }
                    else if (entitiDetails.Project == "3")
                    {
                        entitiDetails.Project = "CPTICDLinks";
                    }
                    else if (entitiDetails.Project == "4")
                    {
                        entitiDetails.Project = "ClientProfile";
                    }
                    else if (entitiDetails.Project == "5")
                    {
                        entitiDetails.Project = "Medicaid";
                    }
                    else if (entitiDetails.Project == "6")
                    {
                        entitiDetails.Project = "CPQ";
                    }
                    else if (entitiDetails.Project == "7")
                    {
                        entitiDetails.Project = "ImpactAnalysis";
                    }
                    else if (entitiDetails.Project == "8")
                    {
                        entitiDetails.Project = "ClientInquiry";
                    }
                    else if (entitiDetails.Project == "9")
                    {
                        entitiDetails.Project = "CTA";
                    }
                    else if (entitiDetails.Project == "10")
                    {
                        entitiDetails.Project = "PresentationManager";
                    }
                }
                if (projectsArray.Any(x => x == entitiDetails.Project.ToUpper()))
                {
                    if ((entitiDetails.Tag == null || entitiDetails.Buildwar == null) && entitiDetails.Project.ToUpper() != "PRODUCTIONHEALTHCHECK")
                    {
                        string msg = string.Empty;
                        if (entitiDetails.Returnmsg == "Return")
                        {
                            entitiDetails.Returnmsg = string.Empty;
                            msg = "Sorry, I'm still learning. Please provide the valid option or below mentioned Sequence Number.";
                        }
                        else
                        {
                            msg = "Type any of the Tests below";
                        }
                        if (entitiDetails.Intent == "Build_Deployment" && entitiDetails.Buildwar == null)
                        {
                            return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text("Please enter war to deploy the build") }, cancellationToken));
                        }

                        return(await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = MessageFactory.Text(Environment.NewLine + msg + Environment.NewLine + "1.Smoke" + Environment.NewLine + "2.Regression") }, cancellationToken));
                    }
                    else
                    {
                        return(await stepContext.ReplaceDialogAsync("WaterfallDialog", entitiDetails, cancellationToken));

                        //return await stepContext.NextAsync(bookingDetails, cancellationToken);
                    }
                }
                else
                {
                    entitiDetails.Returnmsg = "Return";
                    entitiDetails.Project   = null;
                    stepContext.ActiveDialog.State["stepIndex"] = (int)stepContext.ActiveDialog.State["stepIndex"] - 1;
                    return(await PortfolioStepAsync(stepContext, cancellationToken));
                }
            }
        }
Exemple #21
0
        private async Task <DialogTurnResult> ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            // Call LUIS and gather any potential action details. (Note the TurnContext has the response to the prompt.)
            var entitiDetails = stepContext.Result != null
                      ?
                                await LuisHelper.ExecuteLuisQuery(Configuration, Logger, stepContext.Context, cancellationToken)
                      :
                                new EntitiDetails();

            var  eDetails = (EntitiDetails)entitiDetails;
            bool isNum    = int.TryParse(stepContext.Result.ToString().Trim(), out int num);

            if (strRole.ToUpper().Equals("ADMIN"))
            {
                if (isNum)
                {
                    if (num > 5)
                    {
                        isContinue = true;
                        stepContext.ActiveDialog.State["stepIndex"] = (int)stepContext.ActiveDialog.State["stepIndex"] - 1;
                        return(await IntroStepAsync(stepContext, cancellationToken));
                    }
                    if (stepContext.Result.ToString() == "1")
                    {
                        EntitiDetails eDtls = new EntitiDetails();
                        eDtls.Score  = 0.9;
                        eDtls.Intent = "Trigger_Service";
                        eDetails     = eDtls;
                    }
                    else if (stepContext.Result.ToString() == "2")
                    {
                        EntitiDetails eDtls = new EntitiDetails();
                        eDtls.Score  = 0.9;
                        eDtls.Intent = "Build_Deployment";
                        eDetails     = eDtls;
                    }
                    else if (stepContext.Result.ToString() == "3")
                    {
                        EntitiDetails eDtls = new EntitiDetails();
                        eDtls.Score   = 0.9;
                        eDtls.Intent  = "Trigger_Service";
                        eDtls.Project = "ProductionHealthCheck";
                        eDetails      = eDtls;
                    }
                    else if (stepContext.Result.ToString() == "4")
                    {
                        EntitiDetails eDtls = new EntitiDetails();
                        eDtls.Score  = 0.9;
                        eDtls.Intent = "UsefulLinks";
                        eDetails     = eDtls;
                    }
                    else if (stepContext.Result.ToString() == "5")
                    {
                        EntitiDetails eDtls = new EntitiDetails();
                        eDtls.Score   = 0.9;
                        eDtls.Intent  = "Trigger_Service";
                        eDtls.Project = "ClientProfile";
                        eDtls.Tag     = "AutoDerivation";
                        eDetails      = eDtls;
                    }
                }
                //else if (eDetails.Intent == "Acronym" && (string.IsNullOrEmpty(eDetails.Acronym) && eDetails.Score < 0.7))
                //{
                //    isContinue = true;
                //    stepContext.ActiveDialog.State["stepIndex"] = (int)stepContext.ActiveDialog.State["stepIndex"] - 1;
                //    return await IntroStepAsync(stepContext, cancellationToken);
                //}
            }
            else if (strRole.ToUpper().Equals("CP-ADMIN"))
            {
                if (isNum)
                {
                    if (num > 4)
                    {
                        isContinue = true;
                        stepContext.ActiveDialog.State["stepIndex"] = (int)stepContext.ActiveDialog.State["stepIndex"] - 1;
                        return(await IntroStepAsync(stepContext, cancellationToken));
                    }
                    if (stepContext.Result.ToString() == "1")
                    {
                        EntitiDetails eDtls = new EntitiDetails();
                        eDtls.Score  = 0.9;
                        eDtls.Intent = "Trigger_Service";
                        eDetails     = eDtls;
                    }
                    else if (stepContext.Result.ToString() == "2")
                    {
                        EntitiDetails eDtls = new EntitiDetails();
                        eDtls.Score  = 0.9;
                        eDtls.Intent = "Build_Deployment";
                        eDetails     = eDtls;
                    }
                    else if (stepContext.Result.ToString() == "3")
                    {
                        EntitiDetails eDtls = new EntitiDetails();
                        eDtls.Score   = 0.9;
                        eDtls.Intent  = "Trigger_Service";
                        eDtls.Project = "ProductionHealthCheck";
                        eDetails      = eDtls;
                    }
                    else if (stepContext.Result.ToString() == "4")
                    {
                        EntitiDetails eDtls = new EntitiDetails();
                        eDtls.Score  = 0.9;
                        eDtls.Intent = "UsefulLinks";
                        eDetails     = eDtls;
                    }
                }
                else if (eDetails.Intent == "Acronym" && (string.IsNullOrEmpty(eDetails.Acronym) && eDetails.Score < 0.7))
                {
                    isContinue = true;
                    stepContext.ActiveDialog.State["stepIndex"] = (int)stepContext.ActiveDialog.State["stepIndex"] - 1;
                    return(await IntroStepAsync(stepContext, cancellationToken));
                }
                else if (eDetails.Intent == "Build_Deployment")
                {
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text("Sorry. You dont have access to Build deployments. Please contact administrator."), cancellationToken);

                    return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));
                }
            }
            else if (strRole.ToUpper().Equals("USER"))
            {
                if (isNum)
                {
                    if (num > 3)
                    {
                        isContinue = true;
                        stepContext.ActiveDialog.State["stepIndex"] = (int)stepContext.ActiveDialog.State["stepIndex"] - 1;
                        return(await IntroStepAsync(stepContext, cancellationToken));
                    }
                    if (stepContext.Result.ToString() == "1")
                    {
                        EntitiDetails eDtls = new EntitiDetails();
                        eDtls.Score  = 0.9;
                        eDtls.Intent = "Trigger_Service";
                        eDetails     = eDtls;
                    }
                    else if (stepContext.Result.ToString() == "2")
                    {
                        EntitiDetails eDtls = new EntitiDetails();
                        eDtls.Score   = 0.9;
                        eDtls.Intent  = "Trigger_Service";
                        eDtls.Project = "ProductionHealthCheck";
                        eDetails      = eDtls;
                    }
                    else if (stepContext.Result.ToString() == "3")
                    {
                        EntitiDetails eDtls = new EntitiDetails();
                        eDtls.Score  = 0.9;
                        eDtls.Intent = "UsefulLinks";
                        eDetails     = eDtls;
                    }
                }
                else if (eDetails.Intent == "Acronym" && (string.IsNullOrEmpty(eDetails.Acronym) && eDetails.Score < 0.7))
                {
                    isContinue = true;
                    stepContext.ActiveDialog.State["stepIndex"] = (int)stepContext.ActiveDialog.State["stepIndex"] - 1;
                    return(await IntroStepAsync(stepContext, cancellationToken));
                }
                else if (eDetails.Intent == "Build_Deployment")
                {
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text("Sorry. You dont have access to Build deployments. Please contact administrator."), cancellationToken);

                    return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));
                }
            }
            else if (strRole.ToUpper().Equals("DEVOPS"))
            {
                if (isNum)
                {
                    if (num > 2)
                    {
                        isContinue = true;
                        stepContext.ActiveDialog.State["stepIndex"] = (int)stepContext.ActiveDialog.State["stepIndex"] - 1;
                        return(await IntroStepAsync(stepContext, cancellationToken));
                    }
                    if (stepContext.Result.ToString() == "1")
                    {
                        EntitiDetails eDtls = new EntitiDetails();
                        eDtls.Score  = 0.9;
                        eDtls.Intent = "Build_Deployment";
                        eDetails     = eDtls;
                    }
                    else if (stepContext.Result.ToString() == "2")
                    {
                        EntitiDetails eDtls = new EntitiDetails();
                        eDtls.Score  = 0.9;
                        eDtls.Intent = "UsefulLinks";
                        eDetails     = eDtls;
                    }
                }
                else if (eDetails.Intent == "Acronym" && (string.IsNullOrEmpty(eDetails.Acronym) && eDetails.Score < 0.7))
                {
                    isContinue = true;
                    stepContext.ActiveDialog.State["stepIndex"] = (int)stepContext.ActiveDialog.State["stepIndex"] - 1;
                    return(await IntroStepAsync(stepContext, cancellationToken));
                }
                else if (eDetails.Intent == "Trigger_Service")
                {
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text("Sorry. You dont have access to Test Execution. Please contact administrator."), cancellationToken);

                    return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));
                }
            }
            if (eDetails.Intent == "Trigger_Service")
            {
                if (!string.IsNullOrEmpty(entitiDetails.Project) && entitiDetails.Project == "AutoDerivation")
                {
                    entitiDetails.Project = "ClientProfile";
                    entitiDetails.Tag     = "AutoDerivation";
                }
                strJenkinUrl = Configuration["JenkinsURL1"];
                if (Configuration["CheckJenkins"] == "true")
                {
                    strJenkinUrl = CheckJenkinsServer();
                }
                if (string.IsNullOrEmpty(strJenkinUrl) || Configuration["IsJenkinsDown"] == "true")
                {
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text(Configuration["MaintainanceMessage"]), cancellationToken);

                    return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));
                }
            }
            else if (eDetails.Intent == "UsefulLinks")
            {
                await stepContext.Context.SendActivityAsync(MessageFactory.Text("Click on the link: [Useful Links](https://floraafeedback.z13.web.core.windows.net/CotivitiUsefulLink.html)"), cancellationToken);

                return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));
            }
            if ((string.IsNullOrEmpty(eDetails.Intent) || eDetails.Score < 0.3))
            {
                var httpClient = _httpClientFactory.CreateClient();

                var qnaMaker = new QnAMaker(new QnAMakerEndpoint
                {
                    KnowledgeBaseId = Configuration["QnAKnowledgebaseId"],
                    EndpointKey     = Configuration["QnAEndpointKey"],
                    Host            = Configuration["QnAEndpointHostName"]
                },
                                            null,
                                            httpClient);
                EntitiDetails entitiDetails1 = new EntitiDetails();
                if (stepContext.Result.ToString().ToUpper().Trim() == "QUIT")
                {
                    entitiDetails1.Returnmsg = "returnQuit";
                    return(await stepContext.BeginDialogAsync(nameof(MainDialog), entitiDetails1, cancellationToken));
                }
                else
                {
                    entitiDetails1.Returnmsg = "return";
                }
                var response = await qnaMaker.GetAnswersAsync(stepContext.Context);

                if (response != null && response.Length > 0)
                {
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text(response[0].Answer), cancellationToken);

                    await stepContext.EndDialogAsync(cancellationToken : cancellationToken);

                    return(await stepContext.BeginDialogAsync(nameof(MainDialog), entitiDetails1, cancellationToken));
                }
                else
                {
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text("Sorry. I didn't get you. Please select appropriate action"), cancellationToken);

                    return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));
                }
            }
            return(await stepContext.BeginDialogAsync(nameof(ActionDialog), eDetails, cancellationToken));
        }