public async Task <IActionResult> HandleSkillRequest([FromBody] SkillRequest alexaRequest) { // Security check bool result = await CheckSecurityAsync(alexaRequest); if (!result) { return(BadRequest()); } var requestType = alexaRequest.GetRequestType(); if (requestType == typeof(IntentRequest)) { var response = await HandleIntentsAsync(alexaRequest); return(Ok(response)); } if (requestType == typeof(LaunchRequest)) { _skillResponse = _jellenWedding.GetWeddingDateCountDown(PersonType.Self); SkillResponse finalResponse = ResponseBuilder.TellWithCard(_skillResponse.Speech, "Wedding Info", _skillResponse.Message); return(Ok(finalResponse)); } return(Ok(ErrorResponse())); }
/// <summary> /// Handles different intents of the Alexa skill. /// </summary> /// <param name="alexaRequest">current skill request</param> /// <returns></returns> private async Task <SkillResponse> HandleIntentsAsync(SkillRequest alexaRequest) { if (!(alexaRequest.Request is IntentRequest intentRequest)) { return(ErrorResponse()); } // check the name to determine what you should do var intentName = intentRequest.Intent.Name; var soltName = intentRequest.Intent.Slots["Name"]; PersonType person = _jellenWedding.GetPersonType(soltName); if ((intentName.Equals(Intents.GetWeddingDateCountDownIntent) || intentName.Equals(Intents.GetMarriageDateCountIntent)) && person != PersonType.Unknown) { _skillResponse = _jellenWedding.GetWeddingDateCountDown(person); // create the response using the ResponseBuilder SkillResponse finalResponse = ResponseBuilder.TellWithCard(_skillResponse.Speech, "Wedding Info", _skillResponse.Message); return(finalResponse); } if (intentName.Equals(Intents.GetWeddingDateIntent) && person != PersonType.Unknown) { _skillResponse = _jellenWedding.GetWeddingDate(person); // create the response using the ResponseBuilder SkillResponse finalResponse = ResponseBuilder.TellWithCard(_skillResponse.Speech, "Wedding Info", _skillResponse.Message); return(finalResponse); } return(ErrorResponse()); }
public AlexaController(IConfiguration config, ISkillLogic JellenWeddingSkill) { _config = config; _jellenWedding = JellenWeddingSkill; _appid = _config.GetValue <string>("SkillApplicationId"); _skillResponse = new JellenSkillResponse(); }