public ResponseAttributes.DirectivesAttributes CreateDirectiveWithSolicitSlot(Request request) { var directive = new ResponseAttributes.DirectivesAttributes(); directive.SlotToElicit = "date"; directive.Type = "Dialog.ElicitSlot"; directive.UpdatedIntentAttributes.Name = request.Intent; directive.UpdatedIntentAttributes.Slots = request.Slots; return(directive); }
public AlexaResponse GetBirthdaysByDate() { AlexaResponse response = new AlexaResponse(); DateTime startDate; DateTime endDate; var userInput = _request.SlotsList.First().Value; if (userInput == null) { response.Response.OutputSpeech.Ssml = "<speak>Sorry I didn't get that. On which period or date would you like me to tell your birthdays for.</speak>"; response.Response.OutputSpeech.Type = "SSML"; response.Response.ShouldEndSession = false; ResponseAttributes.DirectivesAttributes directive = CreateDirectiveWithSolicitSlot(_request); response.Response.Directives.Add(directive); response.Response.Card.Content = "Sorry I didn't get that. On which period or date would you like me to tell your birthdays for.\n You can ask for:\n 1) a specifc date(i.e. on 5th of March);\n 2) a period like today, tomorrow, this month, next month etc..."; response.Response.Card.Title = _cardTitle + ". Examples of periods you can ask for"; return(response); } switch (userInput.Length) { // this is by month case 7: startDate = Convert.ToDateTime(_request.SlotsList.First().Value); endDate = startDate.AddMonths(1); break; // this has the week number case 8: var tempDate = FirstDateOfWeekISO8601(DateTime.Now.Year, Convert.ToInt32(userInput.Substring(6, 2))); startDate = Convert.ToDateTime(tempDate); endDate = startDate.AddDays(7); break; case 4: var year = Convert.ToInt32(_request.SlotsList.First().Value); startDate = new DateTime(year, 1, 1); endDate = startDate.AddYears(1); break; default: startDate = Convert.ToDateTime(_request.SlotsList.First().Value); endDate = startDate.AddDays(1); break; } var calendarService = new CalendarHelper(startDate, endDate, _request.Accesstoken, _request.UserId); var result = calendarService.GetBirthdays(); var birthDayResponse = BirthDayResponse(result); var cardAttributes = CreateCardContent(result); response = CalculateResponse(_request, birthDayResponse, cardAttributes); return(response); }
public ResponseAttributes.DirectivesAttributes CreateDirectiveWithSlot(Request request) { var directive = new ResponseAttributes.DirectivesAttributes { Type = "Dialog.Delegate", UpdatedIntentAttributes = { Name = request.Intent, Slots = request.Slots } }; return(directive); }