private WebhookResponse ProcessWebhookRequests(WebhookRequest value) { var intentName = value.QueryResult.Intent.DisplayName; IAppRequest iRequest = null; string controllerName = ""; _commonMethods.ProcessIntends(value, intentName, ref iRequest, ref controllerName); _commonMethods.SetupAPICall(iRequest, controllerName, out RestClient clinet, out RestRequest request, Request); var responseResult = clinet.Execute <AppResponse>(request); _logger.LogInformation("Completed service request"); var response = responseResult.Data; if (response != null && response.IsResponseSuccess) { var returnMsg = response.ResponseData.ConvertAllToASCII(); returnMsg = CheckAndAddEndOfMessage(returnMsg); returnMsg = returnMsg.ConvertAllToASCII(); var simpleResponses = new Message { SimpleResponses = new SimpleResponses(), Platform = Platform.ActionsOnGoogle }; simpleResponses.SimpleResponses.SimpleResponses_.Add( new SimpleResponse { Ssml = returnMsg.ConvertToSSML() }); var returnValue = new WebhookResponse(); returnValue.FulfillmentMessages.Add(simpleResponses); return(returnValue); } _logger.LogError($"{controllerName} could not process request.\n\tDetails:"); _logger.LogError($"Input value{value.ToString()}"); _logger.LogError($"Value sent as parameter to {controllerName}:\n{iRequest}"); _logger.LogError($"Return value if any:{response}"); return(new WebhookResponse { FulfillmentText = Utility.ErrorReturnMsg() + Utility.EndOfCurrentRequest() }); }
private SkillResponse ParseIntents(SkillRequest skillRequest) { SkillResponse skillResponse = null; var intentRequest = skillRequest.Request as IntentRequest; var intentName = intentRequest.Intent.Name; IAppRequest iRequest = null; string controllerName = ""; _commonMethods.ProcessIntends(skillRequest, ref skillResponse, intentName, ref iRequest, ref controllerName); if (skillResponse != null) { skillResponse.SessionAttributes = skillRequest.Session.Attributes; return(skillResponse); } _commonMethods.SetupAPICall(iRequest, controllerName, out RestClient clinet, out RestRequest request, Request); var response = clinet.Execute <AppResponse>(request).Data; if (response != null && response.IsResponseSuccess) { var returnMsg = response.ResponseData.ConvertAllToASCII(); returnMsg = CheckAndAddEndOfMessage(returnMsg); returnMsg = returnMsg.ConvertToSSML(); var speech = new SsmlOutputSpeech { Ssml = returnMsg }; skillResponse = ResponseBuilder.Tell(speech, skillRequest.Session); skillResponse.Response.ShouldEndSession = response.ShouldEndSession; } else { _logger.LogError("Error while parsing request:"); _logger.LogError(skillRequest.ToString()); skillResponse = ErrorRequestHandler(intentName); skillResponse.SessionAttributes = skillRequest.Session.Attributes; } return(skillResponse); }