Using Webhooks to Collect SMS Data

Using Webhooks to Collect inbound and outbound SMS Data

In this guide we will cover the use of "Webhook URLs" to capture/store and or take action on inbound and outbound SMS data.

Firstly, we will cover the Inbound portion of this. To capture inbound data such as relating to Inbound SMS replies you will want to utilize each numbers unique "SMS Request URLs". These URLs are accessible via the 'Manage Numbers' page found in the 'Numbers' tab on your API portal dashboard. Once inside the 'Manage Numbers' page you will 'Edit' the relevant phone number, navigate to either the Voice or SMS Tab for the respective Webhook URLs ( SMS Request URL to capture SMS data and Voice Request URL for voice ). 

Now that you are in the SMS Tab you should see two empty fields "SMS Request URL" and "Fallback SMS Request URL". Both URLs serve the same purpose except 1 is the Primary URL whereas the other is the Secondary or 'Fallback' url that will be used if the first one fails. 

In this field you can put whatever URL you wish. Essentially, when the number receives an inbound SMS the API will POST/GET post specific information regarding the SMS to your specified endpoint. The POST itself will look something like - 

To: +19793302841
Price: 0.0075
Time: 2018-08-28 21:23:32
Method: POST
DateSent: 2018-08-28 21:23:32
MessageSid: 9d3ed970-a08-11e8-9936-413fe38766e4
From: +19498423767
Text: Testing Inbound
Action: <>
Status: success

These post fields and their parameters are what your desired endpoint will have to work with and 'digest' either for a follow up API call or simply to assign to columns and rows inside of your database.

Lastly, We will touch on Outbound SMS data capture. The mechanism is the same however the location its set is different. To capture Outbound SMS data you will utilize the MessageStatusCallback URL in your outbound SMS API requests themselves. The MessageStatusCallback URL is posted to as the SMS progresses from Queued status into either Failed or Success. Using this allows you to Database not only the original Inqueue status response but also the update as the SMS moves to either success or failure, allowing you keep an up-to-date realtime database for your SMS.

Did this page help you?