Dynamic Route and IVR For Queue: Wait On Hold or Leave Voicemail

Taking a suggestion from @lgaetz and putting this here in case anyone is looking for a solution like this. Hopefully this is helpful and presented clearly if anyone needs this.

If there are no queue agents available (they’re all on a call) on our IT helpdesk queue, the caller should be sent to an IVR to give them options. Those options are to choose to stay on hold and wait for an agent to become available, or to leave a voicemail for the helpdesk to see later.

Set up a dynamic route (“Applications” → “Dynamic Routes”). I set up a route and left everything default but set a couple things in the “Dynamic Route Lookup Source” section. Here, I am looking at the return value for

using the “free” option, which returns the number of queue members who are currently not in a call.

The entries for the dynamic route are based on that return value - 0 will be returned if there is at least one agent available (free agents >= 1), while 1 is returned if the queue is full (free agents 0 / < 1). Zero sends the caller straight into the queue, while one sends them to an IVR I created, where the caller presses 1 to remain on hold (thereby entering the queue) or select 0 to leave a voicemail in a shared mailbox.


I also added two lines to the extensions_custom.conf file to make sure internal callers hit this check as well:

exten => 5555,1,GoSub(dynroute-2,s,1)
same => n,Hangup()