136
Outbound and QueueMetrics / EXPERIMENTAL: replace the queueDial.agi with a pure-scripting solution
« on: May 23, 2008, 11:56:52 »
We have been working for quite a while on a purely-dialplan solution to replace the queueDial.agi that seems to have problems with a number of 1.4 systems.
So we developed this script that targets Asterisk 1.4 and is a complete replacement of queueDial.agi:
Before telling everybody to use this, though, we would like our power-users to test this out and find any flaws that may be lingering
Known advantages over QueueDial.agi:
- Simpler setup and debugging
- No 'h' problems with calls that are not closed
- Correct tracking of answering time even for outbound (the calls stays unsnswered and then answered at the right time)
- Easier to add options (eg a timeout) to the actual DIAL commend executed
Known issues:
- The script does not distinguish whether it was the AGENT or the CALLED PARTY to hang up (anybody knows how?)
- It's for 1.4.x only
- It uses System() a number of times and not the QueueLog() app
- It uses global variables to pass values back from a different leg of the call
So we developed this script that targets Asterisk 1.4 and is a complete replacement of queueDial.agi:
Code: [Select]
[queuedial]
; using a global variable to pass values back from the answer-detect macro
; STATUS = U unanswered
; = A answered
;
exten => _9XXX.,1,Set(MY_QUE=q-${EXTEN:1:3})
exten => _9XXX.,n,Set(MY_NUM=${EXTEN:4})
exten => _9XXX.,n,Set(MY_AGENT=Agent/${CALLERID(num)})
exten => _9XXX.,n,Set(MY_TECH=Zap/g0/)
exten => _9XXX.,n,NoOp,Ag: ${MY_AGENT} N: ${MY_NUM} Q: ${MY_QUE} T: ${MY_TECH}
exten => _9XXX.,n,MixMonitor(Q-${MY_QUE}-${UNIQUEID}.wav|b|)
exten => _9XXX.,n,Set(ST=${EPOCH})
exten => _9XXX.,n,Set(GM=QDIALV${MY_AGENT})
exten => _9XXX.,n,Set(GLOBAL(${GM})=U)
exten => _9XXX.,n,Set(GLOBAL(${GM}ans)=0)
exten => _9XXX.,n,System( echo "${ST}|${UNIQUEID}|${MY_QUE}|${MY_AGENT}|ENTERQUEUE|-|${MY_NUM}" >> /var/log/asterisk/queue_log )
exten => _9XXX.,n,Dial(${MY_TECH}${MY_NUM}||M(queuedial-answer^${UNIQUEID}^${GM}^${MY_QUE}^${MY_AGENT}^${ST}))
; Trapping call termination here
exten => h,1,NoOp( "Call exiting: status ${GLOBAL(${GM})} answered at: ${GLOBAL(${GM}ans)} DS: ${DIALSTATUS} HU: ${HANGUPCAUSE} " )
exten => h,n,Goto(case-${GLOBAL(${GM})})
exten => h,n,Hangup()
; Call unanswered
exten => h,n(case-U),Set(WT=$[${EPOCH} - ${ST}])
exten => h,n,System( echo "${EPOCH}|${UNIQUEID}|${MY_QUE}|${MY_AGENT}|ABANDON|1|1|${WT}" >> /var/log/asterisk/queue_log )
exten => h,n,Hangup()
; call answered
exten => h,n(case-A),Set(WT=$[${GLOBAL(${GM}ans)} - ${ST}])
exten => h,n,Set(CT=$[${EPOCH} - ${GLOBAL(${GM}ans)}])
exten => h,n,System( echo "${EPOCH}|${UNIQUEID}|${MY_QUE}|${MY_AGENT}|COMPLETECALLER|${WT}|${CT}" >> /var/log/asterisk/queue_log )
exten => h,n,Hangup()
[macro-queuedial-answer]
; Expecting $ARG1: uniqueid of the caller channel
; $ARG2: global variable to store the answer results
; $ARG3: queue name
; $ARG4: agent name
; $ARG5: enterqueue
exten => s,1,NoOp("Macro: queuedial-answer UID:${ARG1} GR:${ARG2} Q:${ARG3} A:${ARG4} E:${ARG5}")
exten => s,n,Set(NOW=${EPOCH})
exten => s,n,Set(WD=$[${NOW} - ${ARG5}])
exten => s,n,System( echo "${NOW}|${ARG1}|${ARG3}|${ARG4}|CONNECT|${WD}" >> /var/log/asterisk/queue_log )
;exten => s,n,DumpChan()
exten => s,n,Set(GLOBAL(${ARG2})=A)
exten => s,n,Set(GLOBAL(${ARG2}ans)=${NOW})
exten => s,n,NoOp("Macro queuedial-answer terminating" )
Before telling everybody to use this, though, we would like our power-users to test this out and find any flaws that may be lingering

Known advantages over QueueDial.agi:
- Simpler setup and debugging
- No 'h' problems with calls that are not closed
- Correct tracking of answering time even for outbound (the calls stays unsnswered and then answered at the right time)
- Easier to add options (eg a timeout) to the actual DIAL commend executed
Known issues:
- The script does not distinguish whether it was the AGENT or the CALLED PARTY to hang up (anybody knows how?)
- It's for 1.4.x only
- It uses System() a number of times and not the QueueLog() app
- It uses global variables to pass values back from a different leg of the call


