Created
September 5, 2019 03:35
-
-
Save gunnala-sri/b11570bb444d773a476d6e6d3cb64be0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[FunctionName("dot-net-skill")] | |
public static async Task<IActionResult> Run( | |
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, | |
ILogger log) | |
{ | |
string json = await req.ReadAsStringAsync(); | |
var skillRequest = JsonConvert.DeserializeObject<SkillRequest>(json); | |
return ProcessRequest(skillRequest); | |
} | |
private static IActionResult ProcessRequest(SkillRequest skillRequest) | |
{ | |
var requestType = skillRequest.GetRequestType(); | |
SkillResponse response = null; | |
if (requestType == typeof(LaunchRequest)) | |
{ | |
response = ResponseBuilder.Tell("Welcome to dot net!"); | |
response.Response.ShouldEndSession = false; | |
} | |
else if (requestType == typeof(IntentRequest)) | |
{ | |
var intentRequest = skillRequest.Request as IntentRequest; | |
if (intentRequest.Intent.Name == "Hello") | |
{ | |
response = ResponseBuilder.Tell("Hi dot net Skill!"); | |
response.Response.ShouldEndSession = false; | |
} | |
} | |
else if (requestType == typeof(SessionEndedRequest)) | |
{ | |
response = ResponseBuilder.Tell("See you next time!"); | |
response.Response.ShouldEndSession = true; | |
} | |
return new OkObjectResult(response); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment