Rate this page:

Queueing Calls


This guide will explain how to use Twilio's Queue feature to create a simple call queueing system. A Queue stores incoming calls in order. You can then connect the first call in the queue to another call easily. The complete code sample will show you how to accept an incoming call, place it into a queue and then connect a live agent to the first call in the queue.

For this demonstration we'll be using two Twilio phone numbers, so if you'd like to try the code out live, you'll need to buy two phone numbers. For more help getting setup with Voice be sure to read our Getting Started guide.

Putting the Caller in a Queue

When our first number is called, Twilio will make a request to our server to place the caller in the Queue.


        We start by creating a creating a TwiML response that uses the Enqueue verb to create a new Queue and place the caller into it.

        You can learn more about how to serve TwiML from your own application in our webhook guides. You can explore all the available TwiML functionality in our TwiML reference docs.

        Connecting the Agent to the Queue

        When our second number is called, Twilio will make a request to our server to connect the agent to the Queue.


              To connect to the first caller in the Queue all we do is Dial the Queue by name.

              Automatically Connecting to the next Caller

              By default the call will end when the Agent or Caller hang up, but in most cases we'll want to connect to the next Caller automatically.


                    An empty <Redirect> verb will redirect the caller to the beginning of the TwiML, which will then Dial and connect to the next person in the Queue. As a final touch we add a <Say> verb to tell the agent that they are being connected to another caller.

                    More sophisticated workflows

                    With Twilio's TaskRouter you can implement very sophisticated call-center workflows like:

                    • assigning available Agents to the next caller in the Queue
                    • offering tiered support plans, that allow premium customers to skip the queue
                    • routing certain callers to different teams based on business logic

                    Hopefully this guide got you up and running with Twilio Queues. Email us and let us know what features of Queue you would like to know more about.

                    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.


                          Thank you for your feedback!

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

                          Sending your feedback...
                          🎉 Thank you for your feedback!
                          Something went wrong. Please try again.

                          Thanks for your feedback!

                          Refer us and get $10 in 3 simple steps!

                          Step 1

                          Get link

                          Get a free personal referral link here

                          Step 2

                          Give $10

                          Your user signs up and upgrade using link

                          Step 3

                          Get $10

                          1,250 free SMSes
                          OR 1,000 free voice mins
                          OR 12,000 chats
                          OR more