Checking Queue Caller Count with Dynamic Routes

Suppose you have inbound calls going to a queue. Further suppose that call load varies thru the day, and you want to offer callers different options if the expected wait time is high. It would be necessary in this scenario to know how many callers are waiting in a queue before sending the caller to a queue, and we can do this with Dynamic Routes.

As discussed in an earlier thread, we will use the ‘Asterisk Variable’ lookup source when setting up the dynroute. One thing to know when using complex expressions for the ‘Asterisk Variable’ is to understand how the ‘Enable Substitutions’ feature works. Dynamic Routes allow you to specify variables to store caller input and the lookup value returned, and these persist across multiple dynroutes for the same call if you are chaining more than one dynroute together. Using square brackets in the ‘Asterisk Variable’ expression will trigger this feature, and if it’s not your intent to reference these variables, then you must set "Enable Substitutions’ to No in order for things to work properly.

If we have a queue numbered “701”, the expression to get the raw number of waiting callers would be:


Using this expression, I might set up matching destinations such that if there are only a few callers waiting in the queue, new calls go into the queue, but other calls go to Voicemail or an IVR giving callers an option to do something else other than wait. In the GUI it would look like this:

An even better way would be an expression like this:


This expression will check to see if there are more than 2 waiting callers in the queue, and return a 1, otherwise it returns a 0. Allowing you to branch the call to a max of two destinations. Since this expression has square brackets and it’s not my intent to ref earlier dynroute variables, then set Enable Substitution to no and the GUI looks like this:

With the above technique, you can selectively play different announcements depending on call load before sending a caller to a queue. You can prevent new callers from going into a queue and instead send them to voicemail. You can even use other Asterisk functions to look at queue members and chain it with other dynamic routes to add more logic to the mix.

1 Like

Amazing! Thank you!! Can time conditions be added to this workflow? So that certain destinations could be selected based both on time, and, say queue position?

1 Like

Are you not able to structure your call flows to use time conditions in the conventional way?

Inbound Route -> Time Condition -> Dynroute -> Queue

Perfect. Yes I’m familiar with the conventional way to use them. That works! Thank you!

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.