Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RootDialog"/> class.
        /// </summary>
        /// <param name="skillMode">Skill mode.</param>
        /// <param name="toDoSkillServices">To Do skill service.</param>
        /// <param name="toDoSkillAccessors">To Do skill accessors.</param>
        /// <param name="toDoService">To Do provider service.</param>
        public RootDialog(bool skillMode, ToDoSkillServices toDoSkillServices, ToDoSkillAccessors toDoSkillAccessors, IToDoService toDoService)
            : base(nameof(RootDialog))
        {
            this.skillMode          = skillMode;
            this.toDoSkillAccessors = toDoSkillAccessors;
            this.toDoService        = toDoService;
            this.toDoSkillResponses = new ToDoSkillResponses();
            this.toDoSkillServices  = toDoSkillServices;

            // Initialise dialogs
            this.RegisterDialogs();
        }
Пример #2
0
        /// <summary>
        /// Digest luis result.
        /// </summary>
        /// <param name="context">dialog context.</param>
        /// <param name="accessors">the state accessors.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        public static async Task DigestLuisResultAsync(ITurnContext context, ToDoSkillAccessors accessors)
        {
            try
            {
                var state = await accessors.ToDoSkillState.GetAsync(context);

                var luisResult = (ToDo)state.LuisResult;
                var entities   = luisResult.Entities;
                if (entities.ContainsAll != null)
                {
                    state.MarkOrDeleteAllTasksFlag = true;
                }

                if (entities.ordinal != null)
                {
                    var index = (int)entities.ordinal[0];
                    if (index > 0 && index <= 5)
                    {
                        if (state.ToDoTaskIndexes.Count > 0)
                        {
                            state.ToDoTaskIndexes[0] = index - 1;
                        }
                        else
                        {
                            state.ToDoTaskIndexes.Add(index - 1);
                        }
                    }
                }

                if (entities.TaskContent != null)
                {
                    state.ToDoTaskContent = entities.TaskContent[0];
                }

                if (context.Activity.Text != null)
                {
                    var words = context.Activity.Text.Split(' ');
                    foreach (var word in words)
                    {
                        if (word.Equals("all", StringComparison.OrdinalIgnoreCase))
                        {
                            state.MarkOrDeleteAllTasksFlag = true;
                        }
                    }
                }
            }
            catch
            {
                // ToDo
            }
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ToDoSkillDialog"/> class.
        /// </summary>
        /// <param name="dialogId">Dialog id.</param>
        /// <param name="toDoSkillServices">To Do skill services.</param>
        /// <param name="accessors">To Do state accessors.</param>
        /// <param name="toDoService">To Do service.</param>
        public ToDoSkillDialog(string dialogId, ToDoSkillServices toDoSkillServices, ToDoSkillAccessors accessors, IToDoService toDoService)
            : base(dialogId)
        {
            this.toDoSkillServices = toDoSkillServices;
            this.accessors         = accessors;
            this.toDoService       = toDoService;

            var oauthSettings = new OAuthPromptSettings()
            {
                ConnectionName = this.toDoSkillServices.AuthConnectionName,
                Text           = $"Authentication",
                Title          = "Signin",
                Timeout        = 300000,
            };

            this.AddDialog(new EventPrompt(AuthSkillMode, "tokens/response", this.TokenResponseValidator));
            this.AddDialog(new OAuthPrompt(AuthLocalMode, oauthSettings, this.AuthPromptValidator));
            this.AddDialog(new TextPrompt(Action.Prompt));
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ShowToDoTasksDialog"/> class.
        /// </summary>
        /// <param name="toDoSkillServices">The To Do skill service.</param>
        /// <param name="toDoService">The To Do service.</param>
        /// <param name="accessors">The state accessors.</param>
        public ShowToDoTasksDialog(ToDoSkillServices toDoSkillServices, IToDoService toDoService, ToDoSkillAccessors accessors)
            : base(Name, toDoSkillServices, accessors, toDoService)
        {
            var showToDoTasks = new WaterfallStep[]
            {
                this.GetAuthToken,
                this.AfterGetAuthToken,
                this.ClearContext,
                this.ShowToDoTasks,
                this.AddFirstTask,
            };

            var addFirstTask = new WaterfallStep[]
            {
                this.AskAddFirstTaskConfirmation,
                this.AfterAskAddFirstTaskConfirmation,
            };

            // Define the conversation flow using a waterfall model.
            this.AddDialog(new WaterfallDialog(Action.ShowToDoTasks, showToDoTasks));
            this.AddDialog(new WaterfallDialog(Action.AddFirstTask, addFirstTask));
            this.AddDialog(new AddToDoTaskDialog(toDoSkillServices, toDoService, accessors));

            // Set starting dialog for component
            this.InitialDialogId = Action.ShowToDoTasks;
        }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MarkToDoTaskDialog"/> class.
        /// </summary>
        /// <param name="toDoSkillServices">The To Do skill service.</param>
        /// <param name="toDoService">The To Do service.</param>
        /// <param name="accessors">The state accessors.</param>
        public MarkToDoTaskDialog(ToDoSkillServices toDoSkillServices, IToDoService toDoService, ToDoSkillAccessors accessors)
            : base(Name, toDoSkillServices, accessors, toDoService)
        {
            var markToDoTask = new WaterfallStep[]
            {
                this.GetAuthToken,
                this.AfterGetAuthToken,
                this.ClearContext,
                this.CollectToDoTaskIndex,
                this.MarkToDoTaskCompleted,
            };

            var collectToDoTaskIndex = new WaterfallStep[]
            {
                this.AskToDoTaskIndex,
                this.AfterAskToDoTaskIndex,
            };

            // Define the conversation flow using a waterfall model.
            this.AddDialog(new WaterfallDialog(Action.MarkToDoTaskCompleted, markToDoTask));
            this.AddDialog(new WaterfallDialog(Action.CollectToDoTaskIndex, collectToDoTaskIndex));

            // Set starting dialog for component
            this.InitialDialogId = Action.MarkToDoTaskCompleted;
        }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GreetingDialog"/> class.
        /// </summary>
        /// <param name="toDoSkillServices">The To Do skill service.</param>
        /// <param name="toDoService">The To Do service.</param>
        /// <param name="accessors">The state accessors.</param>
        public GreetingDialog(ToDoSkillServices toDoSkillServices, IToDoService toDoService, ToDoSkillAccessors accessors)
            : base(Name, toDoSkillServices, accessors, toDoService)
        {
            // Define the conversation flow using a waterfall model.
            this.AddDialog(new WaterfallDialog(Action.Greeting, new WaterfallStep[] { this.GreetingStep }));

            // Set starting dialog for component
            this.InitialDialogId = Action.Greeting;
        }