Author Topic: TRACE CALLS FROM NON QUEUE  (Read 3157 times)

jucha

  • Newbie
  • *
  • Posts: 24
  • Karma: 2
    • View Profile
TRACE CALLS FROM NON QUEUE
« on: September 02, 2011, 17:44:17 »
Hello
As everyone knows, asterisk does not report calls that are not of a queue.
For supervisors is annoying, that they are available, when in reality this agents busy with a call received by transfer.

I have this approach taken from qdial.

This works well only if the calls are not transferred.
I need help to detect trasnferidas and calls when you are hanging.

extensions_custom.conf
#include extensions_queuemetrics_18.conf

[from-internal-custom]
include => queuemetrics


extensions_queuemetrics_18.conf

; JUCHA:
exten => 2103,1,Gosub(qm-nonqueuecalls,s,1(${EXTEN},2901,${CALLERID(all)}))
exten => 2103,2,Hangup()
exten => 2101,1,Gosub(qm-nonqueuecalls,s,1(${EXTEN},2901,${CALLERID(all)}))
exten => 2101,2,Hangup()


; init JUCHA
[qm-nonqueuecalls]
;ARG1=EXT
;ARG2=QUEUE
;ARG3=CALLERID

exten => s,1,Answer
exten => s,n,NoOp("context qm-nonqueuecalls enter")
exten => s,n,Set(CDR(accountcode)=QDIALAGI)
exten => s,n,Set(ST=${EPOCH})
exten => s,n,Set(GLOBAL(${GM})=U)
exten => s,n,Set(GLOBAL(${GM}ans)=0)
;exten => s,n,Macro(queuelog,${ST},${UNIQUEID},${ARG2},,CALLINBOUND,,${ARG1})
exten => s,n,Dial(SIP/${ARG1},300,gM(qm-nonqueuecalls^${UNIQUEID}^SIP/${ARG1}^${ARG2}^${GM}^${ST}))
exten => s,n,Set(CAUSECOMPLETE=${IF($["${DIALSTATUS}" = "ANSWER"]?C)})

; Trapping call termination here
exten => h,1,Goto(case-${GLOBAL(${GM})})
exten => h,n,NoOp("JUCHA ARG2" ${ARG1} ${ARG2} )
exten => h,n,Hangup()

; Call unanswered
exten => h,n(case-U),Set(WT=$[${EPOCH} - ${ST}])
exten => h,n,Macro(queuelog,${EPOCH},${UNIQUEID},${ARG2},SIP/${ARG1},ABANDON,1,1,${WT})
exten => h,n,Hangup()

; call answered: agent/callee hung
exten => h,n(case-A)i,Set(COMPLETE=${IF($["${CAUSECOMPLETE}" = "C"]?COMPLETEAGENT:COMPLETECALLER)})
exten => h,n,Set(WT=$[${GLOBAL(${GM}ans)} - ${ST}])
exten => h,n,Set(CT=$[${EPOCH} - ${GLOBAL(${GM}ans)}])

exten => h,n,NoOp("JUCHA ARG1" ${ARG1} ${ARG2} ${EXTEN} ${CALLERID(num)} )

exten => h,n,Macro(queuelog,${EPOCH},${UNIQUEID},${ARG2},SIP/${ARG1},${COMPLETE},${WT},${CT})
exten => h,n,Hangup()


[macro-qm-nonqueuecalls]
;ARG1=UNIQUEID
;ARG2=EXT
;ARG3=QUEUE
;ARG4=GM
;ARG5=ST

exten => s,1,NoOp("Macro qm-nonqueuecalls enter")
exten => s,n,NoOp("JUCHA EXT" ${EXTEN}  ${CALLERID(num)} )
exten => s,n,Set(NOW=${EPOCH})
exten => s,n,Set(WD=$[${NOW} - ${ARG5}])
exten => s,n,Macro(queuelog,${NOW},${ARG1},${ARG3},${ARG2},CONNECT,${WD},${UNIQUEID})
exten => s,n,Set(GLOBAL(${ARG4})=A)
exten => s,n,Set(GLOBAL(${ARG4}ans)=${NOW})
exten => s,n,NoOp("Macro qm-nonqueuecalls exit")
; end JUCHA

call enter to queue
call conected
call transfered from 2101 to 2103
event from 2101
never event from 2103

tail -f /var/log/asterisk/queue_log
1314977786|1314977786.3584|2901|NONE|ENTERQUEUE||2010|1
1314977787|1314977786.3584|2901|SIP/2101|CONNECT|1|1314977786.3586|0
1314977817|1314977817.3588|2901|SIP/2103|CONNECT|0|1314977817.3589|
1314977818|1314977786.3584|2901|SIP/2101|TRANSFER|s|qm-nonqueuecalls|1|31|1


QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Re: TRACE CALLS FROM NON QUEUE
« Reply #1 on: September 06, 2011, 10:15:18 »
yes it looks correct to me. Good idea!  ;)

jucha

  • Newbie
  • *
  • Posts: 24
  • Karma: 2
    • View Profile
Re: TRACE CALLS FROM NON QUEUE
« Reply #2 on: September 08, 2011, 00:08:36 »
Hello.

Using asterisk built in function for transfer works better and i can to see the state of agents.