Dynamic Routes Question - Average Wait Time

Maybe @lgaetz knows…

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]

In Asterisk Info the queue is:

7500 has 1 calls (max unlimited) in 'rrmemory' strategy (47s holdtime, 898s talktime), W:0, C:7, A:1, SL:71.4%, SL2:75.0% within 60s
Members:
test (Local/XXXXXXXXXX@from-queue/n) (ringinuse disabled) (dynamic) (paused:1 was 516 secs ago) (Not in use) has taken no calls yet (login was 537 secs ago)
Callers:
1. SIP/XXX-000e9684 (wait: 4:54, prio: 0)

When I call my dynamic route I get:
WARNING[9923][C-000900b2] app_queue.c: queue 7500,QUEUEHOLDTIME was not found

Not sure if this is your issue or not but have a look at the response to this post: How to get queue hold time information - Asterisk Support - Asterisk Community

QUEUEHOLDTIME is correct. It is not set unless you enable it, with setqueuevar in queues.conf, or force it with the “function” QUEUEVARIABLES.

1 Like

I saw this post in the other fourm. Can you provide more detial? I have added:
setqueuevar = yes
to
queues_custom_general.conf

But I dont know what “force it with the “function” QUEUEVARIABLES” means exactly

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:

${IF([${QUEUE_VARIABLES(800)}]?${QUEUEHOLDTIME}:${QUEUEHOLDTIME})}

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.

1 Like

No more “QUEUEHOLDTIME was not found” error, but its still not working:

queues_post_custom.conf
[7500](+)
setqueuevar=yes

${IF([${QUEUE_VARIABLES(800)}]?${QUEUEHOLDTIME}:${QUEUEHOLDTIME})}

The log says null value:

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.

I split it into two dynamic routes for now
Route 1:
${SET(foo=${QUEUE_VARIABLES(7500)})}

Route 2:
$[${QUEUEHOLDTIME}>180]

But this just returns:
VERBOSE[32223][C-00090aed] pbx.c: Executing [s@dynroute-2:3] Set("SIP/XXX-1-000ea4d3", "dynroute=$") in new stack

I am missing something.

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 }'

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