Twilio SMS to Azure Table Storage

azure-logic-app

#1

Prerequisites
You need a Twilio Account and a Twilio Phone number that can send SMS messages. Both of these are available with the trial. Also you need an to set up a table in Azure Table Storage.

  1. Create a Logic App with an Http Request Trigger. Make sure POST is selected as the method to trigger the workflow. Copy the HTTP Post URL for use in Twilio
  2. Set up a webhook in Twilio. In the phone number section of Twilo. “When a Message Comes In” Webhook paste in the URL from step 1 and select HTTPPost
  3. Send a test SMS message to trigger the logic app, so we can check the output body of the run.
  4. Copy the output from the body of the run into the Request Body JSON Schema in the HTTP Request Trigger set up in Step1 changing the content type to be

“$content-type”: “application/json”

  1. Add An Insert Entity Action. I found the Azure connection and table name easy to pick. The Entity Text was harder. The graphical view does not show the complete information so I paste it below.
 {
     "inputs": {
         "host": {
             "connection": {
                 "name": "@parameters('$connections')['azuretables']['connectionId']"
             }
         },
         "method": "post",
         "path": "/Tables/@{encodeURIComponent('TableName')}/entities",
         "body": {
             "Message": "@triggerFormDataValue('Body')",
             "PartitionKey": "Twilio",
             "RowKey": "@guid()"
         },
         "authentication": "@parameters('$authentication')"
     }
 }