Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Incoming Calls with Twilio Client

Incoming Capability

In order for your client device to be allowed to receive incoming connections from Twilio, you need to make sure that the Capability Token you've provided allows for it. To do this, you will need to assign a unique client name to your Client and have your server application provide this client name to the incoming capability of the token generator.


        In this example, you can see the client name of "joey" is being assigned. When you have multiple clients, this name will need to be unique so that they can each receive calls intended for them.

        Routing Incoming Calls to Clients

        In order to route a call made to a Twilio phone number to your client, you need to provision the incoming voice URL of your Twilio phone number to return the following TwiML.

        <?xml version="1.0" encoding="UTF-8"?>

        This will connect the inbound caller with the client application that is registered as "joey." In order to have a conversation, however, the client needs to accept the call.

        Accepting an Incoming Call

        To accept a call, you only need to listen for the incoming event. That event will pass you a connection object on which you can call the accept() method.


              Rejecting an Incoming Call

              If your arch-enemy is calling and you're just not in the mood to listen to their monologue, you can reject the call. The process is similar to accepting a call except instead of calling the accept() method on the connection object, you call its reject() method.


                    Calling a Client with the REST API

                    Calling a Twilio Client using the Twilio REST API is extremely easy as well. It's just like making a PSTN phone call with the REST API, but for the To parameter you specify "client:" followed by the client name you wish to call. Here's an example that calls the client named "tommy."

                          David Prothero Alan Klein Andrew Baker
                          Rate this page:

                          Need some help?

                          We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.