When handling phone calls with TwiML, you have many options for controlling the caller’s experience. You can something in a robot voice, other numbers into the call and even the call. My personal favorite is the ability to play audio files over the phone using the TwiML verb. You can even create your own version of Dial-A-Song, a hotline run by the band They Might Be Giants that allows you to listen to their music if you call the number (844) 387-6962.

Today I’m going to show you how to make and receive phone calls using the Node.js Twilio library. We will also be using some ES6 features to “spice things up a notch.” What better way to show what we can do with Twilio voice than to allow the callers to rock out over the phone?

Here is our code in full on GitHub if you want to skip straight to having a working app.

Gearing up

We are going to need to grab some gear and tune up first. For starters, you’ll need to have have Node.js and NPM installed. You will also need to create a Twilio account and purchase a phone number with Voice capabilities.

Now let’s initialize a new app. Open your terminal, navigate to the directory you want to start this project in and run: