Twilio SMS Messaging — Axway Titanium Cross-Platform Library

This guest post was authored by Adam Armstrong. Adam has been using Titanium since 2010 and is an Appcelerator Titan. He is the Manager of Mobile Technology at AmWINS Group and does freelance work via https://implicitli.com. You can follow him on Twitter at @adamtarmstrong.

I have integrated Twilio SMS Messaging for various clients over the past few years and decided it was time to wrap this up into my own library to ease portability.

For this library — I took a very simplistic approach. I added SMS Messaging and no SDK’s or additional libraries; just a basic common.js module.


Setup Twilio Account and API Key

  1. Create a free Twilio Account at https://www.twilio.com/
  2. Create an API Key at https://www.twilio.com/console/video/dev-tools/api-keys

IMPORTANT: Make note of your API Secret. After you complete the setup, the API Key can no longer be retrieved.

Download Library

Copy the /lib/ti.twilio.js file into your Axway Titanium Project under /app/lib/


Add Module and Initialize

  • AccountSID, APISID, & APISecret = All {strings} from your Twilio Account
  • timeout = {integer} to define API timeout in milliseconds
  • FROM_PhoneNumber = {string} in E.164 format of phone # to send message FROM (ie. +15005550006′)

NOTE: FROM_PhoneNumber passed in must match the API Key Environment (more details in github repo)

var twilioClient = require('ti.twilio');
twilioClient.init('AccountSID', 'APISID', 'APISecret', 'FROM_PhoneNumber', timeout);

Send SMS Message

  • Message = {string} message to send to user
  • TO_PhoneNumber = {string} in E.164 format of client phone # to send message TO (ie. +146921439389′)
  • successCallback = {function} to execute upon success
  • failureCallback = {function} to execute upon failure
twilioClient.sendSMS(Message, TO_PhoneNumber, successCallback, failureCallback);

That’s it!

This is a basic SMS Message – I plan to expand the methods over time. Code contributions are greatly appreciated!