Twilio SMS:How To Use, Pricing and Reliability

Hiro_Ho
DeepQ Research Engineering Blog
5 min readJun 5, 2018

I want to protect user account in my application, so I choose phone verification to do it. How to send message with my application? I need SMS API survices, and Twilio is one of my survey for SMS platform. The following will introduce some Twilio SMS features.

First, register your Twilio account!

Simple Start For Twilio SMS

With Twilio SMS API, a trial account has 15.5 USD at first, and you only can send message to verified numbers. Besides, message sent in trial begin with “Sent from a Twilio Trial Account”, and you are limited to one Twilio number.

Send a simple SMS using the Programmable SMS API. For HTTP Basic authentication, you will use your Twilio account SID as your username and your auth token as your password. I selected Node.js as server-side programming language.

var accountSid = 'Your Account SID'; 
var authToken = 'Your Auth Token';
var twilio = require('twilio');
var client = new twilio(accountSid, authToken);
client.messages.create({
body: 'Text',
to: 'Text this number',
from: 'From a valid Twilio number'
}).then((message) => {console.log(message.sid));

Account SID and Auth Token can be accessed after signing up for Twilio trial account.

SMS Feature

Improve Delivery

Carrier route optimization is one of the strengths in Twilio. A unique feedback API lets Twilio monitor global routes to ensure message always take the best path. When a carrier is unable to receive messages from short codes, Twilio will reroute to standard long-code numbers automatically.

Scale as You Grow

Twilo has its own SMS queue, automatically queues and sends each message at a rate that keeps you compliant. Besides, if you buy phone numbers one more, Twilio distributes messages across a group of phone numbers to reach your entire audience quickly. For message contents, Twilio exchange messages in every language and emoji, and can set maximum price for each message.

Build and Debug Faster

Start building with all the information you need and get unstuck quickly with how-to guides, sample code, and extensive API documentation. You can program in the language you already use with helper libraries available from Twilio and its community. Besides, usage analytics allow you to see detailed usage and cost data for messages sent and received by your account over time.

example of detail about my message

SMS Pricing

If my app services for users in Taiwan, and receives from US. I have to pay 0.054 USD(whatever any telecom carrier) for sending each message, and 0.0075 USD for receiving each message.

source: https://www.twilio.com/sms/pricing/tw

Step Two: Phone Verification

Phone verification is an important, high-confidence step in a registration flow to verify that a user has the device they claim to have. Adding phone verification to my application will greatly reduce my number of fraudulent registrations and protect future application users from having their numbers registered by scammers.

Via Verify API

The Twilio Verify REST API allows me to verify that a user has a claimed device in their possession. The API lets me request a verification code to be sent to the user and to check that a received code is valid.

curl -XPOST 'https://api.authy.com/protected/json/phones/verification/start' \
-H "X-Authy-API-Key: d57d919d11e6b221c9bf6f7c882028f9" \
-d via='sms' \
-d phone_number='987-654-3210' \
-d country_code=1 \
-d code_length=6 \
-d locale='en'

Via Authy API

Once a user has been registered with my Twilio Authy application and receives an AuthyID, I can now implement 2FA, passwordless login or protect an in-application high value transaction. Using the Authy API, I can send one-time passwords over voice or SMS channels, and users can additionally use authentication application or SDK linked soft tokens.

curl -i "http://api.authy.com/protected/json/sms/234572" \
-H "X-Authy-API-Key: d57d919d11e6b221c9bf6f7c882028f9"

Verify Pricing for one user

Via Verify API

1. Request and Send verification code (0.054 USD)
2. Verify a verification code sent to user (0.05 USD)
Total: 0.104 USD

Via Authy API

1. Request and Send a one-time password (0.054 USD)                                                                                 
2. Verify a one-time password (0.09 USD)
Total: 0.144 USD

SMS API Comparison Test

The following data are sourced from Twilio SMS Comparison — 2017/06/22

Content Accuracy

When you send someone a message, you expect that same message to show up intact on the recipient’s device without errors, missing characters, or breaking into multiple messages. With over 100,000 characters representing the world’s languages and multiple variants of character encoding and concatenation by global carriers, this is not a trivial undertaking.

  • Test 1: Global Languages
  • Test 2: Currency And Characters With Encoding Conflicts
  • Test 3: Long Messages

Test Result

source: twilio SMS comparison

Deliverability

When a message doesn’t reach your customer, it can damage marketing campaigns, cause unnecessary support calls, and erode your carefully crafted communication workflow. SMS platforms must have a high degree of platform availability and be resilient against outages across hundreds of mobile carriers worldwide.

  • Test 4: Global Availability
  • Test 5: Platform Availability
  • Test 6: Phone Number Availability

Test Result

source: twilio SMS comparison

Operating At Scale

It’s critical that the SMS platform abstracts away as much development complexity as possible, eliminating the need for telecom and messaging engineering expertise. You won’t run into these issues building a proof of concept, but the workload can be massive when you go to scale, secure, and operate that solution globally.

  • Test 7: API Response
  • Test 8: Operational Usability
  • Test 9: Docs And External Resources

Test Result

source: twilio SMS comparison
source: twilio SMS comparison
source: twilio SMS comparison

Discussion

  • Which SMS platform is suitable for use in my application
  • If I use Twilio, which verification way is better for me

--

--