How to build a Conference line with Twilio Functions

March 25, 2020
Written by
Sam Agnew
Twilion

Copy of Language template - node2 (2).png

Another conference call, another app, another PIN, another log-in. Joining conference calls shouldn’t take more than simply dialing a phone number. Lets walk through how you can quickly build a conference line anyone and everyone can use with Twilio Functions.

Setting up a Twilio Function

You’ll need to create a Twilio account if you don’t already have one. From the Twilio Functions page in your Twilio Console, create a new Function and select the “Blank” template as seen in this image:

Create a Twilio Function

Give your function a name and a path.

Give your function a route

Writing code to handle incoming calls

Now replace the default code in the function with the following code for our app, and click save:

exports.handler = function(context, event, callback) {
  let twiml = new Twilio.twiml.VoiceResponse();

  twiml.say('Please wait while we dial you into the call.');
  twiml.dial().conference('my-conference-room');

  callback(null, twiml);
};

In this code, we are responding to the HTTP request Twilio sends when a phone call is received with some TwiML that tells Twilio to greet the caller, and then dial them into a conference line. In a Twilio Function, you already have access to the Twilio Node library, so no more setup is necessary. When you're finished generating the TwiML in your code, you call the callback function and pass null for the error and the twiml object you created for the response content.

Getting everything running

Now buy a Twilio number so you can link it up to your Function. After buying your number, scroll down to the “Voice and Fax” section and under "A CALL COMES IN" configure it to call your function whenever someone calls your Twilio number, as seen in this image:

Configuring your phone number

You are now ready to receive a phone call to your new Twilio number. Give your new conference line a spin and have some friends join you to test it out!

Give your friends and colleagues a call

Now that you know how to create a basic conference call, try building off of it with other features from our Conference TwiML docs such as joining a Conference on mute, silently bridging calls, or making a conference call moderated.

I’m looking forward to seeing what you build. Feel free to reach out and share your experiences or ask any questions.

  • Email: sagnew@twilio.com
  • Twitter: @Sagnewshreds
  • Github: Sagnew
  • Twitch (streaming live code): Sagnewshreds