This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Twilio Connector
The Twilio connector allows you to connect to Twilio, an online service that lets you embed phones, VoIP, and messaging in web, desktop, and mobile software. The connector uses the Twilio REST API to connect to Twilio and work with accounts, applications, calls, messages, and more. The underlying Java classes in the connector use the Twilio Java Helper Library to make the HTTP requests to the Twilio API.
The following sections describe how to perform various operations with the connector. For general information on using connectors and their operations in your ESB configurations, see Using a Connector. To download the connector, go to https://store.wso2.com/store/assets/esbconnector/twilio, click the Twilio connector, and then click Download Connector. Then you can add and enable the connector in your ESB instance.
Connecting to Twilio
To use the Twilio connector, add the <twilio.init> element in your configuration before any other Twilio operations. This Twilio configuration authenticates with Twilio by specifying the SID and authentication token of your master Twilio account. You can find your SID and token by logging into your Twilio account and going to the API Credentials section on the dashboard.
init
<twilio.init>
<accountSid>ACba8bc05eacf94afdae398e642c9cc32d</accountSid>
<authToken>AC5ef8732a3c49700934481addd5ce1659:{AuthToken}</authToken>
</twilio.init>Entering secure data
For security purposes, you should store your SID and token in the WSO2 secure vault and reference it by alias instead of hard-coding the actual values in the configuration file. For more information, see Working with Passwords.
Re-using Twilio configurations
For best results, save the Twilio configuration as a local entry. You can then easily reference it with the configKey attribute in your Twilio operations. For example, if you saved the above <twilio.init> entry as a local entry named MyTwilioConfig, you could reference it from an operation like getTranscriptionList as follows:
<twilio.getTranscriptionList configKey="MyTwilioConfig" />
Working with accounts
The following operations are available for working with accounts:
Operation | Description |
|---|---|
Creates a new account resource as a sub-account of the master account. | |
Retrieves a list of the account resources belonging to the master account. This list will include the master account as well. | |
Returns a representation of a specified account. | |
Allows you to modify the properties of an account. |
Following is more information about these operations.
createSubAccount
<twilio.createSubAccount configKey="MyTwilioConfig">
<friendlyName>My New Account</friendlyName>
</twilio.createSubAccount>To create a sub-account as a resource of the master account, use twilio.createSubAccount and specify the following properties. If successful, Twilio responds with information about the sub-account, including its SID, a 34-character string that uniquely identifies this sub-account.
Properties
friendlyName: A human-readable description of the new sub-account, up to 64 characters. Defaults to "SubAccount Created at {YYYY-MM-DD HH:MM meridian}".
Related Twilio documentation
http://www.twilio.com/docs/api/rest/subaccounts
getAccountsList
<twilio.getAccountsList configKey="MyTwilioConfig">
<friendlyName>My SubAccount</friendlyName>
<status>active</status>
</twilio.getAccountsList>To get a list of existing accounts that belong to the master account, use twilio.getAccountsList and optionally specify the following properties. If you do not specify these properties, all accounts belong to the master account are returned. The master account is included in the list.
Properties
friendlyName: Optional. The human-readable account name. Only accounts whose name exactly match this string are returned.status: Optional. The status of accounts to return: active, suspended, or closed. Only accounts with this status are returned.
Related Twilio documentation
http://www.twilio.com/docs/api/rest/account#list
getAccount
<twilio.getAccount configKey="MyTwilioConfig">
<subAccountSid>ACba8bc05eacf94afdae398e642c9cc32d</subAccountSid>
</twilio.getAccount>To get information about an account, such as its friendly name, date created, and status, use twilio.getAccount and specify the following properties.