DEV Community

Cover image for Twillio Direct Audio call integration with Nodejs Express
Pankaj Kumar
Pankaj Kumar

Posted on • Updated on

Twillio Direct Audio call integration with Nodejs Express

Hi, Today we will discuss about the end to end/direct calling using Twilio API. I assume that you have knowledge of Twilio and why it is used for.

BASIC FLOW OF DIRECT CALLING USING TWILIO

Step 1: Purchase Twilio number

For this task user need to purchase a twilio number on which user will call for interacting IVR or making direct end to end call.

Step 2: Set callback url

For this task we need to login into the twilio console. After login on console scroll down the page and click Phone Number option at the bottom of the page. After redirecting the page there will be a section named Manage Numbers under which there will be list of active phone numbers like below screenshot

Image description

Now click on the twilio number and set the callback api url like below screenshot:

Image description

Now we have performed all the task needed at twilio platform. So now the task which is left is callback api creation in nodejs express.

Step 3: Create Callback API

So now we have following code which is doing the actual job to return the end user phone number to the twilio.


router.post('/make-call', (req, res) => {
const VoiceResponse = require('twilio').twiml.VoiceResponse;

const response = new VoiceResponse();
const dial = response.dial({
callerId: '+12121111', // Purchased twilio number
});
dial.number('+91878765456'); // phone number of end user to forward the call
res.send(response.toString());
});

Enter fullscreen mode Exit fullscreen mode

Pretty cool! Finally our task completes here.

That’s all for now. Thank you for reading and I hope this post will be helpful for beginners who are going implement twillio calling.

Let me know your thoughts over the email demo.jsonworld@gmail.com. I would love to hear them and If you like this article, share with your friends.

This article is originally posted over jsonworld

Top comments (0)