コード例 #1
0
ファイル: CheckLUISDialog.cs プロジェクト: ystvan/chatbot101
        /// <summary>
        /// Creates random meeting slots for supervision
        /// </summary>
        /// <param name="searchQuery">The search-query</param>
        /// <returns>A List of random objects of type Meeting</returns>
        private async Task <IEnumerable <Meeting> > GetMeetingsAsync(MeetingsQuery searchQuery)
        {
            var meetings = new List <Meeting>();

            //some random result manually for demo purposes
            for (int i = 1; i <= 5; i++)
            {
                var     random  = new Random(i);
                Meeting meeting = new Meeting()
                {
                    DateTime = $" Available time: {searchQuery.Date} At building {i}",
                    Teacher  = $" Professor {searchQuery.Name.ToUpperInvariant()}",
                    Location = $" Elisagårdsvej 3, Room {random.Next(1, 300)}",
                    Image    = $"https://placeholdit.imgix.net/~text?txtsize=35&txt=Supervision+{i}&w=500&h=260"
                };

                meetings.Add(meeting);
            }

            return(meetings);
        }
コード例 #2
0
ファイル: CheckLUISDialog.cs プロジェクト: ystvan/chatbot101
        public async Task BookAppointment(IDialogContext context, IAwaitable <IMessageActivity> activity, LuisResult result)
        {
            var message = await activity;
            await context.PostAsync($"I am analysing your message: '{message.Text}'...");

            var meetingsQuery = new MeetingsQuery();

            EntityRecommendation teacherEntityRecommendation;
            EntityRecommendation dateEntityRecommendation;

            if (result.TryFindEntity(EntityTeacher, out teacherEntityRecommendation))
            {
                teacherEntityRecommendation.Type = "Name";
            }
            if (result.TryFindEntity(EntityMeetingDate, out dateEntityRecommendation))
            {
                dateEntityRecommendation.Type = "Date";
            }

            var meetingsFormDialog = new FormDialog <MeetingsQuery>(meetingsQuery, this.BuildMeetingsForm, FormOptions.PromptInStart, result.Entities);

            context.Call(meetingsFormDialog, this.ResumeAfterMeetingsFormDialog);
        }