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 business 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.
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.
After you install the Twilio Connector, download “demo-sms” from this page and import it into Studio. You will see the following Mule flows in the project:
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”.
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.
- You can find Account SID and Auth Token in your Twilio dashboard.
(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.”
Before you click on “POST,” fromNumber and toNumber should be properly configured.
“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.
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.