I am trying to use a dynamic route to look at essentially the queue wait time and route the call to a different queue if it exceeds a certain threshold. If queue 7500 has a wait time greater than 3 minutes, I want to skip that queue and go to another.
I am using:
$[${QUEUE_VARIABLES(7500,QUEUEHOLDTIME)}>180]
I found my notes from when I needed this in the past
First, @shane8johnson is correct, the necessary queue config is not available in the GUI so you must enable it manually using the conf files. Add a section like these for every queue you need to get the variables to the conf file: queues_post_custom.conf
[800](+)
setqueuevar=yes
[801](+)
setqueuevar=yes
This Asterisk function is odd, in that you must use it over two lines. If you’re doing asterisk dialplan they would look like this:
exten => s,n,set(foo=${QUEUE_VARIABLES(800)})
exten => s,n,Noop(Queue 800 hold time ${QUEUEHOLDTIME})
Since dynroutes can only accommodate a single line you need to finesse it so that it looks like this:
That expression is probably more complicated than it needs to be, but it’s the only way I can think of to call two different functions in a single expression you can use in the one field available in dynroutes.
VERBOSE[26870][C-000903bb] pbx.c: Executing [s@dynroute-2:1] Set("SIP/XXX-1-000e9a3a", "dynroute=") in new stack
VERBOSE[26870][C-000903bb] pbx.c: Executing [s@dynroute-2:2] Set("SIP/XXX-1-000e9a3a", "dynroute=") in new stack
VERBOSE[26870][C-000903bb] pbx.c: Executing [s@dynroute-2:3] Set("SIP/XXX-1-000e9a3a", "dynroute=") in new stack
Any ideas @lgaetz? I should note the queue has agents but currently no calls in queue.
Also noticing the ${QUEUEHOLDTIME} shows the average? hold time? it shows 47s, which I see in Asterisk Info, but there are no agents and no calls waiting. I need the current longest call waiting. Is there a different variable for that?
Hold time is computed based on answered calls. I think the only easily accessible metric for current time to answer is the queue length, divided by the number of agents. Queuing with different priorities can break even those statistics.
Because management can throw in more agents, any forecast can be invalidated by management taking action to compensate.
You could get the value from the CLI queue show command, but that is intended for human, not machine, use and is expensive to run from dialplan.
This is probably lacking in efficiency, but does work to get the time in seconds. asterisk -x "queue show 7500" | grep -nm1 "wait" | sed 's/..........$//' | tail -c 6 | awk -F: '{ print ($1 * 60) + $2 }'