Ejemplo n.º 1
0
        public async Task Reminder(IDialogContext context, LuisResult result)
        {
            string   eventName = result.GetSimpleEntityValue("Event");
            string   time      = result.GetComplexEntityValue("builtin.datetimeV2.time");
            string   datetime  = result.GetComplexEntityValue("builtin.datetimeV2.datetime");
            DateTime?moment    = InterpretDateTime(datetime) ?? InterpretTime(time);

            if (eventName == null || moment == null)
            {
                await context.PostAsync($"I think you want me to remind you of something, but I can't tell what.");
            }
            else
            {
                var delay = moment.Value.Subtract(DateTime.Now);
                await context.PostAsync($"OK. I'll remind you of {eventName} in about {Math.Round(delay.TotalMinutes)} minutes.");

                new Reminder(delay, eventName, context.Activity.ToConversationReference()).Start();
            }
            context.Wait(MessageReceived);
        }