Example #1
0
        /// <summary>
        /// Generates new QuestionAndAnswerModel and returns ChoicePrompt
        /// or passes on not modified QuestionAndAnswerModel to the next step.
        /// </summary>
        /// <param name="stepContext"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        private async Task <DialogTurnResult> GetMenuItemsStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var _DialogInfo = await _dialogInfoStateProperty.GetAsync(stepContext.Context);//new DialogState()

            _DialogInfo.LastDialogName = this.Id;
            {
                _menuItems = DecisionMaker.GetMainMenuItems(_DialogInfo.Language);
                //_menuItemsNeutral = DecisionMaker.GetMainMenuItemsNeutral();

                var choices = new List <Choice>();

                foreach (var item in _menuItems)
                {
                    choices.Add(new Choice(item.Name));
                }

                var dialogsMUI = DecisionMaker.GetDialogsMui(_DialogInfo.Language);

                var prompt = dialogsMUI.MainMenuDictionary["prompt"];// "What you are interested in?";

                var options = new PromptOptions()
                {
                    Prompt      = MessageFactory.Text(prompt),
                    RetryPrompt = MessageFactory.Text(dialogsMUI.MainDictionary["reprompt"]),
                    Choices     = choices,
                    Style       = ListStyle.SuggestedAction
                };

                var message = options.Prompt.Text;
                var sender  = "bot";
                var time    = stepContext.Context.Activity.Timestamp.Value;

                _myLogger.LogMessage(message, sender, time, _DialogInfo.DialogId);

                return(await stepContext.PromptAsync(nameof(ChoicePrompt), options, cancellationToken));
            }
        }