Skip to content

Instantly share code, notes, and snippets.

@KevinDJones
Created October 25, 2018 05:31
Show Gist options
  • Save KevinDJones/5b955e5e57f9d41f6f04890cf590e57b to your computer and use it in GitHub Desktop.
Save KevinDJones/5b955e5e57f9d41f6f04890cf590e57b to your computer and use it in GitHub Desktop.
[FunctionName("TwilioHandler")]
public static async Task<HttpResponseMessage> Webhook(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "TwilioHandler/{id}")]
HttpRequestMessage req,
[OrchestrationClient] DurableOrchestrationClient client,
[Table(MessageMapping.TableName, "Sms", "{id}")] MessageMapping mapping,
ILogger log)
{
var content = await req.Content.ReadAsStringAsync();
var formBody = ParseForm(content);
var status = formBody["SmsStatus"];
if (status == "delivered" || status == "failed")
{
await client.RaiseEventAsync(mapping.OrchestrationId, "TwilioCallback", status);
}
var response = req.CreateResponse(HttpStatusCode.OK);
response.Content = new StringContent("OK", Encoding.UTF8, "text/xml");
return response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment