Twilio SMS - Getting Started
Use Twilio to send SMS to your customers as part of your triggered campaigns, either with
Getting started with Twilio
You'll need a couple of things before you can enable Twilio in Customer.io:
A Twilio account: If you don't have one, you can sign up on Twilio.com. We recommend using a trial account to get started.
A Twilio-specific phone number, shortcode or an alphanumeric id: You can't use your own phone number to send SMS; you need to purchase a number from Twilio. You can do so from your account page. If you already have a Twilio-specific number, make sure to have it at hand when you're composing your message later.
Similarly, if you're in the US, Canada, or the UK, you can use a short code: a 5- or 6-digit number that can send and receive SMS/MMS. They need to be leased, and Twilio can do so for you; you can read more on Twilio's documentation page.
Alternatively, if you have a paid Twilio account with Alphanumeric Sending enabled, you can send using an Alphanumeric ID in Customer.io instead of a Twilio phone number.
An Account SID and Auth Token: You can see these on your Twilio dashboard:
Note: You might also see a set of test credentials for Twilio in your account page. To send SMS with Customer.io, you'll need to use the Live credentials, not Test.
Configure your user data in Customer.io
To make sure that you can reach your customers via SMS, you'll need to make sure that you have the right data in Customer.io.
Most importantly, you will need to store a phone number for customers (for example, an attribute called
phone). Ideally, this number will be formatted in E.164 format. This is very important. If it's not used, the likelihood that your message will be sent is lower, because Twilio has to try and detect the number format, and that detection may not always be successful.
What is E.164 format?
E.164 is the internationally-standardized format for all phone numbers. If your number is in this format, you can be that much more certain that it will reach your end user. E.164 numbers can have a maximum of fifteen digits and are usually written as follows:
[+][country code][subscriber number including area code]
Here are a few examples:
|USA||415 555 2671||+14155552671|
|UK||020 7183 8750||+442071838750|
|China||021 6309 5246||+862163095246|
|Australia||(08) 9287 8230||+61892878230|
Example user with a phone attribute
Note that the phone number is E.164 formatted!
Enabling Twilio in Customer.io
From your workspace dashboard, head to Message Settings in the left panel, and click 'Get Started' next to Twilio:
What you'll need is your Account SID and Authorization Token — as we mentioned, you can get these on your account page in Twilio. Copy and paste them into the fields in Customer.io, and click Test and Save:
Syncing Phone Numbers
Once you successfully enable Twilio, you'll see your synced phone numbers (and short codes, if you're using them) below your credentials. If you add or change phone numbers in your Twilio account, re-sync here so you can use them in Customer.io.
Using Alphanumeric IDs
You'll also see Alphanumeric IDs in your Twilio Settings.
These allow you to send one-way messages from a brand name (e.g., CUSTOMERIO) rather than a phone number. A few important things things to keep in mind:
- Enable the feature in Twilio first! You can add these in Customer.io, but if you haven't enabled it in your Twilio project settings, the message will fail.
- They're one-way: Your customers cannot reply to them.
- Opt-in/opt-out: Customers receiving these should have opted in to your service and be informed on how to opt out.
- They're not supported in all countries, including the USA: If you try to send to an unsupported country from an Alphanumeric Sender ID, your SMS will fail to send. Note that some require sender ID pre-registration with Twilio.
Adding an Alphanumeric ID in Customer.io
Adding one of these is simple: tell us the ID you want to use, and choose a name (how you refer to it internally; your customers won't see this) and save. You can use both upper- and lower-case ASCII letters, the digits 0 through 9, and space. It can't be only numbers.
If you need it, Twilio have documentation on how to activate this feature.
Adding Twilio messages to your campaign
Once you have your Twilio enabled, you can start sending SMS messages! First, create a campaign in Customer.io that will trigger sending an SMS. Here, we’re using an event triggered campaign with
invoice_overdue as the trigger. So, once a customer's invoice is overdue, we want to send them an SMS that lets them know:
Add your Twilio action to the workflow
Next, add your Twilio SMS to the campaign by clicking the Add workflow item button:
And choose Twilio SMS:
Give it a name which makes sense to you— your end-user won't see this. Then, click Add Twilio SMS. In our case, we're using "Invoice overdue SMS notification," in line with our event for this campaign. That way, we know what the SMS does when we see it in our Campaign Overview:
Next, click Add Content to open the SMS composer and set up your message.
Compose your Twilio SMS
Finally, it's time to write your SMS. In the Customer.io composer, it consists of three parts:
- The "From" field: The number, shortcode, or Alphanumeric ID you're using to send the message
- The "To" number: The number that the message is headed to; your user's number
- The message body: This is where your message's content goes.
Note: You can use Liquid here to send to your customer’s phone number, or to address them personally, if you'd like. Just make sure you have the right attributes for that user. You can see this in action in our example below, or click here to learn more about Liquid in Customer.io.
At this point, your SMS composer should look something like this (you can hit Preview to see what your SMS looks like):
If you use Alphanumeric ID here, remember that you must have the feature enabled in your Twilio settings, and users cannot reply to it: it's one-way only!
Send test request
To make sure your SMS works, you can send a test message by entering a phone number in the test box (shown in the screenshot below), and clicking "Send Test”. This will send a real SMS, so make sure you're sending the test to yourself (or a test account)!
Once sent, Customer.io will show you the response from Twilio, and you should see Test sent.
The SMS should then appear on your phone (or whichever number you chose to send it to)! We have a separate guide for tracking your sent Twilio messages.