public async Task <DialogTurnResult> ProcessUserChoice(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            string choice   = stepContext.Context.Activity.Text.ToUpperInvariant();
            string response = string.Empty;

            switch (choice)
            {
            case "YES":
                // await stepContext.Context.SendActivityAsync("LUIS");
                await GetSearchResult(stepContext);

                return(await stepContext.EndDialogAsync());

            case "NO":
                response = "Thank you.Hope to see you around";
                TaskResult taskResult = new TaskResult()
                {
                    Category     = CategoryType.Search,
                    ModelName    = "Search API",
                    Query        = stepContext.Values["PrevQuery"].ToString(),
                    Intent       = string.Empty,
                    Entity       = string.Empty,
                    Response     = response,
                    ResponseType = BotResponseType.ValidResponse,
                    Score        = 1,
                    Source       = CategoryType.Search
                };
                await stepContext.Context.SendActivityAsync(response);

                await _sqlLoggerRepository.InsertBotLogAsync(stepContext.Context.Activity, taskResult);

                return(await stepContext.EndDialogAsync());

            default:
                return(await stepContext.BeginDialogAsync(nameof(WPBotFlowDialog)));
            }
        }
        protected override async Task <DialogTurnResult> OnBeginDialogAsync(DialogContext innerDc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            bool   isResponded = false;
            string response    = string.Empty;

            // QnA Service
            _configuration.CheckKeyVault(_configuration["QnA:EndpointKey"]);
            var qnaEndpoint = new QnAMakerEndpoint()
            {
                KnowledgeBaseId = _configuration["QnA:KbId"],
                EndpointKey     = _configuration[_configuration["QnA:EndpointKey"]],
                Host            = _configuration["QnA:Hostname"],
            };
            QnAMakerOptions qnaOptions = float.TryParse(_configuration["QnA:Threshold"], out float scoreThreshold)
                ? new QnAMakerOptions {
                ScoreThreshold = scoreThreshold, Top = 1,
            }
                : null;

            var qnaMaker = new QnAMaker(qnaEndpoint, qnaOptions, null);

            QueryResult[] answer = await qnaMaker.GetAnswersAsync(innerDc.Context);

            if (answer != null && answer.Length > 0)
            {
                response = Regex.Replace(answer.FirstOrDefault().Answer, Utilities.GetResourceMessage(Constants.FirstNamePlaceHolder), innerDc.Context.Activity.From.Name, RegexOptions.IgnoreCase);
                await innerDc.Context.SendActivityAsync(response.Trim());

                await innerDc.Context.AskUserFeedbackAsync(_prevActivityAccessor);

                isResponded = true;
            }
            TaskResult taskResult = new TaskResult()
            {
                Category     = CategoryType.QnA,
                ModelName    = _configuration["QnA:Name"],
                Intent       = string.Empty,
                Entity       = string.Empty,
                Response     = response,
                ResponseType = BotResponseType.ValidResponse,
                Score        = (answer == null || answer.Length == 0) ? 0 : answer.FirstOrDefault().Score,
                Source       = string.IsNullOrEmpty(response) ? CategoryType.QnA : CategoryType.BotResponse
            };
            await _sqlLoggerRepository.InsertBotLogAsync(innerDc.Context.Activity, taskResult);

            return(await innerDc.EndDialogAsync(result : isResponded));
        }