Setting Up SMS Account Verification with Twilio

As a part of the verification during signup procedure, SMS account activation is designed to prevent fake signups and, simultaneously, to encourage real users for upgrading their accounts to billing instead of creating another trial one after the provided free trial period has expired.

Note: SMS verification becomes operable only in case the mandatory account activation is already enabled, so make sure you’ve performed the necessary configurations beforehand.

In order to have an opportunity to use this activation type, you are required to preliminary set up the appropriate messaging tool, intended to automatically send authorization SMS notifications. As an example for this guide, we’ll use Twilio (however, you can configure any other preferred service in a similar way). It provides a number of features, like using custom name as sender ID instead of the phone number, support of non-English character sets, tracking message status in real-time, etc.

So, to accomplish the required configurations for enabling the additional SMS verification during signup, you’ll need to perform the following steps:

Purchase a Phone Number

1. First of all, navigate to the Twilio website and either Sign up for a new account or just Log in (if you already have one) with the appropriate button.

2. Once inside the administration panel, switch to the Numbers > Twilio Numbers section using the top pane and click the Buy a number button at the right part of the page.

3. Now, you need to specify the required search options to find a phone number that will satisfy your needs:

  • Country - select the preferred region
  • Number/Location - enter the appropriate search parameters if required (e.g. specific digits or area code) or leave this field blank. Herewith, search over Location is available for US and Canada only.
  • Capabilities - obligatory tick the SMS option

When all the options are defined, select Search to output the list of 10 suitable numbers.

4. Click the Buy button next to the preferred number.

Note that depending on a type and country the chosen number belongs to, it may allow the domestic SMS distribution only, while we recommend to choose the one with the global SMS sending possibility in order not to limitate the expansion of your target audience.

This feature availability can be checked within the Global SMS Enabled column in the SMS Enabled Phone Numbers table at the corresponding Twilio’s help page.

5. Within the appeared pop-up window, review the number parameters and click the Buy This Number button to confirm the purchase.

In a moment this phone number will appear at your Manage Numbers list.

Configure Script

Now, you need to adjust a dedicated Jelastic script, which is responsible for sending the appropriate SMS messages to the newly registered users, with the acquired number and your messaging tool credentials.

Note: By default, our script is configured to work with the above mentioned Twilio tool, thus, if using any other SMS sending service, you’ll need to adjust or rewrite this script at first.

1. Enter the 104 container of your hardware node via SSH and open the sendsms script, located at /home/hivext/scripts, for editing. To make it to work properly, adjust the lines within the CHANGE THIS PARAMETERS section with your Twilio data, namely:




  • {phone_number} - the previously purchased number; can be found within the Numbers > Twilio Numbers section
  • {Twilio_SID} - your Twilio account security identifier from the Account > Account Settings > API Credentials > AccountSID frame (circled below)

  • {Twilio_token} - security authentication token, located under the previously specified SID (to see its value, click on the padlock button to the left)

After the above mentioned parameters are specified, don’t forget to save the changes, applied to the script.

2. In order to check everything is configured properly, you can execute this script manually, right from the container:

/home/hivext/scripts/sendsms -n {phone_number} -c {activation_code} -l {language}

Here, the highlighted parameters should be substituted with the following values:

  • -n {phone_number} - mobile phone number the SMS should be sent to
  • -c {activation_code} - the preferred activation code of 4 digits (for example 4545)
  • -l {language} - SMS notification language, stated with the ISO 639-1 format (herewith, the exact message text for every used language is defined within the script’s GRETINGS_lang parameter)

In response to this, a JSON object with the result property will be received.

The result should be equal to 0 (as underlined above) - this means that SMS has been sent successfully, so you can make sure it matches the inputted properties. Otherwise, you need to recheck the settings within your sendsms script for being specified properly.

If everything is OK here, you can navigate to the JCA panel to enable SMS verification and configure its parameters at Jelastic side.