Twilio
* 
PTC support for ThingWorx’s Twilio extension has ended, and the extension is no longer available for download from PTC’s download portal. PTC partner Free ThingWorx Widgets | IQNOX will provide support and future maintenance release for this extension. For more information, see PTC’s support article.
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.
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.
Was this helpful?