Exemplo n.º 1
0
        /// <summary>
        /// Execution for the <see cref="NameDialog"/> starts here.
        /// </summary>
        /// <param name="context">Mandatory. The context for the execution of a dialog's conversational process.</param>
        public Task StartAsync(IDialogContext context)
        {
            if (_entities != null)
            {
                _preferredName = _messageHelpers.ExtractEntityFromMessage("User.PreferredName", _entities);
            }

            string name = _botDataService.GetPreferredName(context);

            if (!string.IsNullOrWhiteSpace(_preferredName))
            {
                PromptDialog.Confirm(context, ResumeAfterPreferredNameConfirmation,
                                     $"So you'd like me to call you {_preferredName}?", $"Sorry I don't understand - try again! Should I call you {_preferredName}?");
                return(Task.CompletedTask);
            }

            if (!string.IsNullOrWhiteSpace(name))
            {
                PromptDialog.Confirm(context, ResumeAfterConfirmation,
                                     $"Do you want me to keep calling you {name}?", $"Sorry I don't understand - try again! Should I call you {name}?");
                return(Task.CompletedTask);
            }

            PromptDialog.Text(context, ResumeAfterNameFilled,
                              "What is your name?", "Sorry I didn't get that - try again! What should I call you?");
            return(Task.CompletedTask);
        }
Exemplo n.º 2
0
        public async Task Greeting(IDialogContext context, LuisResult result)
        {
            string name = _botDataService.GetPreferredName(context);
            bool   hasCompletedGetStarted = _botDataService.hasCompletedGetStarted(context);

            if (hasCompletedGetStarted)
            {
                // Just say hey
                await context.PostAsync(await _conversationService.GetGreeting(name));
            }
            else
            {
                // Run the setup/tutorial
                context.Call(_dialogBuilder.BuildGetStartedDialog(GetMessageActivity(context)), Resume_AfterGetStartedDialog);
            }
        }