public SkillResponse Prescreen(SkillRequest alexaRequestInput) { AlexaRequestValidationService validator = new AlexaRequestValidationService(); SpeechletRequestValidationResult validationResult = validator.ValidateAlexaRequest(alexaRequestInput); if (validationResult != SpeechletRequestValidationResult.OK) { logger.Debug("validation error: " + validationResult.ToString()); new Exception("Invalid Request"); } SkillResponse response = new SkillResponse(); response.Version = "1.0"; // logger.Debug("Request:" + JsonConvert.SerializeObject(alexaRequestInput.Request)); switch (alexaRequestInput.Request.Type) { case "LaunchRequest": // logger.Debug("Launch request in"); response.Response = new ResponseBody(); response.Response.Card = new SimpleCard() { // Content = "Hello! Enjoy your game while I keep the scores. You can tell me to start a game or ask for the score of your current game.", Content = "Hello!! Welcome to Childcare pre-screening! Please note: This is a demo skill to demonstrate voice driven pre-screening process. Outcomes have no real world significance.", Title = "Welcome!!" }; response.Response.OutputSpeech = new PlainTextOutputSpeech() { Text = "Hello!! welcome to Childcare pre-screening! You can now say, check my eligibility" }; response.Response.ShouldEndSession = false; // logger.Debug("Launch request out"); break; case "SessionEndedRequest": response.Response = new ResponseBody(); response.Response.Card = new SimpleCard() { // Content = "Hello! Enjoy your game while I keep the scores. You can tell me to start a game or ask for the score of your current game.", Content = "Goodbye, have a good day!", Title = "Welcome!!" }; response.Response.OutputSpeech = new PlainTextOutputSpeech() { Text = "Goodbye, have a good day!" }; response.Response.ShouldEndSession = true; return(response); case "IntentRequest": try { CaseInfo caseInfo = Helpers.GetCaseInfo(alexaRequestInput.Session.SessionId); IntentRequest intentRequest = (IntentRequest)alexaRequestInput.Request; if (intentRequest.Intent.Name == "PreScreen") { UpdateModel(caseInfo, intentRequest.Intent); string slot = GetNextSlot(caseInfo); ResponseBody body = GetResponseForSlot(slot, caseInfo.ChildName); caseInfo.LastAskedSlot = slot; response.Response = body; if (body.ShouldEndSession == true) { Helpers.RemoveCaseInfo(alexaRequestInput.Session.SessionId); } } if (intentRequest.Intent.Name == "AMAZON.StopIntent") { var stophandler = new AMAZON_StopIntent(); var skillresponse = stophandler.HandleIntent(null, null, null, null, logger); skillresponse.Version = "1.0"; return(skillresponse); } if (intentRequest.Intent.Name == "AMAZON.FallbackIntent") { var fallbackhandler = new AMAZON_FallbackIntent(); var fallbackresponse = fallbackhandler.HandleIntent(null, null, null, null, logger); fallbackresponse.Version = "1.0"; return(fallbackresponse); } if (intentRequest.Intent.Name == "AMAZON.CancelIntent") { var cancelhandler = new AMAZON_CancelIntent(); var cancellresponse = cancelhandler.HandleIntent(null, null, null, null, logger); cancellresponse.Version = "1.0"; return(cancellresponse); } if (intentRequest.Intent.Name == "AMAZON.HelpIntent") { var helphandler = new AMAZON_HelpIntent(); var helplresponse = helphandler.HandleIntent(null, null, null, null, logger); helplresponse.Version = "1.0"; helplresponse.Response.ShouldEndSession = false; return(helplresponse); } break; }catch (Exception e) { response.Response = Helpers.GetPlainTextResponseBody("Aaargh, the application encountered an error. Please try again later. Sorry for the inconvenience", true, "Error", e.Message); response.Response.ShouldEndSession = true; logger.Debug(e.StackTrace); } break; } // logger.Debug("Response:" + JsonConvert.SerializeObject(response.Response)); response.Response.Reprompt = new Reprompt("Sorry, I didn't hear you, can you repeat that?"); return(response); }
public SkillResponse HandleResponse(SkillRequest alexaRequestInput) { AlexaRequestValidationService validator = new AlexaRequestValidationService(); SpeechletRequestValidationResult validationResult = validator.ValidateAlexaRequest(alexaRequestInput); if (validationResult != SpeechletRequestValidationResult.OK) { logger.Debug("validation error: " + validationResult.ToString()); new Exception("Invalid Request"); } SkillResponse response = new SkillResponse(); response.Version = "1.0"; logger.Debug("Request:" + JsonConvert.SerializeObject(alexaRequestInput.Request)); CaseInfo caseInfo = Helpers.GetCaseInfo(alexaRequestInput.Context.System.User.UserId); if (caseInfo.profile == null) { caseInfo.profile = Helpers.GetUserProfile(alexaRequestInput); } switch (alexaRequestInput.Request.Type) { case "LaunchRequest": logger.Debug("Launch request in"); response.Response = new ResponseBody(); response.Response.Card = new SimpleCard() { Content = "Hello " + caseInfo.profile.name + ". Welcome to your Benefind dashboard. Say: \"Check case summary\", \"Check my pending documents\" or \"Schedule an appointment\"", Title = "Benifind Dashboard" }; response.Response.OutputSpeech = new PlainTextOutputSpeech() { Text = "Hello " + caseInfo.profile.name + ". Welcome to your Beni-find dashboard. You don't have any new notifications. You can now say, Check case summary, or Check my pending documents, Or say Schedule an appointment \"" }; //response.Response.OutputSpeech = new PlainTextOutputSpeech() { Text = "Hello!! say, \"I am ready!\"" }; response.Response.ShouldEndSession = false; logger.Debug("Launch request out"); break; case "SessionEndedRequest": response.Response = new ResponseBody(); response.Response.Card = new SimpleCard() { Content = "Goodbye, have a good day!", Title = "Welcome!!" }; response.Response.OutputSpeech = new PlainTextOutputSpeech() { Text = "Goodbye, have a good day!" }; response.Response.ShouldEndSession = true; return(response); case "IntentRequest": try { IntentRequest intentRequest = (IntentRequest)(alexaRequestInput.Request); if (intentRequest.Intent.Name == "casesummary") { string text = "Hello <Name>, I see your SNAP case is active and ongoing. The SNAP case will be up for renewal for March 31st 2019. Your child care case is pending for an RFI. Please say \"Check my RFI\" to know more."; response.Response = Helpers.GetPlainTextResponseBody(text.Replace("<Name>", caseInfo.profile.name), true, "Case Summary"); response.Response.ShouldEndSession = false;; } if (intentRequest.Intent.Name == "rfi") { string text = "Hello <Name>, you have a household composition RFI, due by January 31st 2019. You can upload documents on our self service portal or return documents to our offices. P.A.F.S 76 is a supported document for this RFI."; response.Response = Helpers.GetPlainTextResponseBody(text.Replace("<Name>", caseInfo.profile.name), true, "RFI Details"); response.Response.ShouldEndSession = false;; } if (intentRequest.Intent.Name == "schedule") { string text = ""; if (intentRequest.Intent.ConfirmationStatus == "CONFIRMED") { var date = intentRequest.Intent.Slots["date"].Value; var time = intentRequest.Intent.Slots["time"].Value; text = "All set, your appointment is scheduled for the selected time. I have also sent you this information on your email."; Helpers.SendEmailAsync(caseInfo.profile.email, caseInfo.profile.name, date, time); } else { text = "Ok, Roger that!! Request cancelled!"; } response.Response = Helpers.GetPlainTextResponseBody(text.Replace("<Name>", caseInfo.profile.name), true, "Appointments"); response.Response.ShouldEndSession = true;; } if (intentRequest.Intent.Name == "AMAZON.StopIntent") { var stophandler = new AMAZON_StopIntent(); var skillresponse = stophandler.HandleIntent(null, null, null, null, logger); skillresponse.Version = "1.0"; return(skillresponse); } if (intentRequest.Intent.Name == "AMAZON.FallbackIntent") { var fallbackhandler = new AMAZON_FallbackIntent(); var fallbackresponse = fallbackhandler.HandleIntent(null, null, null, null, logger); fallbackresponse.Version = "1.0"; return(fallbackresponse); } if (intentRequest.Intent.Name == "AMAZON.CancelIntent") { var cancelhandler = new AMAZON_CancelIntent(); var cancellresponse = cancelhandler.HandleIntent(null, null, null, null, logger); cancellresponse.Version = "1.0"; return(cancellresponse); } //if (intentRequest.Intent.Name == "AMAZON.HelpIntent") //{ // var helphandler = new AMAZON_HelpIntent(); // var helplresponse = helphandler.HandleIntent(null, null, null, null, logger); // helplresponse.Version = "1.0"; // helplresponse.Response.ShouldEndSession = false; // return helplresponse; //} break; } catch (Exception e) { response.Response = Helpers.GetPlainTextResponseBody("Aaargh, the application encountered an error. Please try again later. Sorry for the inconvenience", true, "Error", e.Message); response.Response.ShouldEndSession = true; logger.Debug(e.StackTrace); } break; } logger.Debug("Response:" + JsonConvert.SerializeObject(response.Response)); return(response); }
public SkillResponse Prescreen(SkillRequest alexaRequestInput) { AlexaRequestValidationService validator = new AlexaRequestValidationService(); SpeechletRequestValidationResult validationResult = validator.ValidateAlexaRequest(alexaRequestInput); if (validationResult != SpeechletRequestValidationResult.OK) { logger.Debug("validation error: " + validationResult.ToString()); new Exception("Invalid Request"); } SkillResponse response = new SkillResponse(); response.Version = "1.0"; logger.Debug("Request:" + JsonConvert.SerializeObject(alexaRequestInput.Request)); switch (alexaRequestInput.Request.Type) { case "LaunchRequest": // logger.Debug("Launch request in"); response.Response = new ResponseBody(); response.Response.Card = new SimpleCard() { Content = "Hello!! Welcome to the Kentucky Health eligibility finder! Lets answer a few questions together to see the benefits you could have through the Kentucky HEALTH program. Say \"I am ready\" when ready to start.", Title = "Welcome!!" }; response.Response.OutputSpeech = new PlainTextOutputSpeech() { Text = "Hello!! Welcome to Kentucky Health eligibility finder! Lets answer a few questions together and see what types of requirements and benefits you may have through the Kentucky HEALTH program. When ready, say, \"I am ready!\"" }; //response.Response.OutputSpeech = new PlainTextOutputSpeech() { Text = "Hello!! say, \"I am ready!\"" }; response.Response.Reprompt = new Reprompt("Please say, I am ready."); response.Response.ShouldEndSession = false; // logger.Debug("Launch request out"); break; case "SessionEndedRequest": response.Response = new ResponseBody(); response.Response.Card = new SimpleCard() { Content = "Goodbye, have a good day!", Title = "Welcome!!" }; response.Response.OutputSpeech = new PlainTextOutputSpeech() { Text = "Goodbye, have a good day!" }; response.Response.ShouldEndSession = true; return(response); case "IntentRequest": try { CaseInfo caseInfo = Helpers.GetCaseInfo(alexaRequestInput.Session.SessionId); IntentRequest intentRequest = (IntentRequest)alexaRequestInput.Request; //if (intentRequest.Intent.Name == "repeat") //{ // response.Response = GetResponseForSlot(caseInfo.LastAskedSlot, caseInfo.ChildName, caseInfo.EligibilityGroup); // response.Version = "1.0"; // response.Response.ShouldEndSession = false; //} if (intentRequest.Intent.Name == "PreScreen") { UpdateModel(caseInfo, intentRequest.Intent); string slot = GetNextSlot(caseInfo); ResponseBody body = GetResponseForSlot(slot, caseInfo.ChildName, caseInfo.EligibilityGroup); if (slot.Contains("EG_")) { caseInfo.EligibilityGroup = slot; slot = "conclude"; } caseInfo.LastAskedSlot = slot; response.Response = body; if (body.ShouldEndSession == true) { Helpers.RemoveCaseInfo(alexaRequestInput.Session.SessionId); } } if (intentRequest.Intent.Name == "AMAZON.StopIntent") { var stophandler = new AMAZON_StopIntent(); var skillresponse = stophandler.HandleIntent(null, null, null, null, logger); skillresponse.Version = "1.0"; return(skillresponse); } if (intentRequest.Intent.Name == "AMAZON.FallbackIntent") { var fallbackhandler = new AMAZON_FallbackIntent(); var fallbackresponse = fallbackhandler.HandleIntent(null, null, null, null, logger); fallbackresponse.Version = "1.0"; return(fallbackresponse); } if (intentRequest.Intent.Name == "AMAZON.CancelIntent") { var cancelhandler = new AMAZON_CancelIntent(); var cancellresponse = cancelhandler.HandleIntent(null, null, null, null, logger); cancellresponse.Version = "1.0"; return(cancellresponse); } //if (intentRequest.Intent.Name == "AMAZON.HelpIntent") //{ // var helphandler = new AMAZON_HelpIntent(); // var helplresponse = helphandler.HandleIntent(null, null, null, null, logger); // helplresponse.Version = "1.0"; // helplresponse.Response.ShouldEndSession = false; // return helplresponse; //} break; } catch (Exception e) { response.Response = Helpers.GetPlainTextResponseBody("Aaargh, the application encountered an error. Please try again later. Sorry for the inconvenience", true, "Error", e.Message); response.Response.ShouldEndSession = true; logger.Debug(e.StackTrace); } break; } logger.Debug("Response:" + JsonConvert.SerializeObject(response.Response)); return(response); }