Created
October 25, 2018 05:31
-
-
Save KevinDJones/5b955e5e57f9d41f6f04890cf590e57b 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("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