void addProp(userState userProfile, string key, string value)
 {
     if (userProfile.props.ContainsKey(key))
     {
         userProfile.props[key] = value;
     }
     else
     {
         userProfile.props.Add(key, value);
     }
 }
        private async Task <DialogTurnResult> MAINSTEP(WaterfallStepContext step, CancellationToken cancellationToken)
        {
            var userProfile = await UserProfileAccessor.GetAsync(step.Context, () => null);

            if (userProfile == null)
            {
                userProfile = new userState()
                {
                    step = 1, props = new Dictionary <string, string>()
                };
                await UserProfileAccessor.SetAsync(step.Context, userProfile);
            }
            var stepNumber = userProfile.step;

            switch (stepNumber)
            {
            //STEPS

            case 1:      //START-# I am the conversation designer demo-Main
                await step.Context.SendActivityAsync(await this.ReplacePragmas(step, STRING_1));

                return(await step.NextAsync());

            case 2:      //MESSAGE-## Read the graphic flow and watch the synchronization between the flow and the chat-Main
                await step.Context.SendActivityAsync(await this.ReplacePragmas(step, STRING_2));

                return(await step.NextAsync());

            case 3:      //CHOICE-What do you want to try?-Main
                return(await this.STEP_3(step));

            case 4:      //DIALOG-LUIS Dialog-Main
                         //ADD TO THE DIALOG STACK

                dialogStack.push(new DialogStep {
                    step = 3, dialog = "Main"
                });
                return(await step.NextAsync());

            case 5:      //DIALOG-Echo Dialog-Main
                         //ADD TO THE DIALOG STACK

                dialogStack.push(new DialogStep {
                    step = 3, dialog = "Main"
                });
                return(await step.NextAsync());

            case 6:      //DIALOG-QNA Dialog-Main
                         //ADD TO THE DIALOG STACK

                dialogStack.push(new DialogStep {
                    step = 3, dialog = "Main"
                });
                return(await step.NextAsync());

            case 7:      //DIALOG-Change Language Dialog-Main
                         //ADD TO THE DIALOG STACK

                dialogStack.push(new DialogStep {
                    step = 3, dialog = "Main"
                });
                return(await step.NextAsync());

            case 8:      //DIALOG-Dialog-Main
                         //ADD TO THE DIALOG STACK

                dialogStack.push(new DialogStep {
                    step = 3, dialog = "Main"
                });
                return(await step.NextAsync());

            case 9:      //INPUT-Please shout something. (Exit to leave)-ECHO
                return(await this.STEP_9(step));

            case 10:      //MESSAGE-You said: {SHOUT}-ECHO
                await step.Context.SendActivityAsync(await this.ReplacePragmas(step, STRING_10));

                return(await step.NextAsync());

            case 11:      //IF-Did user type EXIT ?-ECHO
                return(await step.NextAsync());

            case 12:      //DIALOGSTART-StartDialog-ECHO
                return(await step.NextAsync());

            case 13:      //DIALOGEND-EndDialog-ECHO
                return(await step.NextAsync());

            case 14:      //DIALOGSTART-StartDialog-QnA
                return(await step.NextAsync());

            case 15:      //DIALOGEND-EndDialog-QnA
                return(await step.NextAsync());

            case 16:      //QNA-Chitchat with me in English (EXIT to leave)-QnA
                return(await this.STEP_16(step));

            case 17:      //IF-Did the user type EXIT?-QnA
                return(await step.NextAsync());

            case 18:      //DIALOGSTART-StartDialog-LANGUAGE
                return(await step.NextAsync());

            case 19:      //DIALOGEND-EndDialog-LANGUAGE
                return(await step.NextAsync());

            case 20:      //CHOICE-Choose the new language-LANGUAGE
                return(await this.STEP_20(step));

            case 21:      //MESSAGE-Language changed to {CURRENT_LANGUAGE}-LANGUAGE
                await step.Context.SendActivityAsync(await this.ReplacePragmas(step, STRING_21));

                return(await step.NextAsync());

            case 22:      //DIALOGSTART-StartDialog-LUIS
                return(await step.NextAsync());

            case 23:      //DIALOGEND-EndDialog-LUIS
                return(await step.NextAsync());

            case 24:      //LUIS-Choose a color using natural language (LUIS)-LUIS
                return(await this.STEP_24(step));

            case 25:      //MESSAGE-Blue: nice color!-LUIS
                await step.Context.SendActivityAsync(await this.ReplacePragmas(step, STRING_25));

                return(await step.NextAsync());

            case 26:      //MESSAGE-Red: nice color!-LUIS
                await step.Context.SendActivityAsync(await this.ReplacePragmas(step, STRING_26));

                return(await step.NextAsync());

            case 27:      //MESSAGE-No intent detected-LUIS
                await step.Context.SendActivityAsync(await this.ReplacePragmas(step, STRING_27));

                return(await step.NextAsync());

            case 28:      //DIALOGSTART-StartDialog-SEARCH
                return(await step.NextAsync());

            case 29:      //DIALOGEND-EndDialog-SEARCH
                return(await step.NextAsync());

            case 30:      //SEARCH-What to Search?-SEARCH
                return(await this.STEP_30(step));

            default:
                userProfile.step = 1;
                await UserProfileAccessor.SetAsync(step.Context, userProfile);

                return(await step.NextAsync());
            }

            return(await step.NextAsync());
        }
        private async Task qnaResultsDisplay(WaterfallStepContext step, int thisStep, userState userProfile, QnAResult[] qnaResults, CancellationToken cancellationToken)
        {
            if (qnaResults.Length > 0)
            {
                var res     = qnaResults[0].Answer;
                var prompts = qnaResults[0].Context?.Prompts;

                if (prompts.Length > 0)
                {
                    var buttons = new List <Choice>();
                    for (int i = 0; i < prompts.Length; i++)
                    {
                        CardAction CA = new CardAction()
                        {
                            Type = ActionTypes.ImBack, Title = prompts[i].DisplayText, Value = prompts[i].DisplayText
                        };
                        buttons.Add(new Choice {
                            Action = CA, Value = prompts[i].DisplayText
                        });
                    }

                    var options = new PromptOptions()
                    {
                        Prompt  = MessageFactory.Text(res),
                        Style   = ListStyle.HeroCard,
                        Choices = buttons,
                    };

                    await step.PromptAsync(CHOICE_PROMPT, options, cancellationToken);

                    userProfile.step = thisStep;
                }
                else
                {
                    await step.Context.SendActivityAsync(res);
                }
            }
            else
            {
                await step.Context.SendActivityAsync("Sorry, didn't find answers in the KB.");
            }
        }
 string getProp(userState userProfile, string key)
 {
     return(userProfile.props[key]);
 }