private static SkillResponse BuildResponse(IOutputSpeech outputSpeech, bool shouldEndSession, Session sessionAttributes, Reprompt reprompt, ICard card) { SkillResponse response = new Response.SkillResponse(); response.Version = "1.0"; if (sessionAttributes != null) { response.SessionAttributes = sessionAttributes.Attributes; } ResponseBody body = new Response.ResponseBody(); body.ShouldEndSession = shouldEndSession; body.OutputSpeech = outputSpeech; if (reprompt != null) { body.Reprompt = reprompt; } if (card != null) { body.Card = card; } response.Response = body; return(response); }
public SkillResponse FunctionHandler(SkillRequest input, ILambdaContext context) { // your function logic goes here // check what type of a request it is like an IntentRequest or a LaunchRequest var requestType = input.GetRequestType(); if (requestType == typeof(IntentRequest)) { var intentRequest = input.Request as IntentRequest; var responseBodyIntent = new Alexa.NET.Response.ResponseBody(); var speechIntent = new Alexa.NET.Response.PlainTextOutputSpeech(); var skillResponseIntent = new Alexa.NET.Response.SkillResponse(); // check the name to determine what you should do if (intentRequest.Intent.Name.Equals("umbracoRootknoten")) { var informationsIntent = GetUmbracoRootNode().Result.Replace("\"", ""); speechIntent.Text = informationsIntent; // create the response responseBodyIntent.OutputSpeech = speechIntent; responseBodyIntent.ShouldEndSession = true; // this triggers the reprompt skillResponseIntent.Response = responseBodyIntent; skillResponseIntent.Version = "1.0"; return(skillResponseIntent); } if (intentRequest.Intent.Name.Equals("erstelleUmbracoRootknoten")) { var number = intentRequest.Intent.Slots["rootknotenalias"].Value; if (number != null) { var informationsIntent = CreateNode(number).Result.Replace("\"", ""); speechIntent.Text = informationsIntent; responseBodyIntent.OutputSpeech = speechIntent; responseBodyIntent.ShouldEndSession = true; // this triggers the reprompt skillResponseIntent.Response = responseBodyIntent; skillResponseIntent.Version = "1.0"; return(skillResponseIntent); } speechIntent.Text = "Ungültig Eingabe Sie Vollidiot!"; responseBodyIntent.OutputSpeech = speechIntent; responseBodyIntent.ShouldEndSession = true; // this triggers the reprompt skillResponseIntent.Response = responseBodyIntent; skillResponseIntent.Version = "1.0"; return(skillResponseIntent); } } else if (requestType == typeof(Alexa.NET.Request.Type.LaunchRequest)) { // default launch path executed } else if (requestType == typeof(AudioPlayerRequest)) { // do some audio response stuff } var speech = new Alexa.NET.Response.PlainTextOutputSpeech(); var informations = GetUmbracoString().Result.Replace("\"", ""); speech.Text = informations; // create the response var responseBody = new Alexa.NET.Response.ResponseBody(); responseBody.OutputSpeech = speech; responseBody.ShouldEndSession = true; // this triggers the reprompt var skillResponse = new Alexa.NET.Response.SkillResponse(); skillResponse.Response = responseBody; skillResponse.Version = "1.0"; return(skillResponse); }