Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Sending an SMS With Twilio Connector

DZone's Guide to

Sending an SMS With Twilio Connector

Walk through a simple demo app and follow a couple of easy steps to learn how you can send an SMS with the Twilio Connector.

· Integration Zone
Free Resource

Share, secure, distribute, control, and monetize your APIs with the platform built with performance, time-to-value, and growth in mind. Free 90 day trial 3Scale by Red Hat

Twilio is a cloud communications platform that 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. 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.

Exchange-Twilio

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:

Twilio-Flow

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

Twilio-Configuration-1

Twilio-Configuration-2

In 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=.

 Note: 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 as of 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 POST, you (toNumber) 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! 

Discover how you can achielve enterpriese agility with microservices and API management

Topics:
integration ,tutorial ,sms ,twilio

Published at DZone with permission of Nathan Nam, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}