Twilio Integration

General Bytes offers the Twilio API to send SMS messages to you & OTP codes to your customers. The charges per SMS varies across geographic regions.

SPAM FILTERING:

The major phone carriers/telcos around the globe impose limits upon the frequency of SMS transmission. The carriers use equipment that has limitations; there’s no getting around this. When these limits are exceeded, the carrier will “filter” out the excess SMS traffic, and those messages will simply be discarded: lost.

You’ll typically see these “spam filtering” events occur in batches.


Create your Twilio account.

Navigate to Twilio at: https://www.twilio.com/

TWILIO USE CASE:

The designed use case for SMS messaging within CAS is for Identity Verification and Opt-in Notifications (“2FA”). We encourage you to obey these strict limitations.

Provide a valid email & phone number, and the following options:


Locate your keys:

  • Both the “ACCOUNT SID” and “AUTH TOKEN” are required.


Buy a phone number.

  • In this example, the cost is only $1/month.

  • Make sure it is SMS & Voice capable (MMS, Fax not required).

  • Per Twilio: “Toll-free verification required for US messaging. US Toll-Free numbers will not be able to send messages until the verification has been approved.”

  • Information about Twilio Toll-free verification


Assemble the required parameters:

Using a colon “:” between all 3 parameters, place them in this specific order:

SID:TOKEN:PHONE

For this example, it would look something like:

ACcc4a0a5980c47020edc81ef9a43e039b:8a108eec08d81306d4ae9e0206f:+18558101002

  • Copy & paste the entire parameter string in one paste operation.

    • CAS fields don’t append previous entries - so the entire string must be pasted each time.

  • During registration at the BATM, the Location of the BATM determines the default country code.

    • e.g. the BATM Location is in the Czech Republic, the country code will default to “+420”.

    • e.g. the BATM Location is in the United States, the country code will default to “+1”.

    • This has no bearing whatsoever on the phone number number used in the parameters (which must include the specific country code in the “from_phone_number”).


Navigate to CAS: Organization: SMS Provider

Enter the parameters from the previous step:


Save it.


Return to the setting, and test it.

  • You’ll be asked for a receiving phone number.

  • The number should be in international format, e.g. +420296399328

  • Twilio trial accounts (only), this test will not send an SMS unless:

    • the number must be pre-verified in your Twilio settings, and

    • in the US: your Twilio toll-free number is approved.

Success

If everything went as planned, you should receive a test SMS (at the supplied number) and see:


Troubleshooting

From the BASH console, you can test your Twilio settings to ensure that:

  1. the settings that you are entering are correct, and

  2. the Twilio service is working as expected, and

  3. your Twilio account is working as expected.

First, collect this information and set these from your Twilio settings:

sid=[ENTER YOUR TWILIO SID] token=[ENTER YOUR TWILIO TOKEN] from_phone_number=[ENTER YOUR TWILIO "FROM" PHONE NUMBER] test_number=[ENTER THE INTERNATIONAL-FORMATTED TEST PHONE NUMBER]

If everything is correct and functional, then this (typed in the same, active bash window) will send a text to the target phone number:

curl "https://api.twilio.com/2010-04-01/Accounts/$sid/Messages.json" -X POST --data-urlencode "To=$test_number" --data-urlencode "From=$from_phone_number" --data-urlencode 'Body=Hello from GB' -u $sid:$token

This an example result:

  • The test_number should receive the SMS if everything is working, active, and you have the correct settings. Any issue on the Twilio side will cause this to fail, resulting in an “ERROR”.

  • You should test this first when it doesn’t work in CAS. Twilio failures within CAS are extremely unlikely after they are properly setup. The more likely issue is a problem at Twilio (and the telco provider).

Copyright © 2020-2024 General Bytes USA LLC