Handle Twilio SMS Status Call back in Azure Logic apps

In my previous post, I explained how to send SMS using Twilio connector in Azure logic app. In this post, I will describe how to capture the Twilio SMS Status call back events after we sent the SMS using Twilio and save them to the database using logic app . 


  • Azure subscription
  • A sender application to send SMS using Twilio


1) Login to Azure portal

2) Select "Create a Resource" -> Search for Logic app -> Create

3) Select subscription, resource group, Region and give logic app name -> Click on Review & Create button -> Create

4) Open the logic app once the deployment completed

5) Select Http Request response template in the Logic Apps Designer. It will create a new app with Request and Response connectors.

6) I want to capture the SMS status back to the SQL server using SQL connector. Insert new step(+ icon) after Http Trigger connector -> Add an Action -> In the search box, enter "Sql" to filter the connectors -> Select "Sql Serve" -> Under the actions list select the "Insert row (V2)"

7) Create the connection by giving the required details 

8) Once you created the connection, select the Server name, Database name, table name. Once you          selected the table name, it will show the required columns name automatically in the form. If you want other columns, you can open the "Add New Parameter" drop down and select the required columns. 

9) Here I want to capture the MessageId (Unique message Id in our system), MessageSid (Sid from Twilio), MessageStatus (Status from Twilio) from the call back data. As I am sending the MessageId as query string parameter to the call back page, I am capturing it's value by using the expression 


The main thing here is Twilio will post the data to our call back end point in application/x-www-form-urlencoded format. So I used the below expression to get the parameters posted by Twilio. We can red the form data posted to our logic app with the below expression



10) In the Response connector, just send the 200 status code back to Twilio.

11) Save the logic app. Once you saved the logic app it will generate an URL in the HTTP trigger connector.


12) Use this URL as Status call back urn while sending the Twilio SMS along with the query string value id. Below is how I used in the logic app created in my previous post.



 That's it. Now your logic app will receive the status call backs and save the response in the database.

Happy Coding 😀!


    Blogger Comment
    Facebook Comment


Post a Comment