ThingWorx Extensibility > Extensions > Twilio
  
Twilio
The ThingWorx Twilio extension provides the ability to send SMS text and voice messages from ThingWorx through the Twilio communication platform. It allows you to create a Twilio Thing in ThingWorx that stores the configuration information for the Twilio account to be used to send the messages from.
The services provided by the Twilio extension can be used directly or can be used in conjunction with the ThingWorx Notifications feature. The ThingWorx Twilio extension is available from the ThingWorx Marketplace.
* 
The Twilio extension requires ThingWorx 7.4 or a later version.
Configuration
You need to import the Twilio extension to ThingWorx. After importing the Twilio extension, a Thing Template named Twilio appears in the Thing Templates list.
To create and configure a new Twilio Thing, do the following:
1. In ThingWorx, create a new Thing and assign the Twilio template.
2. Click the Configuration view and enter the following details in the Twilio account from which messages will be sent.:
General Settings
Description
authToken
Enter the auth token associated with the Twilio account.
callerID
Enter a valid phone number associated with the Twilio account. This will be the number from which the messages will originate.
accountSID
Enter the accountSID associated with the Twilio account.
3. Once you enter the information, click Save.
In the Services area, the following services are available:
GetNotificationHandlers — used by the ThingWorx Notifications feature and is generally not useful.
SendSMSMessage — requires the receiver’s phone number and the text to send.
SendVoiceMessage — requires the receiver’s phone number, the text to send, the voice of the message (male or female), loop capability, and the voice language.
If new services are created in the Twilio Thing, they can be called in a custom service from the Me/Entities service editor area.
Usage
The Twilio Extension can be used by invoking one of the following services:
SendSMSMessage
The Twilio Thing Template includes a service to send SMS messages. SendSMSMessage takes the recipient's phone number and a message as an input. For example, to send a mass text to all your employees, you can create a service containing the following code:
var employeeList = Groups[employees].GetGroupMembers();

for (var x = 0; x < employeesList.getRowCount(); x++) {
var employee = employeesList.getRow(x);

var params = {
to: employee.smsAddress,
text: "Hey, " + employee.firstName + "." + message
};

me.SendSMSMessage(params);
}
SendVoiceMessage
The Twilio Thing Template also includes a service to make phone calls. SendVoiceMessage takes the recipient's phone number and a message as input in addition to optional voice, language, and loop input. For example, to automate a complimentary wake-up service, you could create a service containing the following code:
var date = new Date();
var hour = date.getHours();

if (hour == 5) {
var params = {
to: "(555) 555-5555",
text: "Rise and shine!"
};

me.SendVoiceMessage(params);
}
You are now ready to send SMS messages and make phone calls.