Asterisk Queues

| No TrackBacks

I've been busy lately working on a rather big Asterisk installation.

One of the bigger problems we've wanted to solve was our queue management.

Here's the beginnings of a queue log in/out macro I've been fiddling with.

oh, and a super-big thanks goes to Jared Smith, for the basis of what I've done here.

; macros to do login and out of queues [macro-queueloginout] ; first argument is the queue to be added to, second(not yet implemented) is penality exten => s,1,Answer exten => s,n,Set(MYNUMB=${CUT(CHANNEL,-,1)}) exten => s,n,Set(MYNUMBCLEAN=${CUT(MYNUMB,/,2)}) exten => s,n,Set(OUR_QM_LIST=${QUEUE_MEMBER_LIST(${ARG1})}) ; assign member list to variable so it doesn't change exten => s,n,Set(CHANNEL_TO_MATCH=${CUT(CHANNEL,-,1)}) ; get rid of the unique identifier on the end exten => s,n,Set(X=1) ; initialize counter

exten => s,n,While($[${EXISTS(${CUT(OUR_QM_LIST,\,,${X})})}]) ; while we still have a value (not-null), loop
exten => s,n,Set(MATCHED=${IF($["${CUT(OUR_QM_LIST,\,,${X})"} = "${CHANNEL_TO_MATCH}"]?1:0)}) ; match against the channel
exten => s,n,Exec(${IF($[${MATCHED}]?ExitWhile():NoOp())}) ; exit while on match
exten => s,n,Set(X=$[${X} + 1]) ; increase the iterator
exten => s,n,EndWhile() ; End of the loop
exten => s,n,GotoIf($[${MATCHED}]?100,1:400,1) ;branch on match, 100 means yes 200 means no

exten => 100,1,noop(yup) ; agent is already logged in, log em out
exten => 100,n,RemoveQueueMember(${ARG1},Local/${MYNUMBCLEAN}@queueagents/n)
exten => 100,n,playback(agent-loggedoff)
exten => 100,n,Hangup

exten => 400,1,noop(nope) ; agent is not logged in, log em in
exten => 400,n,AddQueueMember(${ARG1},Local/${MYNUMBCLEAN}@queueagents/n,0)
; catch if queuemember breaks
exten => 400,n,Execif($[ ${AQMSTATUS} = ADDED ],Playback,agent-loginok)
exten => 400,n,Execif($[ ${AQMSTATUS} = NOSUCHQUEUE ],Playback,try-again)
exten => 400,n,Hangup

It is still a work in progress, I'm hoping to get a penality overload built into the macro in the near future.

Oh, yeah! I almost forgot to show you how to use the macro in your dialplan:

exten => _77XX,1,Macro(queueloginout,${EXTEN})

This extension, anything in the 7700 range, will log the currently calling phone into the queue specified, numbered by the extension dialed.
E.g. dial 7703 will log you into or out of queue 7703.

UPDATE 2007-05-10

I was fiddling with this, and realzed that only one agent could log in at a time.

Thanks again to Jared for discovering that adding four little quote marks makes it work correctly.

post above edited to show the new quotes.

No TrackBacks

TrackBack URL: http://blog.friocorte.com/mt/mt-tb.cgi/12