Sending a Twilio SMS
What you need to get started
You’ll need a couple of things before you can set up your Twilio action:
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 or shortcode: 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.
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.
- The right data in Customer.io: You need to make sure you’re getting the right data from your users. This is a little more complex, and is explained in detail below.
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 Email & Actions 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:
Click Continue Setup. Your Twilio phone numbers (and short codes, if you’re using them) should then appear below your credentials. If you add or change phone numbers in your Twilio account, you can re-sync here so you can use them in Customer.io.
Create your campaign
You’re finally ready to create your campaign, and start sending your 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 SMS 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” number: The number 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):
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.