Tutorial on Voice Call using Twilio Connector

Authors: Manish Prabhu and Ganesh Nyati

Introduction

Twilio is a communication platform based on cloud. We can make and receive calls, send & receive text messages using twilio. We have a twilio connector in Mule 4 that can be imported from exchange.

The operations about sending, receiving of text messages is possible using the twilio connector. But making a voice call facility is not available in the connector operation. This is possible with the help of REST api available in twilio. The api available for making voice calls is:

POST https://api.twilio.com/2010-04-01/Accounts/{accountSID}/Calls.json

The above API requires following data in body of the request in application/urlencoded format:

Url = http://demo.twilio.com/docs/voice.xml

From={fromPhoneNumber}- this trial number you need to get in the twilio dashboard for making calls.

To={toPhoneNumber}- this number must be a verified phone number i.e. it should be present in a verified list of numbers in twilio dashboard.

It requires basic authentication as an authentication mechanism where you need to provide accountSID as username and authtoken as password. You can get these values from twilio dashboard. The trial number received from twilio must be used in the From field.

You can get a list of verified phone numbers. You can also add a new phone number. You can make calls to only verified phone numbers.

Sample flow:

Listener configuration:

The first transform message is configured as input for making calls api as follows:

The HTTP Request component for making calls is configured as:

The second transform message is used to display output of http request in json format:

The above designed application is deployed on localhost & it is verified using the postman request.

A voice call is made from a (From) number specified in the HTTP request.

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.