Queue: The Gathering

Twilio recently added the ability to use the <Gather> verb in the TwiML you use to provide a callers experience while in a queue. This opens up lots of interesting possibilities for changing what would normally be a bland and frustrating experience for your customer, into a more targeted and even possibly entertaining experience.

In this post I’ll show you how you can use the <Gather> verb to create a variety of different call queue experiences for your customers.

Create A Call Queue

Before we get started looking at a Queue wait experience, lets quickly review how you create a call Queue in the first place.

The <Enqueue> verb is the easiest way to create a new Queue and add a caller to it. For example, if you create a new Queue named CustomerService and add a caller to it you would return the following TwiML:When adding a caller to this queue they would experience a fairly standard, if uninteresting  experience while they wait, hearing basic hold music.  Thankfully <Enqueue> includes the waitUrl parameter, which allows you to customize the callers queue experience.

In this case, when the caller drops into the queue, Twilio will make a request to the URL specified in the waitUrl parameter and use the TwiML returned to create the callers queue experience.  When the TwiML returned from the waitUrl completes execution, if the caller is still in the queue Twilio will make another request to the waitUrl, allowing you to  dynamically change the experience the caller is having while the wait in the queue.

Now that you know how to create a queue and create a custom wait experience, lets look at how you can use the <Gather> verb in the TwiML returned from the waitUrl.

Just Call Me Back

No one really wants to wait on hold, so why make them. While sitting in the queue, why not let the user choose to have you call them back? Using <Gather> in Queue it’s easy.  Below is some TwiML I can return from my waitUrl that lets me remind the user that they can have us call them back, instead of continuing to wait in the queue:

Using the <Gather> verb I let the caller make the selection that lets them exit the queue and enter a workflow for setting up the callback. To make this experience even more dynamic, your application might even check to see if the current wait time or caller position exceeds a specific threshold before it beings to offer this prompt to callers.

Let Me Help You Help Me

Sometimes you have well-defined workflows that help customers walk through troubleshooting a problem, or get the information they are calling about.  Instead of just having customers listen to hold music, why not make use of queue wait time to gather more information. Doing this lets the caller continue to moving closer to talking to an human, while at the same time providing valuable information that can help identify a resolution faster once they are talking to a representative.

For example lets say every time you get a support call from a customer you will need to get a model number in order to help them. You can use the time the caller is in the queue to gather this. In the TwiML below, I am prompting the user to let them know we are going to be asking questions while they wait, then I <Redirect> to the first question:

As its name suggestions, the GatherModelNumber endpoint uses <Gather> to capture the users model number.

As the caller enters information, the information survey can dynamically change based on the information gathered to date.  For example, once I know the model number I can change the information survey to ask only questions that are relevant for that model.

Shall We Play a Game?

Finally, sometimes the best option is just to give customers something to do while on hold, like play a game.  A simple game can be an easy way to help pass the time for customers.  To show this, I’ve written a sample that shows how to create a simple pub-style trivia game that callers can play while waiting in the queue.  You can try the sample out here:   http://quizshow.azurewebsites.net

The game is simple.  The IVR asks the caller five different trivia questions and scores them at the end.  The image below shows the basic call flow for the game.


While I’m not going to detail the entire app in this post since the actual code is relatively straight forward, there are some interesting parts of the call flow to point out.

First, when a caller initially drops into the queue, the IVR performs some basic checks to try to determine if the caller should even give them the option to play the game.  This includes looking at the current average wait time of callers in the queue, as well as the position of the caller in the queue, both of which are given to me as parameters each time Twilio requests the waitUrl.  If these values are below a certain threshold then I can assume the callers wait time will be short and therefore it does not make sense to have them play the game.

Second, even if I determine that the caller is eligible to play the game, I still give them the option to opt out.  Sometimes callers just want to listen to hold music.

Build A Better Queue

Adding <Gather> to your queue opens the possibility to create innovating an engaging experiences for a situation that most customers would rather avoid.

As always, we encourage you to do dig through the source code for the quiz show sample which you can get from GitHub, and try out our live demo by going to http://quizshow.azurewebsites.net.




  • Very cool. I would like to find more ways like this to integrate our texting app with Twilio.

    • Great! What are you building? Here are some examples of Twilio use cases: (www.twilio.com/solutions). You can check out what developers are building here (www.twilio.com/doers). If you have any questions let us know: kyleky@twilio.com

  • hanane

    hey , i want to make a java application that can be able to make call from my application to any phone number , can i do this with twilio api?

    • Yes you can. You check out our API docs here (http://www.twilio.com/docs/api/rest/call) and different Twilio solutions here (www.twilio.com/solutions) Let us know if you have any questions!

      • hanane

        thank you for reply , actualy , i have an upgraded twilio account , and i followed exactly what is mentioned in this link : http://www.twilio.com/docs/api/rest/making-calls example 1 , first i can’t heard the ring while calling the other persone , seconde when the other personne pik up his phone i can’t hear him and even he can’t hear me but he heard a voice texting what is mentioned in the URL parameter , i want to speak to him directely , additionaly my cost account decrease , can you help me it’s very urgent , the call is establishing but i can’t communicate with the called person

        • The fast avenue for help is to email our support team at help@twilio.com – they can trouble shoot with you