public static SkillResponse RespondToEvent(LocalEventTime meetup, LocalDate currentDate, string intro) { var pronoun = meetup.Date < currentDate ? "it was" : "it's"; var humanDate = Humanizer.DateHumanizeExtensions.Humanize( meetup.Date.ToDateTimeUnspecified().ToUniversalTime(), currentDate.ToDateTimeUnspecified().ToUniversalTime()); var starter = new Sentence(); starter.Elements.Add(new PlainText($"{intro}, {pronoun} {humanDate}, {meetup.Date.ToDateTimeUnspecified().ToString("dddd dd MMM")}, and is titled {meetup.Event.Name}")); var speech = new Speech(starter); speech.Elements.Add(new Break { Strength = BreakStrength.Medium }); speech.Elements.Add(new Paragraph(new Sentence("Can I help with anything else?"))); return(ResponseBuilder.Ask(speech, null)); }
public static async Task <SkillResponse> SingleEventResponse(APLSkillRequest request, LocalEventTime eventToRecognise, LocalDate currentDate, Group groupData, string intro) { var response = SpeechHelper.RespondToEvent(eventToRecognise, currentDate, intro); if (request.Context.System.Device.IsInterfaceSupported(Consts.APLInterface)) { var dateDisplay = $"{eventToRecognise.Date.ToDateTimeUnspecified():MMMM dd yyyy}, {eventToRecognise.Event.LocalTime}"; var dataSource = new KeyValueDataSource { Properties = new Dictionary <string, object> { { "backgroundUrl", groupData.KeyPhoto?.HighRes ?? groupData.GroupPhoto?.HighRes }, { "groupName", groupData.Name }, { "eventDate", dateDisplay }, { "eventTitle", eventToRecognise.Event.Name } } }; var filename = request.APLInterfaceDetails().Runtime.MaxVersion == APLDocumentVersion.V1 ? "assets/NextEvent.json" : "assets/NextEvent2.json"; var document = await S3Helper.GetDocument(System.Environment.GetEnvironmentVariable("bucket"), filename); document.AddResponsiveDesign(); response.Response.Directives.Add(new RenderDocumentDirective { DataSources = new Dictionary <string, APLDataSource> { { "eventData", dataSource } }, Document = document, Token = eventToRecognise.Event.Id }); } return(response); }