Ejemplo n.º 1
0
        /// <summary>
        /// Asks the user what to do next.
        /// </summary>
        /// <param name="stepContext"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        private async Task <DialogTurnResult> FirstStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var _DialogInfo = await _dialogInfoStateProperty.GetAsync(stepContext.Context);

            _DialogInfo.LastDialogName = this.Id;

            _chooseOptionList = DecisionMaker.GetChooseOptions(_DialogInfo.Language);

            var choices = new List <Choice>();

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

            var mainMenu      = dialogsMUI.ChooseOptionDictionary["mainMenu"];      // "Main Menu";
            var sendEmail     = dialogsMUI.ChooseOptionDictionary["sendEmail"];     // "Send conversation to email";
            var subscriptions = dialogsMUI.ChooseOptionDictionary["subscriptions"]; // "My subscriptions";

            var ch1 = mainMenu;
            var ch2 = sendEmail;
            var ch3 = subscriptions;
            {
                choices.Add(new Choice(ch1));
                choices.Add(new Choice(ch2));
                choices.Add(new Choice(ch3));
            }
            var stepOptions = stepContext.Options.ToString().ToLower();

            if (stepOptions == "qa")
            {
                var ch4 = dialogsMUI.ChooseOptionDictionary["questions/answers"]; // "Questions/Answers";
                var ch5 = dialogsMUI.ChooseOptionDictionary["proposeQuestion"];;  // "Propose a new question";

                choices.Add(new Choice(ch4));
                choices.Add(new Choice(ch5));
            }

            {
                var ch6 = dialogsMUI.ChooseOptionDictionary["endDialog"]; // "End dialog";
                choices.Add(new Choice(ch6));
            }

            var msg      = dialogsMUI.ChooseOptionDictionary["next"]; // "What to do next?";
            var retryMsg = dialogsMUI.MainDictionary["reprompt"];     // "Try one more time, please:";

            var options = new PromptOptions()
            {
                Prompt      = MessageFactory.Text(msg),
                RetryPrompt = MessageFactory.Text(retryMsg),
                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));
        }