Integrate without Limits – Twilio Integration with MuleSoft

Written by Muhammad Aqib Arif

Senior Software Engineer - Middleware Practice

In today’s digital world, communication has been one of the biggest challenges, especially when communicating with customers, communicating one system to another, or implementing communication channels anywhere.

With businesses getting digitized and advanced technologies being introduced in the market at lightning speed, almost every market has become global. Therefore, there is no geographical limit to which you should restrain your business transactions. Twilio is a platform that small companies use for huge enterprises across the globe. This integration would let you reach out to the users located across the globe and communicate with them, hoping to grow your business.

At the simplest level, integration is the process of combining two or more things to create a whole. For businesses, the term integration often refers to software or system integration, which means bringing together several business systems to operate as a collaborative unit. In this blog, we will go through Twilio and its integration with MuleSoft, and we will see how Twilio can help narrow the communication gap using Phone calls or messages APIs. This integration makes the best use of both platforms to enhance the communication pertaining to their client organization.

Introduction to Twilio

Twilio is a platform that facilitates users in cloud communications. It can be utilized with respect to the platform as a service. Twilio empowers software developers to programmatically make and receive phone calls, send and receive text messages, and execute other communication functions using its web service APIs.

How to Integrate Twilio with MuleSoft?

In this Integration scenario, we can Send SMS from MuleSoft using Twilio Connector. Please follow the steps below to get your Twilio account.

  • Once the Twilio account is created, login and analyze the Twilio console.
  • Now click on the “Get a Trial Number” button to get your Twilio trial number.
  • A new popup will appear where you can choose the number as shown in the image below.
  • Click on “Choose this Number”.
  • Now a Congratulations message will appear with your number. Click on Done.
  • Your Twilio number will now be visible on the Twilio console.
  • So, the Twilio account is setup and ready to integrate.
  • Note the Trial Number, Account SID, and Auth Token. This detail will help in the next steps.

Now, open Anypoint Studio and follow the steps below to integrate Twilio with MuleSoft.

  • Create a new project in Anypoint Studio and give a name.
  • Now drag HTTP Listener from Mule palette.
  • Let’s add configuration for the HTTP Listener.
  • Now add path for HTTP Listener as /send.
  • So, the HTTP Listener is configured. Let’s now add Twilio Connector in MuleSoft.
  • Go to Mule Palette and Click on “Search in Exchange”.
  • A new popup window will appear, search for Twilio Connector there and click on Add.
  • Click finish and see the Twilio Connector is added to the project.
  • Now, let’s drag the “Create Message” operation to the flow right after the HTTP Listener.
  • Configure the operation and add the following in the fields. Username as Account Sid (Twilio) and Password as Auth Token (Twilio).

Now Test Connection, and it should be Successful

  • Configure the general settings.
  • Let’s add the Transform Component in between the HTTP Listener and Twilio Connector, then configure as shown in the below image.
  • Now run the project and open REST Client like a postman.
  • Send the request with the payload shown in the image above to (the number where the message is to be sent) from (Your Twilio trial number) body (Message).
  • Let’s now monitor the message from Twilio Console.
  • Go back to Twilio Console, and on the bottom right select Programmable Messaging.
  • In the Recent Messages section, click on the date, and it will redirect to a detailed message page.
  • See the detailed message in the image below.
  • The message received on mobile looks like this.

MuleSoft provides a cloud connector to integrate Twilio API with MuleSoft. MuleSoft Cloud connector offers a simple and easy way to integrate with these Twilio APIs and then use them as services within MuleSoft. MuleSoft-Twilio connector provides a platform for the developer to develop and integrate their application easily and quickly with Twilio. You maybe interested in this Whitepaper about Salesforce MuleSoft Integration.

At Royal Cyber, we enable APIs, IoT (Internet of Things), Artificial Intelligence, Cloud, and the complete Digital transformation ecosystem for our customers, and the latest technology trends. We have over 20 years of experience with clients across the globe. For more information or for a quick demo, you can email us at info@royalcyber.com or visit www.royalcyber.com.

Leave a Reply