Example #1
0
        /// <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());
        }