public async Task <IActionResult> HandleDialogflowRequest([FromBody] dynamic dialogflowRequest)
        {
            var     intentName = dialogflowRequest?.queryResult?.action?.ToString();
            dynamic response   = null;

            if (intentName == "input.welcome")
            {
                response = Ask(_infoResponseService.GetWelcomeMessage());
            }
            else if (intentName.Contains("ZipCode"))
            {
                // get the zip slot
                var zipCode = dialogflowRequest?.queryResult?.parameters["zip-code"]?.ToString();

                (string responseString, string displayText) = await _infoResponseService.GetResponseAsync((string)intentName, (string)zipCode);

                response = Ask(responseString, displayText);
            }


            if (response is null)
            {
                response = Ask(_infoResponseService.GetFallbackMessage());
            }

            return(new JsonResult(response));
        }
        public async Task <SkillResponse> HandleAlexaRequest([FromBody] SkillRequest skillRequest)
        {
            if (skillRequest.GetRequestType() == typeof(LaunchRequest))
            {
                return(ResponseBuilder.Ask(_infoResponseService.GetWelcomeMessage(), null));
            }
            else if (skillRequest.GetRequestType() == typeof(IntentRequest))
            {
                var intentRequest = skillRequest.Request as IntentRequest;
                if (intentRequest.Intent.Name == "AMAZON.HelpIntent")
                {
                    return(ResponseBuilder.Ask(_infoResponseService.GetHelpMessage(), null));
                }


                if (intentRequest.Intent.Name.Contains("ZipCode"))
                {
                    var zipCode = intentRequest.Intent.Slots["ZipCode"];
                    var(response, _) = await _infoResponseService.GetResponseAsync(intentRequest.Intent.Name, zipCode.Value);

                    return(ResponseBuilder.Ask(response, null));
                }
            }

            return(ResponseBuilder.Ask(_infoResponseService.GetFallbackMessage(), null));
        }
Beispiel #3
0
        public async Task <BixbyResponse> HandleRequest(string intentName, [FromBody] BixbyRequest bixbyRequest)
        {
            BixbyResponse response = null;

            if (intentName == "input.welcome")
            {
                response = Ask(_infoResponseService.GetWelcomeMessage());
            }
            else if (intentName.Contains("ZipCode"))
            {
                (string _, string displayText) = await _infoResponseService.GetResponseAsync(intentName, bixbyRequest.ZipCode);


                response = Ask($"Here's what I found for {bixbyRequest.ZipCode}", displayText);
            }


            if (response is null)
            {
                response = Ask(_infoResponseService.GetFallbackMessage());
            }

            return(response);
        }