Skip to content

Instantly share code, notes, and snippets.

@gunnala-sri
Created September 5, 2019 03:35
Show Gist options
  • Save gunnala-sri/b11570bb444d773a476d6e6d3cb64be0 to your computer and use it in GitHub Desktop.
Save gunnala-sri/b11570bb444d773a476d6e6d3cb64be0 to your computer and use it in GitHub Desktop.
[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