Implement Twilio Messaging Using Webhooks

Feb 9, 2018
Chin Man Yeung
Software Engineer
Min 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:

  • Account SID
  • Authorization Token
  • 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 '' \
--data-urlencode 'To=recipient#' \
--data-urlencode 'From=twilio#' \
--data-urlencode 'Body=Message Text' \
-u account_SID:authorization_token

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:

To: ${$To},
From: ${$From},
Body: ${$Body}

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.

To learn more, check out our integration guides or tutorials in our developer documentation. If you want a more in-depth look at Talon.One, we can schedule a live demo, just get in touch.

content LiBRARY
Download Your Talon.One Loyalty Playbook
Best Practices for loyalty programs
How to gain a competitive advantage
Your definitive guide to loyal customers
Get Your Free Playbook
Most relevant articles
Download Your Talon.One Loyalty Playbook
Best Practices for loyalty programs
How to gain a competitive advantage
Your definitive guide to loyal customers