Exemplo n.º 1
0
        protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            var httpClient = _httpClientFactory.CreateClient();

            var qnaMaker = new QnAMaker(new QnAMakerEndpoint
            {
                KnowledgeBaseId = _configuration["QnAKnowledgebaseId"],
                EndpointKey     = _configuration["QnAAuthKey"],
                Host            = GetHostname()
            },
                                        null,
                                        httpClient);

            _logger.LogInformation("Calling QnA Maker");

            // The actual call to the QnA Maker service.
            var response = await qnaMaker.GetAnswersAsync(turnContext);

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

                    var card = new HeroCard();

                    card.Text    = @"Were you able to obtain your e-measures?";
                    card.Buttons = new List <CardAction>()
                    {
                        new CardAction()
                        {
                            Title = "Yes", Type = ActionTypes.ImBack, Value = "Yes, I completed the survey."
                        },
                        new CardAction()
                        {
                            Title = "No, I need more help\n from my EHR", Type = ActionTypes.ImBack, Value = String.Format("I need more help from {0}.", turnContext.Activity.Text)
                        },
                        new CardAction()
                        {
                            Title = "No, I need steps for\n a different EHR", Type = ActionTypes.ImBack, Value = "I need steps for a different EHR."
                        },
                        new CardAction()
                        {
                            Title = "Go back", Type = ActionTypes.ImBack, Value = "Go back"
                        },
                    };

                    var reply = MessageFactory.Attachment(card.ToAttachment());
                    await turnContext.SendActivityAsync(reply, cancellationToken);
                }
                else if (turnContext.Activity.Text == "MENU" || turnContext.Activity.Text == "Go back")
                {
                    await OpenMenu(turnContext, cancellationToken);
                }
                else if (turnContext.Activity.Text == "FAQ")
                {
                    var card = new HeroCard();

                    card.Text    = @"Call your Practice Support Advisor(PSA) for access to Hill inSite or for any issues with the automated questionnaire. Or go back to the Main Menu.";
                    card.Buttons = new List <CardAction>()
                    {
                        new CardAction()
                        {
                            Title = "How do I access the\n questionnaire?", Type = ActionTypes.ImBack, Value = "How do I access the questionnaire?"
                        },
                        new CardAction()
                        {
                            Title = "What is the deadline\n to complete the\n questionnaire? ", Type = ActionTypes.ImBack, Value = "What is the deadline to complete the questionnaire? "
                        },
                        new CardAction()
                        {
                            Title = "Why is this\n information requested?", Type = ActionTypes.ImBack, Value = "Why is this information requested?"
                        },
                        new CardAction()
                        {
                            Title = "What are the \n two e-Measures?", Type = ActionTypes.ImBack, Value = "What are the two e-Measures?"
                        },
                        new CardAction()
                        {
                            Title = "For which\n measurement year\n is the e-Measure \n data being requested?", Type = ActionTypes.ImBack, Value = "For which measurement year is the e-Measure data being requested?"
                        },
                        new CardAction()
                        {
                            Title = "Who may complete\n the form? ", Type = ActionTypes.ImBack, Value = "Who may complete the form? "
                        },
                        new CardAction()
                        {
                            Title = "Does the form have to\n be completed\n once per provider?", Type = ActionTypes.ImBack, Value = "Does the form have to be completed once per provider?"
                        },
                        new CardAction()
                        {
                            Title = "Is this information\n collected only\n for Hill\n Physicians’ members?", Type = ActionTypes.ImBack, Value = "Is this information collected only for Hill Physicians’ members?"
                        },
                        new CardAction()
                        {
                            Title = "Is performance based\n on the number\n of compliant\n patients?", Type = ActionTypes.ImBack, Value = "Is performance based on the number of compliant patients?"
                        },
                        new CardAction()
                        {
                            Title = "Why do I have to\n complete this\n form every year?", Type = ActionTypes.ImBack, Value = "Why do I have to complete this form every year?"
                        },
                        new CardAction()
                        {
                            Title = "Go back", Type = ActionTypes.ImBack, Value = "Go back"
                        }
                    };

                    var reply = MessageFactory.Attachment(card.ToAttachment());
                    await turnContext.SendActivityAsync(reply, cancellationToken);
                }
                else if (turnContext.Activity.Text.Contains("more help")) //FIX
                {
                    var card = new HeroCard();

                    card.Text    = @"Call your Practice Support Advisor(PSA) for access to Hill inSite or for any issues with the automated questionnaire. Or go back to the Main Menu.";
                    card.Buttons = new List <CardAction>()
                    {
                        new CardAction()
                        {
                            Title = "Go back", Type = ActionTypes.ImBack, Value = "Go back"
                        },
                    };

                    var reply = MessageFactory.Attachment(card.ToAttachment());
                    await turnContext.SendActivityAsync(reply, cancellationToken);
                }
                else
                {
                    await turnContext.SendActivityAsync(MessageFactory.Text(response[0].Answer), cancellationToken);
                }
            }
            else
            {
                var card = new HeroCard();

                card.Text    = @"I'm not sure how to answer that question. Call your Practice Support Advisor(PSA) for access to Hill inSite or for any issues with the automated questionnaire. Or go back to the Main Menu.";
                card.Buttons = new List <CardAction>()
                {
                    new CardAction()
                    {
                        Title = "Go back", Type = ActionTypes.ImBack, Value = "Go back"
                    },
                };

                var reply = MessageFactory.Attachment(card.ToAttachment());
                await turnContext.SendActivityAsync(reply, cancellationToken);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Run every turn of the conversation. Handles orchestration of messages.
        /// </summary>
        /// <param name="turnContext">Bot Turn Context.</param>
        /// <param name="cancellationToken">Task CancellationToken.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken)
        {
            var activity = turnContext.Activity;

            // Create a dialog context
            var dc = await Dialogs.CreateContextAsync(turnContext, cancellationToken);

            switch (activity.Type)
            {
            case ActivityTypes.Message:
            {
                // This bot is not case sensitive.
                var text = turnContext.Activity.Text?.Trim()?.ToLowerInvariant();

                if (text == null)
                {
                    string action = ((dynamic)turnContext.Activity.Value)?.action;
                    string id     = ((dynamic)turnContext.Activity.Value)?.id;

                    switch (action)
                    {
                    case DropoffAction:
                        await dc.BeginDialogAsync(
                            nameof(ConfirmDropoffDialog),
                            new ConfirmDropoffDialog.ConfirmDropoffDialogOptions {
                                ReservationId = id
                            },
                            cancellationToken : cancellationToken);

                        break;

                    case CancelAction:
                        await dc.BeginDialogAsync(
                            nameof(CancelReservationDialog),
                            new CancelReservationDialog.CancelReservationDialogOptions {
                                ReservationId = id
                            },
                            cancellationToken : cancellationToken);

                        break;
                    }

                    // Continue the current dialog
                    await dc.ContinueDialogAsync(cancellationToken);

                    break;
                }

                if (text == "help")
                {
                    await SendWelcomeMessageAsync(turnContext, cancellationToken);

                    break;
                }

                if (text == "login")
                {
                    // Start the Login process.
                    await dc.BeginDialogAsync(nameof(AuthDialog), cancellationToken : cancellationToken);

                    break;
                }

                if (text == "logout")
                {
                    // The bot adapter encapsulates the authentication processes.
                    var botAdapter = (BotFrameworkAdapter)turnContext.Adapter;
                    await botAdapter.SignOutUserAsync(turnContext, AuthDialog.AuthConnectionName, cancellationToken : cancellationToken);

                    await turnContext.SendActivityAsync("You have been signed out.", cancellationToken : cancellationToken);

                    break;
                }

                if (text == "!generatetranscripts")
                {
                    await GenerateTranscriptsAsync(turnContext);
                }

                // Perform a call to LUIS to retrieve results for the current activity message.
                var luisResults = await _luis.RecognizeAsync(dc.Context, cancellationToken).ConfigureAwait(false);

                var(intent, score) = luisResults.GetTopScoringIntent();
                var entities = ParseLuisForEntities(luisResults);

                // Log LUIS to AppInsights
                LogLuis(luisResults, intent, score, entities);

                // Handle conversation interrupts first.
                var interrupted = await IsTurnInterruptedAsync(dc, intent);

                if (interrupted)
                {
                    // Bypass the dialog.
                    // Save state before the next turn.
                    await _accessors.ConversationState.SaveChangesAsync(turnContext, cancellationToken : cancellationToken);

                    await _accessors.UserState.SaveChangesAsync(turnContext, cancellationToken : cancellationToken);

                    return;
                }

                // Continue the current dialog
                var dialogResult = await dc.ContinueDialogAsync(cancellationToken);

                // if no one has responded,
                if (!dc.Context.Responded)
                {
                    // examine results from active dialog
                    switch (dialogResult.Status)
                    {
                    case DialogTurnStatus.Empty:
                        switch (intent)
                        {
                        case NewReservationIntent:
                            await dc.BeginDialogAsync(
                                nameof(NewReservationDialog),
                                new NewReservationDialog.NewReservationDialogOptions {
                                    LuisEntities = entities
                                },
                                cancellationToken);

                            // await dc.BeginDialogAsync(
                            //    nameof(NewReservationForm),
                            //    cancellationToken);
                            break;

                        case EditReservationIntent:
                            var reply = turnContext.Activity.CreateReply();
                            reply.Attachments.Add(new HeroCard
                                {
                                    Text    = "Please open the app to make modifications to your reservations.",
                                    Buttons = new List <CardAction> {
                                        new CardAction(ActionTypes.OpenUrl, "Open the app", value: "https://carwashu.azurewebsites.net/")
                                    },
                                }.ToAttachment());
                            await turnContext.SendActivityAsync(reply, cancellationToken);

                            break;

                        case CancelReservationIntent:
                            await dc.BeginDialogAsync(
                                nameof(CancelReservationDialog),
                                cancellationToken : cancellationToken);

                            break;

                        case FindReservationIntent:
                            await dc.BeginDialogAsync(nameof(FindReservationDialog), cancellationToken : cancellationToken);

                            break;

                        case NextFreeSlotIntent:
                            await dc.BeginDialogAsync(nameof(NextFreeSlotDialog), cancellationToken : cancellationToken);

                            break;

                        case WeatherIntent:
                            await turnContext.SendActivityAsync("They say, I'll get access to the internet soon, and will be able to answer what the weather will look like...", cancellationToken : cancellationToken);

                            break;

                        case NoneIntent:
                            // Check QnA Maker model
                            var response = await _qna.GetAnswersAsync(turnContext);

                            if (response != null && response.Length > 0)
                            {
                                await turnContext.SendActivityAsync(response[0].Answer, cancellationToken : cancellationToken);
                            }
                            else
                            {
                                _telemetryClient.TrackEvent(
                                    "Understanding user failed",
                                    new Dictionary <string, string>
                                    {
                                        { "Event Name", "Understanding user failed" },
                                        { "Activity Type", turnContext.Activity.Type },
                                        { "Message", text },
                                        { "Channel ID", turnContext.Activity.ChannelId },
                                        { "Activity ID", turnContext.Activity.Id },
                                        { "Conversation ID", turnContext.Activity.Conversation.Id },
                                        { "From ID", turnContext.Activity.From.Id },
                                        { "Recipient ID", turnContext.Activity.Recipient.Id },
                                        { "Value", JsonConvert.SerializeObject(turnContext.Activity.Value) },
                                        { "LUIS intent 'None'", "true" },
                                    });

                                await dc.Context.SendActivityAsync("I didn't understand what you just said to me.", cancellationToken : cancellationToken);
                            }

                            break;

                        default:
                            _telemetryClient.TrackEvent(
                                "Understanding user failed",
                                new Dictionary <string, string>
                                {
                                    { "Event Name", "Understanding user failed" },
                                    { "Activity Type", turnContext.Activity.Type },
                                    { "Message", text },
                                    { "Channel ID", turnContext.Activity.ChannelId },
                                    { "Activity ID", turnContext.Activity.Id },
                                    { "Conversation ID", turnContext.Activity.Conversation.Id },
                                    { "From ID", turnContext.Activity.From.Id },
                                    { "Recipient ID", turnContext.Activity.Recipient.Id },
                                    { "Value", JsonConvert.SerializeObject(turnContext.Activity.Value) },
                                    { "LUIS intent 'None'", "false" },
                                });

                            // Help or no intent identified, either way, let's provide some help to the user
                            await dc.Context.SendActivityAsync("I didn't understand what you just said to me.", cancellationToken : cancellationToken);

                            break;
                        }

                        break;

                    case DialogTurnStatus.Waiting:
                        // The active dialog is waiting for a response from the user, so do nothing.
                        break;

                    case DialogTurnStatus.Complete:
                        await dc.EndDialogAsync(cancellationToken : cancellationToken);

                        break;

                    default:
                        await dc.CancelAllDialogsAsync(cancellationToken);

                        break;
                    }
                }

                break;
            }

            case ActivityTypes.Event:
            case ActivityTypes.Invoke:
                // This handles the MS Teams Invoke Activity sent when magic code is not used.
                // See: https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/authentication/auth-oauth-card#getting-started-with-oauthcard-in-teams
                // The Teams manifest schema is found here: https://docs.microsoft.com/en-us/microsoftteams/platform/resources/schema/manifest-schema
                // It also handles the Event Activity sent from the emulator when the magic code is not used.
                // See: https://blog.botframework.com/2018/08/28/testing-authentication-to-your-bot-using-the-bot-framework-emulator/
                // dc = await Dialogs.CreateContextAsync(turnContext, cancellationToken);
                await dc.ContinueDialogAsync(cancellationToken);

                if (!turnContext.Responded)
                {
                    await dc.BeginDialogAsync(nameof(AuthDialog), cancellationToken : cancellationToken);
                }

                break;

            case ActivityTypes.ConversationUpdate:
            {
                if (activity.MembersAdded.Any())
                {
                    // Iterate over all new members added to the conversation.
                    foreach (var member in activity.MembersAdded)
                    {
                        // Greet only the user and not the bot itself.
                        if (member.Id == activity.Recipient.Id)
                        {
                            continue;
                        }
                        await SendWelcomeMessageAsync(turnContext, cancellationToken);

                        break;
                    }
                }

                break;
            }
            }

            await _accessors.ConversationState.SaveChangesAsync(turnContext, cancellationToken : cancellationToken);

            await _accessors.UserState.SaveChangesAsync(turnContext, cancellationToken : cancellationToken);
        }
Exemplo n.º 3
0
 public virtual async Task <QueryResult[]> GetAnswersAsync(ITurnContext turnContext, QnAMakerOptions options = null)
 => await QnAMaker.GetAnswersAsync(turnContext, options);
Exemplo n.º 4
0
        private async Task <DialogTurnResult> IntroStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            if (!_luisRecognizer.IsConfigured)
            {
                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.", inputHint: InputHints.IgnoringInput), cancellationToken);

                return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));
            }
            else
            {
                var luisResult = await _luisRecognizer.RecognizeAsync <BotAxity>(stepContext.Context, cancellationToken);

                var answerFromService = " ";
                switch (luisResult.TopIntent().intent)
                {
                case BotAxity.Intent.PasswordReset:
                    string modulo;
                    try
                    { modulo = luisResult.Entities.Modulo[0][0]; }
                    catch (Exception e)
                    {
                        _logger.LogInformation($"Error en InitialDialog.cs {e.StackTrace}");
                        modulo = "";
                    }

                    switch (modulo)
                    {
                    case "SAP":
                        return(await stepContext.BeginDialogAsync(nameof(PasswordResetSapDialog), null, cancellationToken));

                    case "AD":
                        return(await stepContext.BeginDialogAsync(nameof(PasswordResetAdDialog), null, cancellationToken));

                    case "TAO":
                        return(await stepContext.BeginDialogAsync(nameof(PasswordResetTaoDialog), null, cancellationToken));

                    default:
                        await SendSuggestedActionsModuleAsync(stepContext.Context, cancellationToken);

                        break;
                    }
                    break;

                case BotAxity.Intent.ComprarProductos:
                    return(await stepContext.BeginDialogAsync(nameof(FormDialogFromAdativeCard), null, cancellationToken));

                case BotAxity.Intent.QnAMakerSigma:
                    //No colocar el IhttpFactoryclient

                    var qnaMaker = new QnAMaker(new QnAMakerEndpoint
                    {
                        KnowledgeBaseId = _configuration["QnAKnowledgebaseId"],
                        EndpointKey     = _configuration["QnAAuthKey"],
                        Host            = _configuration["QnAEndpointHostName"]
                    });

                    var results = await qnaMaker.GetAnswersAsync(stepContext.Context);

                    if (results != null && results.Length > 0)
                    {
                        try
                        {
                            JObject resultToJson = JObject.Parse(results[0].Answer);
                            var     answers      = resultToJson.SelectToken("Message").ToList();
                            foreach (var answer in answers)
                            {
                                await stepContext.Context.SendActivityAsync(MessageFactory.Text(answer.ToString()), cancellationToken);
                            }
                        } catch
                        {
                            await stepContext.Context.SendActivityAsync(MessageFactory.Text(results[0].Answer), cancellationToken);
                        }
                    }
                    break;

                case BotAxity.Intent.TicketReview:
                    try
                    {
                        var Id_ticket = luisResult.Entities.Id_Ticket[0];
                        await stepContext.Context.SendActivityAsync(MessageFactory.Text("Perfecto, voy a checarlo con el equipo, en breve te tendré una respuesta"), cancellationToken);

                        await stepContext.BeginDialogAsync(nameof(TicketReviewDialog), Id_ticket, cancellationToken);
                    } catch
                    {
                        await stepContext.Context.SendActivityAsync(MessageFactory.Text("Ok, pero olvidaste ingresar el Id_Ticket"), cancellationToken);

                        await stepContext.Context.SendActivityAsync(MessageFactory.Text("Vuelve a intentarlo como el siguiente ejemplo \"Dime el estado de mi ticket 234NHJ2r\""), cancellationToken);
                    }
                    break;

                case BotAxity.Intent.Pregunta_1:
                    var DESC_ENTITY = luisResult.Entities.DESC_CUENTA[0];
                    var msg         = MessageFactory.Text("Pregunta 1");
                    msg.Speak = "< speak version = \"1.0\" xmlns = \"https://www.w3.org/2001/10/synthesis\" xml: lang = \"es-MX\" >HOla perro</ speak >";
                    await stepContext.Context.SendActivityAsync(msg, cancellationToken);



                    answerFromService = getAnswerFromQuestion1();
                    break;

                case BotAxity.Intent.Pregunta_2:
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text("Entró a Pregunta 2"), cancellationToken);

                    answerFromService = getAnswerFromQuestion2();
                    break;

                case BotAxity.Intent.Pregunta_3:
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text("Entró a Pregunta 3"), cancellationToken);

                    answerFromService = getAnswerFromQuestion3();
                    break;

                case BotAxity.Intent.Pregunta_4:
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text("Entró a Pregunta 4"), cancellationToken);

                    answerFromService = getAnswerFromQuestion4();
                    break;

                case BotAxity.Intent.Pregunta_5:
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text("Entró a Pregunta 5"), cancellationToken);

                    answerFromService = getAnswerFromQuestion5();
                    break;

                case BotAxity.Intent.Pregunta_6:
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text("Entró a Pregunta 6"), cancellationToken);

                    answerFromService = getAnswerFromQuestion6();
                    break;

                case BotAxity.Intent.Pregunta_7:
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text("Entró a Pregunta 7"), cancellationToken);

                    answerFromService = getAnswerFromQuestion7();
                    break;

                default:
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text("Lo siento no entendí, vuelve a intentarlo."), cancellationToken);

                    break;
                }
            }
            return(await stepContext.EndDialogAsync(cancellationToken : cancellationToken));
        }
Exemplo n.º 5
0
        protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            _logger.LogInformation("Running dialog with Message Activity.");
            var botState = await BasicBotStateAccessor.GetAsync(
                turnContext, () => new BasicBotState(), cancellationToken);

            var phoneNum = turnContext.Activity.Text;

            var regEx = new System.Text.RegularExpressions.Regex(@"1?\W*([2-9][0-8][0-9])\W*([2-9][0-9]{2})\W*([0-9]{4})(\se?x?t?(\d*))?");

            if (regEx.Match(phoneNum).Success)
            {
                botState.phoneNumber = phoneNum;
                var key = this.GenerateCSRNG(phoneNum);
                botState.CSRNGKey = key;

                //we have a phone number so log them in to the council
                // Run the Dialog with the new message Activity.
                /// await _dialog.Run(turnContext, _conversationState.CreateProperty<DialogState>("DialogState"), cancellationToken);
                var msgInfo     = "Great I just sent a sacred code to your frequency, can you provide that to me please?";
                var msgActivity = MessageFactory.Text(msgInfo);
                msgActivity.Speak     = msgInfo;
                msgActivity.InputHint = InputHints.ExpectingInput;

                //  return await stepContext.PromptAsync(
                //     "name", new PromptOptions { Prompt = msgActivity }, cancellationToken);

                await turnContext.SendActivityAsync(msgActivity, cancellationToken);
            }
            else
            {
                var userAnswer = turnContext.Activity.Text;

                if (userAnswer.ToLower() == "quit" || userAnswer.ToLower() == "exit" || userAnswer.ToLower() == "end game" || userAnswer.ToLower() == "stop")
                {
                    var msgInfo     = "Thank you kosmosan, your score is " + botState.Score.ToString() + ". Now you have been initiated into the supreme council and you now just enough to start and go out and save  the world.";
                    var msgActivity = MessageFactory.Text(msgInfo);
                    msgActivity.Speak     = msgInfo;
                    msgActivity.InputHint = InputHints.IgnoringInput;
                    await turnContext.SendActivityAsync(msgActivity, cancellationToken);

                    return;
                }

                var response = await _qnaService.GetAnswersAsync(turnContext);

                if (response != null && response.Length > 0)
                {
                    await turnContext.SendActivityAsync(MessageFactory.Text(response[0].Answer), cancellationToken);
                }
                else
                {
                    var welcomeCard     = CreateAdaptiveCardAttachment();
                    var genericresponse = CreateResponse(turnContext.Activity, welcomeCard);
                    await turnContext.SendActivityAsync(genericresponse, cancellationToken);
                }


                // Get a random question
                var cnStr = "Server=tcp:jmcafe-dng.database.windows.net,1433;Initial Catalog=JM_Cafe_DB;Persist Security Info=False;User ID=jmsqladmin;Password=(JMC@f3B0t);MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";

                //var rnd = new Random();
                // var chooseAQuestion = rnd.Next(1, 22);
                var question = string.Empty;
                var answer   = string.Empty;
                var fact     = string.Empty;

                using (var SqlCn = new System.Data.SqlClient.SqlConnection(cnStr))
                {
                    SqlCn.Open();
                    var sqlCmd = new System.Data.SqlClient.SqlCommand(
                        "SELECT TOP 1 * FROM dbo.echoTech_Bot_POC_QA ORDER BY NEWID()", SqlCn);

                    var dr = sqlCmd.ExecuteReader();
                    dr.Read();
                    question = dr["question_txt"].ToString();
                    answer   = dr["correct_answer"].ToString();
                    fact     = dr["Fact_Txt"].ToString();
                    botState.previousQuestion = botState.currentQuestion;
                    botState.previousFact     = botState.currentFact;
                    botState.previousAnswer   = botState.currentAnswer;
                    botState.currentAnswer    = answer;
                    botState.currentFact      = fact;
                    botState.currentQuestion  = question;
                }

                await _userState.SaveChangesAsync(turnContext);


                var isSecretCode = false;
                if (userAnswer.Contains('-'))
                {
                    isSecretCode = true;
                }

                //turnContext.Activity.Text = question;
                // The actual call to the QnA Maker service.
                //var response = await _qnaService.GetAnswersAsync(turnContext);
                //if (response != null && response.Length > 0)
                //{
                //   // await turnContext.SendActivityAsync(MessageFactory.Text(response[0].Answer), cancellationToken);
                //}
                //else
                //{
                //    await turnContext.SendActivityAsync(MessageFactory.Text("No QnA Maker answers were found."), cancellationToken);
                //}

                var correctAnswer = botState.previousAnswer;

                if (!isSecretCode)
                {
                    //check the answer angainst the qnaAnswer Service
                    if (correctAnswer.Trim().ToLower().Contains(userAnswer.ToLower()))
                    {
                        botState.Score += 10;
                        //we have a good match the user is correct
                        var msgInfo     = "Great JOB! We need more people like you. Let's try another one, " + question;
                        var msgActivity = MessageFactory.Text(msgInfo);
                        msgActivity.Speak     = msgInfo;
                        msgActivity.InputHint = InputHints.ExpectingInput;

                        await turnContext.SendActivityAsync(msgActivity, cancellationToken);
                    }
                    else
                    {
                        var errMsgInfo     = "Let's try again, that was a nice try, the answer is: " + botState.previousAnswer.ToLower() + ".  The facts of the matter are actually, " + botState.previousFact.ToLower() + " Ok try this question, " + question;
                        var msgErrActivity = MessageFactory.Text(errMsgInfo);
                        msgErrActivity.Speak     = errMsgInfo;
                        msgErrActivity.InputHint = InputHints.ExpectingInput;
                        await turnContext.SendActivityAsync(msgErrActivity, cancellationToken);
                    }
                }
                else
                {
                    if (isSecretCode)
                    {
                        var secMsgInfo     = "Excellent, let's explore your thought patterns now if you don't mind. Can you answer a couple of questions for me... " + question;
                        var msgSecActivity = MessageFactory.Text(secMsgInfo);
                        msgSecActivity.Speak     = secMsgInfo;
                        msgSecActivity.InputHint = InputHints.ExpectingInput;
                        await turnContext.SendActivityAsync(msgSecActivity, cancellationToken);
                    }
                    else
                    {
                        var errMsgInfo     = "Let's try again, that was a nice try";
                        var msgErrActivity = MessageFactory.Text(errMsgInfo);
                        msgErrActivity.Speak     = errMsgInfo;
                        msgErrActivity.InputHint = InputHints.ExpectingInput;
                        await turnContext.SendActivityAsync(msgErrActivity, cancellationToken);
                    }
                }
                //}
                //else
                //{
                //    //    await turnContext.SendActivityAsync(MessageFactory.Text("No QnA Maker answers were found."), cancellationToken);
                //    //}

                //    // Run the Dialog with the new message Activity.
                //    await _dialog.Run(turnContext, _conversationState.CreateProperty<DialogState>("DialogState"), cancellationToken);
                //}
            }
        }