Implement Twilio messaging using webhooks
Sep 14, 2022
3 minutes to read
Need to improve your marketing automation workflows? You can trigger 3rd party applications as an effect for any of your promotions by creating a webhook with Talon.One.
In the Talon.One Developer Tools, developers can create webhooks to other web applications and test the implementation within your account. A webhook is an HTTP callback which is triggered by an event; for instance, sending an SMS message when a new customer registers.
This article will show you how to use the webhook feature by implementing Twilio, a communications platform for building SMS, voice and messaging applications, into a Talon.One ruleset.
1. Twilio Account Information
First, you'll need some information from your Twilio account before you implement the webhook in Talon.One.
You will need the following:
A Twilio phone number (the sent from number)
A verified recipient phone number on your Twilio account (necessary for testing).
The Twilio documentation gives a sample API command to send an SMS. This will tell us the information needed to create the Twilio webhook in Talon.One.
curl -X POST 'https://api.twilio.com/Accounts/account_SID/Messages.json' \
--data-urlencode 'To=recipient#' \
--data-urlencode 'From=twilio#' \
--data-urlencode 'Body=Message Text' \
You can execute this command to test that all your Twilio information is set up correctly.
2. Creating the Webhook in Talon.One
In the Talon.One Developer Tools, there is a setting to manage your webhooks. Here you can create your Twilio webhook.
Talon.One's Campaign Manager
You will need to add a few key things for this webhook.
First, you need to add the parameters which are the recipient's phone number, the sender's phone number, and the text of the message. From the Twilio command, you can see that these three parameters are string types.
You can also see the parameters' Content-Type is data-urlencode so this information should be added as a Header like so: Content-Type: application/x-www-form-urlencoded
The request for this webhook will be the exact same as the Twilio request, a POST to the Twilio messaging in your account.
You will also need to add an HTTP authentication header, but first you need to encode your Twilio Authorization Token.
You should encode api:$your_authorization_token as base64 and add a Header like: Authorization: Basic your_encoded_auth_token.
The last thing to add is the payload. A payload consists of the input parameters that the request contains and looks like this:
3. Add Twilio messaging to a rule and test it!
Now that the Twilio Webhook is created, you want to implement it into a Campaign and test the functionality. You can head to the Campaign where you'd like to use it and go to the Rule Builder. Here you can create your rule, for instance when a new customer registers then send an SMS message saying "Welcome new customer!"
Once you have enabled the Campaign, you can head to the API Tester in the Developer Tools to create a command to test your new rule. For our example rule, you can create a new customer profile to test it. In the webhook logs, you will see the response to the request. If an error occurred you can see the response for debugging.
If your test succeeded, congrats! Now you can use this methodology to create other webhooks in Talon.One.
Every month, I share an insights newsletter with thousands of marketers.
Content Lead at Talon.One
Wiener Strasse 10
41 Church Street
B3 2RT Birmingham
One Boston Place, Suite 2600
02108 Boston, MA
1 Scotts Road, #21-10 Shaw Centre