Reading Time: 5 minutes

Twilio is a cloud communications platform which allows software developers to programmatically make and receive phone calls and send and receive text messages using its APIs. More than 28,000 companies including Salesforce, Netflix, Coca-Cola Enterprise, Airbnb, Intuit, and Uber integrate Twilio in their products or processes.

MuleSoft customers also use Twilio in various use cases. A customer uses Twilio to send internal notifications based on the contact information in Salesforce. Another customer uses Twilio to send personalized messages to its website visitors, and others send promotional coupons to their users based on their locations.

latest report
Learn why we are the Leaders in management and iPaaS

In this blog post, I'd like to walk you through a simple demo app to show you how to send an SMS with the Twilio Connector.

Before you start with the demo app, please make sure you have the Twilio Connector v2.0.0 downloaded from the Exchange.

Exchange-Twilio

After you install the Twilio Connector, download “demo-sms” from this page and import it into Studio. You will see the following flows in the project:

Twilio-Flow

Once you load the example, configure the connector. To configure the Twilio Connector, go to Global Elements, and find “Twilio: Basic Authentication” and click “Edit”.

Twilio-Configuration-1
Twilio-Configuration-2

In the “Twilio: Basic Authentication,” you can specify the configuration for Twilio. You could directly add your Twilio information in the configuration, but we recommend using the properties file to add your configuration information. In mule-app.properties, please configure the following properties based on your Twilio instance.

twilio.accountSid=

twilio.authToken=

  • You can find Account SID and Auth Token in your Twilio dashboard.
Twilio Dashboard

twilio.apiUrl=https://api.twilio.com/2010-04-01

(This is the latest API URL when this blog post is written.)

Now, your app is ready to send an SMS through Twilio API. If you open your browser and hit localhost:8081/console, you will see the following HTML page. This page enables you to send an SMS by simply clicking “POST” and “Try it” under “/messages.”

Twilio-demo-console
Sending a SMS

Before you click on “POST,” fromNumber and toNumber should be properly configured.

{

 “fromNumber”: “+16055551212”,

 “toNumber”: “+541123456789”,

 “bodyMessage”: “Connect anything. Change Everything”

}

“fromNumber” is your Twilio number where you can find in your Twilio Console (Phone Numbers). You can only send an SMS to “toNumber” which is on the list of Verified Caller IDs. When you click on “POST,” you (“toNumber”) would receive an SMS similar to the following one.

Received SMS

For new users, try the above example to get started, and for others, please share with us how you are planning to use Twilio with the Anypoint Connector for Twilio! Also, explore the Anypoint Exchange to see other resources you can leverage today.