Extension To Queue

Asterisk 14

Does anyone have a method of greping or something similar that would give me the list of queues a member is a part of?

I have a dialplan that kicks off if an extension doesn’t answer by offering the caller a chance to go to the queue that the extension is a part of, so they can speak with a peer.

The part I am stuck on is using the dnid (extension) to pull up the related queue, so I can route to it. Open to alternative approaches if someone has a better idea. Thanks in advance for any insights!

I shifted gears and this is my approach. It seems inefficient, but works.

  1. Set a loop counter ${QUEUELOOP} to 1
    exten => s,n,Set(QUEUELOOP=1)

  2. Count the number of queues on the system, and set them to a variable: {QUEUELOOPMAX} `exten => s,n(loopstart),Set(QUEUELOOPMAX={SHELL(asterisk -rx ‘queue show’ | egrep max | wc -l)}`

  3. Get an ordered list of queues and select the nth queue, based on current value of {QUEUELOOP} `exten => s,n,Set(QUEUECHK={SHELL(asterisk -rx ‘queue show’ | egrep max | grep -o ‘^\S*’ | sort | awk ‘NR==${QUEUELOOP}{ print; }’`

  4. Check for the extension as a member of the current queue under evaluation {QUEUECHK} `exten => s,n,Set(QUEUEMEMBERRESULT={SHELL(asterisk -rx 'queue show {QUEUECHK}' | egrep {CALLERID(dnid)} | cut -d"@" -f1 | cut -d"/" -f2)}`

  5. If the extension is contained in the {QUEUEMEMBERRESULT} the extension is an agent in the queue, and transfer to the queue, otherwise increase the loop count by +1 `exten => s,n,GotoIf([{QUEUEMEMBERRESULT} = {CALLERID(dnid)}]?route:noroute) exten => s,n(route),Goto(ext-queues,{QUEUECHK},1)` `exten => s,n(noroute),Set(QUEUELOOP=[${QUEUELOOP} + 1])`

  6. If {QUEUELOOPMAX}>{QUEUELOOP} then try again at the top going to the next skill, otherwise the treatment is over.
    exten => s,n,GotoIf($[${QUEUELOOPMAX} > ${QUEUELOOP}]?loopstart:hangup)
    exten => s,n(hangup),Hangup()

This cannot be the best way to do it, but it all works, in dialplan. Some of it could be combined, but I think the way it is broken out will make it easier to understand for future editors of the treatment.

something like this will work is not the exact command you need to work on the awk command part to get the colum holding the queue value and replace xxxx by the queue member

asterisk -x " queue show " | grep XXXX | awk

1 Like

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