Author Topic: [Dialout panel] Agents can't make outbound calls  (Read 531 times)

sonffrey

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
    • View Profile
    • Email
[Dialout panel] Agents can't make outbound calls
« on: October 31, 2016, 14:34:58 »
When agents makes outbound calls using dialout panel, it keeps calling their own extension, and when they pick up the call it ends. I don't know what might be the issue most probably my dial plan.

Trunk type: DAHDi trunk
Trunk Name:   g0

Below are the configurations:

Code: [Select]
; extension 28: agent custom dial
exten => 28,1,Answer
exten => 28,n,NoOp( "QM: Agent Custom Dial. Dialing ${EXTTODIAL} on queue ${OUTQUEUE}  made by '${QM_LOGIN}'" )
exten => 28,n,Set(QDIALER_QUEUE=${OUTQUEUE})
exten => 28,n,Set(QDIALER_NUMBER=${EXTTODIAL})
exten => 28,n,Set(QDIALER_AGENT=Agent/${AGENTCODE})
exten => 28,n,Set(QDIALER_CHANNEL=SIP/g0/${QDIALER_NUMBER})
exten => 28,n,Set(QueueName=${QDIALER_QUEUE})
exten => 28,n,MixMonitor(Q-${QDIALER_QUEUE}-${UNIQUEID}.WAV,b,)
;exten => 28,n,Set(CALLERID(all)="1234567890" <1234567890>) ; Uncomment and change this if you need to set your own caller ID
exten => 28,n,Goto(qm-queuedial,s,1)
exten => 28,n,Hangup

Code: [Select]
;
; ================================================================
; The following dialplan is used in order to make oubound calls
; that are tracked through QueueMetrics.
; See http://forum.queuemetrics.com/index.php?board=12.0
; ================================================================


[queuedial]
; this piece of dialplan is just a calling hook into the [qm-queuedial] context that actually does the
; outbound dialing - replace as needed - just fill in the same variables.
;exten => _XXX.,1,Set(QDIALER_QUEUE=q-${EXTEN:0:3})
;exten => _XXX.,n,Set(QDIALER_NUMBER=${EXTEN:3})
;exten => _XXX.,n,Set(QDIALER_AGENT=Agent/${CALLERID(num)})
;exten => _XXX.,n,Set(QDIALER_CHANNEL=DAHDI/g0/${QDIALER_NUMBER})
;exten => _XXX.,n,Set(QueueName=${QDIALER_QUEUE})
;exten => _XXX.,n,MixMonitor(Q-${QDIALER_QUEUE}-${UNIQUEID}.WAV,b,)
;exten => _XXX.,n,Set(CALLERID(all)="1234567890" <1234567890>) ; Uncomment and change this if you need to set your own caller ID
;exten => _XXX.,n,Goto(qm-queuedial,s,1)
;exten => _XXX.,n,Set(QDIALER_CHANNEL=DAHDI/g0/${QDIALER_NUMBER})

exten => _XXX.,1,Set(QDIALER_QUEUE=300)
exten => _XXX.,n,Set(QDIALER_NUMBER=${EXTEN:1})
exten => _XXX.,n,Set(QDIALER_AGENT=Agent/${CALLERID(num)})
exten => _XXX.,n,Set(QDIALER_CHANNEL=SIP/g0/${QDIALER_NUMBER})
exten => _XXX.,n,Set(QueueName=${300})
exten => _XXX.,n,MixMonitor(Q-${QDIALER_QUEUE}-${UNIQUEID}.WAV,b,)
exten => _XXX.,n,Goto(qm-queuedial,s,1)

Code: [Select]
[qm-queuedial]
; We use a global variable to pass values back from the answer-detect macro.
; STATUS = U unanswered
;        = A answered    (plus CAUSECOMPLETE=C when callee hung up)
; The 'g' dial parameter must be used in order to track callee disconnecting.
; Note that we'll be using the 'h' hook in any case to do the logging when channels go down.
; We set the CDR(accountcode) for live monitoring by QM.
;
exten => s,1,NoOp( "Outbound call - A:${QDIALER_AGENT} N:${QDIALER_NUMBER} Q:${QDIALER_QUEUE} Ch:${QDIALER_CHANNEL}" )
exten => s,n,Set(CDR(accountcode)=QDIALAGI)
exten => s,n,Set(ST=${EPOCH})
exten => s,n,Set(GM=QDV-${QDIALER_AGENT})
exten => s,n,Set(GLOBAL(${GM})=U)
exten => s,n,Set(GLOBAL(${GM}ans)=0)
exten => s,n,Macro(queuelog,${ST},${UNIQUEID},${QDIALER_QUEUE},${QDIALER_AGENT},CALLOUTBOUND,,${QDIALER_NUMBER})
exten => s,n,Dial(${QDIALER_CHANNEL},300,gM(queuedial-answer^${UNIQUEID}^${GM}^${QDIALER_QUEUE}^${QDIALER_AGENT}^${ST}))
exten => s,n,Set(CAUSECOMPLETE=${IF($["${DIALSTATUS}" = "ANSWER"]?C)})

sonffrey

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
    • View Profile
    • Email
Re: [Dialout panel] Agents can't make outbound calls
« Reply #1 on: October 31, 2016, 14:58:42 »
This is what I get

Code: [Select]
    -- Executing [28@queuemetrics:2] NoOp("Local/1029@from-internal-0001b16b;1", " "QM: Agent Custom Dial. Dialing 0628000055 on queue 300  made by 'Agent/1029'" ") in new stack
    -- Executing [28@queuemetrics:3] Set("Local/1029@from-internal-0001b16b;1", "QDIALER_QUEUE=300") in new stack
    -- Executing [28@queuemetrics:4] Set("Local/1029@from-internal-0001b16b;1", "QDIALER_NUMBER=0628000055") in new stack
    -- Executing [28@queuemetrics:5] Set("Local/1029@from-internal-0001b16b;1", "QDIALER_AGENT=Agent/1029") in new stack
    -- Executing [28@queuemetrics:6] Set("Local/1029@from-internal-0001b16b;1", "QDIALER_CHANNEL=SIP/g0/0628000055") in new stack
    -- Executing [28@queuemetrics:7] Set("Local/1029@from-internal-0001b16b;1", "QueueName=300") in new stack
    -- Executing [28@queuemetrics:8] MixMonitor("Local/1029@from-internal-0001b16b;1", "Q-300-1477921568.257562.WAV,b,") in new stack
    -- Executing [28@queuemetrics:9] Goto("Local/1029@from-internal-0001b16b;1", "qm-queuedial,s,1") in new stack
  == Begin MixMonitor Recording Local/1029@from-internal-0001b16b;1
    -- Goto (qm-queuedial,s,1)
    -- Executing [s@qm-queuedial:1] NoOp("Local/1029@from-internal-0001b16b;1", " "Outbound call - A:Agent/1029 N:0628000055 Q:300 Ch:SIP/g0/0628000055" ") in new stack
[2016-10-31 16:46:12] WARNING[9172][C-0000734b]: file.c:1230 ast_writefile: Unable to open file /var/spool/asterisk/monitor/Q-300-1477921568.257562.WAV: Permission denied
[2016-10-31 16:46:12] ERROR[9172][C-0000734b]: app_mixmonitor.c:583 mixmonitor_save_prep: Cannot open /var/spool/asterisk/monitor/Q-300-1477921568.257562.WAV
    -- Executing [s@qm-queuedial:2] Set("Local/1029@from-internal-0001b16b;1", "CDR(accountcode)=QDIALAGI") in new stack
    -- Executing [s@qm-queuedial:3] Set("Local/1029@from-internal-0001b16b;1", "ST=1477921572") in new stack
    -- Executing [s@qm-queuedial:4] Set("Local/1029@from-internal-0001b16b;1", "GM=QDV-Agent/1029") in new stack
    -- Executing [s@qm-queuedial:5] Set("Local/1029@from-internal-0001b16b;1", "GLOBAL(QDV-Agent/1029)=U") in new stack
  == Setting global variable 'QDV-Agent/1029' to 'U'
    -- Executing [s@qm-queuedial:6] Set("Local/1029@from-internal-0001b16b;1", "GLOBAL(QDV-Agent/1029ans)=0") in new stack
  == Setting global variable 'QDV-Agent/1029ans' to '0'
    -- Executing [s@qm-queuedial:7] Macro("Local/1029@from-internal-0001b16b;1", "queuelog,1477921572,1477921568.257562,300,Agent/1029,CALLOUTBOUND,,0628000055") in new stack
    -- Executing [s@macro-queuelog:1] Set("Local/1029@from-internal-0001b16b;1", "ADDINFO=|0628000055|") in new stack
[2016-10-31 16:46:12] WARNING[9171][C-0000734b]: pbx.c:1673 pbx_exec: The application delimiter is now the comma, not the pipe.  Did you forget to convert your dialplan?  (Set(ADDINFO=|0628000055|))
    -- Executing [s@macro-queuelog:2] QueueLog("Local/1029@from-internal-0001b16b;1", "300,1477921568.257562,Agent/1029,CALLOUTBOUND,|0628000055|") in new stack
    -- Executing [s@qm-queuedial:8] Dial("Local/1029@from-internal-0001b16b;1", "SIP/g0/0628000055,300,gM(queuedial-answer^1477921568.257562^QDV-Agent/1029^300^Agent/1029^1477921572)") in new stack
  == Using SIP RTP TOS bits 184
  == Using SIP RTP CoS mark 5

mirkox

  • Loway
  • Full Member
  • *
  • Posts: 187
  • Karma: 1
    • View Profile
Re: [Dialout panel] Agents can't make outbound calls
« Reply #2 on: October 31, 2016, 14:59:19 »
Hi sonffrey,

it would be really useful to know what happens in the Asterisk CLI while you try to do an outbound call

Thanks
Mirko

mirkox

  • Loway
  • Full Member
  • *
  • Posts: 187
  • Karma: 1
    • View Profile
Re: [Dialout panel] Agents can't make outbound calls
« Reply #3 on: October 31, 2016, 15:01:16 »
Which version of the dialplan file are you using?
Please try replace it with extensions_queuemetrics_18.conf

sonffrey

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
    • View Profile
    • Email
Re: [Dialout panel] Agents can't make outbound calls
« Reply #4 on: October 31, 2016, 15:19:21 »
I ran
Code: [Select]
asterisk -vvvvr I believe this is the Asterisk CLI output, I just took one call I made and attached.

This is what I get

Code: [Select]
    -- Executing [28@queuemetrics:2] NoOp("Local/1029@from-internal-0001b16b;1", " "QM: Agent Custom Dial. Dialing 0628000055 on queue 300  made by 'Agent/1029'" ") in new stack
    -- Executing [28@queuemetrics:3] Set("Local/1029@from-internal-0001b16b;1", "QDIALER_QUEUE=300") in new stack
    -- Executing [28@queuemetrics:4] Set("Local/1029@from-internal-0001b16b;1", "QDIALER_NUMBER=0628000055") in new stack
    -- Executing [28@queuemetrics:5] Set("Local/1029@from-internal-0001b16b;1", "QDIALER_AGENT=Agent/1029") in new stack
    -- Executing [28@queuemetrics:6] Set("Local/1029@from-internal-0001b16b;1", "QDIALER_CHANNEL=SIP/g0/0628000055") in new stack
    -- Executing [28@queuemetrics:7] Set("Local/1029@from-internal-0001b16b;1", "QueueName=300") in new stack
    -- Executing [28@queuemetrics:8] MixMonitor("Local/1029@from-internal-0001b16b;1", "Q-300-1477921568.257562.WAV,b,") in new stack
    -- Executing [28@queuemetrics:9] Goto("Local/1029@from-internal-0001b16b;1", "qm-queuedial,s,1") in new stack
  == Begin MixMonitor Recording Local/1029@from-internal-0001b16b;1
    -- Goto (qm-queuedial,s,1)
    -- Executing [s@qm-queuedial:1] NoOp("Local/1029@from-internal-0001b16b;1", " "Outbound call - A:Agent/1029 N:0628000055 Q:300 Ch:SIP/g0/0628000055" ") in new stack
[2016-10-31 16:46:12] WARNING[9172][C-0000734b]: file.c:1230 ast_writefile: Unable to open file /var/spool/asterisk/monitor/Q-300-1477921568.257562.WAV: Permission denied
[2016-10-31 16:46:12] ERROR[9172][C-0000734b]: app_mixmonitor.c:583 mixmonitor_save_prep: Cannot open /var/spool/asterisk/monitor/Q-300-1477921568.257562.WAV
    -- Executing [s@qm-queuedial:2] Set("Local/1029@from-internal-0001b16b;1", "CDR(accountcode)=QDIALAGI") in new stack
    -- Executing [s@qm-queuedial:3] Set("Local/1029@from-internal-0001b16b;1", "ST=1477921572") in new stack
    -- Executing [s@qm-queuedial:4] Set("Local/1029@from-internal-0001b16b;1", "GM=QDV-Agent/1029") in new stack
    -- Executing [s@qm-queuedial:5] Set("Local/1029@from-internal-0001b16b;1", "GLOBAL(QDV-Agent/1029)=U") in new stack
  == Setting global variable 'QDV-Agent/1029' to 'U'
    -- Executing [s@qm-queuedial:6] Set("Local/1029@from-internal-0001b16b;1", "GLOBAL(QDV-Agent/1029ans)=0") in new stack
  == Setting global variable 'QDV-Agent/1029ans' to '0'
    -- Executing [s@qm-queuedial:7] Macro("Local/1029@from-internal-0001b16b;1", "queuelog,1477921572,1477921568.257562,300,Agent/1029,CALLOUTBOUND,,0628000055") in new stack
    -- Executing [s@macro-queuelog:1] Set("Local/1029@from-internal-0001b16b;1", "ADDINFO=|0628000055|") in new stack
[2016-10-31 16:46:12] WARNING[9171][C-0000734b]: pbx.c:1673 pbx_exec: The application delimiter is now the comma, not the pipe.  Did you forget to convert your dialplan?  (Set(ADDINFO=|0628000055|))
    -- Executing [s@macro-queuelog:2] QueueLog("Local/1029@from-internal-0001b16b;1", "300,1477921568.257562,Agent/1029,CALLOUTBOUND,|0628000055|") in new stack
    -- Executing [s@qm-queuedial:8] Dial("Local/1029@from-internal-0001b16b;1", "SIP/g0/0628000055,300,gM(queuedial-answer^1477921568.257562^QDV-Agent/1029^300^Agent/1029^1477921572)") in new stack
  == Using SIP RTP TOS bits 184
  == Using SIP RTP CoS mark 5

mirkox

  • Loway
  • Full Member
  • *
  • Posts: 187
  • Karma: 1
    • View Profile
Re: [Dialout panel] Agents can't make outbound calls
« Reply #5 on: October 31, 2016, 15:20:55 »
Hi, yes I saw it , we replied at the same time  ;D

sonffrey

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
    • View Profile
    • Email
Re: [Dialout panel] Agents can't make outbound calls
« Reply #6 on: October 31, 2016, 15:21:36 »
Which version of the dialplan file are you using?
Please try replace it with extensions_queuemetrics_18.conf


I am using extensions_queuemetrics_18.conf dialplan

sonffrey

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
    • View Profile
    • Email
Re: [Dialout panel] Agents can't make outbound calls
« Reply #7 on: November 01, 2016, 12:28:24 »
Anyone to help? Still not working.

mirkox

  • Loway
  • Full Member
  • *
  • Posts: 187
  • Karma: 1
    • View Profile
Re: [Dialout panel] Agents can't make outbound calls
« Reply #8 on: November 02, 2016, 10:56:58 »
Looks like an older version, try with this one

Code: [Select]

;
; ============================================================================
; The following dialplan context is used by QueueMetrics
; through the manager API.
; - $Id: extensions_queuemetrics.conf,v 1.26 2015/06/10 10:34:02 marcos Exp $
;
; You should modify it to fit your system.
;
; To enable this file, copy it to /etc/asterisk
; and add the line:
;   #include extensions_queuemetrics.conf
; by the end of your extensions.conf file.
; ============================================================================
;

[queuemetrics]
; extension 10 is a dummy end point
exten => 10,1,Answer
exten => 10,2,Wait(10)
exten => 10,3,Hangup

; extension 11 makes remote monitoring possible
exten => 11,1,Answer
exten => 11,2,NoOp( "QM_AGENT_CODE: ${QM_AGENT_CODE}" )
exten => 11,3,NoOp( "QM_EXT_MONITOR: ${QM_EXT_MONITOR}" )
exten => 11,4,NoOp( "QM_AGENT_EXT: ${QM_AGENT_EXT}" )
exten => 11,5,NoOp( "QM_LOGIN: ${QM_LOGIN} / ${QM_CLASS}" )
exten => 11,6,NoOp( "QM_AGENT_LOGEXT: ${QM_AGENT_LOGEXT}" )
exten => 11,7,ChanSpy(${QM_AGENT_CODE})
exten => 11,8,Hangup

; extension 12: set call status code
exten => 12,1,Answer
exten => 12,2,NoOp( "QM: Setting call status '${CALLSTATUS}' on call '${CALLID}' for agent '${AGENTCODE}' made by '${QM_LOGIN}'" )
exten => 12,3,System( echo "${EPOCH}|${CALLID}|NONE|Agent/${AGENTCODE}|CALLSTATUS|${CALLSTATUS}" >> /var/log/asterisk/queue_log )
exten => 12,4,Hangup

; extension 14 makes remote monitoring possible for OUTBOUND CALLS
exten => 14,1,Answer
exten => 14,2,NoOp( "QM_AGENT_CODE: ${QM_AGENT_CODE}" )
exten => 14,3,NoOp( "QM_EXT_MONITOR: ${QM_EXT_MONITOR}" )
exten => 14,4,NoOp( "QM_AGENT_EXT: ${QM_AGENT_EXT}" )
exten => 14,5,NoOp( "QM_LOGIN: ${QM_LOGIN} / ${QM_CLASS}" )
exten => 14,6,ChanSpy(Local/${QM_AGENT_CODE:6}@from-internal)
exten => 14,7,Hangup

; extension 16: set call status code
exten => 16,1,Answer
exten => 16,2,NoOp( "QM: Setting call feature '${FEATCODE}' on call '${CALLID}' for agent '${AGENTCODE}' made by '${QM_LOGIN}' with freetext ${FEATTEXT}" )
exten => 16,3,System( echo "${EPOCH}|${CALLID}|NONE|Agent/${AGENTCODE}|INFO|FTR|${FEATCODE}|${FEATTEXT}" >> /var/log/asterisk/queue_log )
exten => 16,4,Hangup

; extension 17: unset call status code
exten => 17,1,Answer
exten => 17,2,NoOp( "QM: Removing call feature '${FEATCODE}' on call '${CALLID}' for agent '${AGENTCODE}' made by '${QM_LOGIN}' with freetext ${FEATTEXT}" )
exten => 17,3,System( echo "${EPOCH}|${CALLID}|NONE|Agent/${AGENTCODE}|INFO|NOFTR|${FEATCODE}|${FEATTEXT}" >> /var/log/asterisk/queue_log )
exten => 17,4,Hangup

; extension 20: agent callback login
;               For this to work, there must be no password on the agent.
exten => 20,1,Answer
exten => 20,2,NoOp( "QM: Logging on Agent/${AGENTCODE} to extension ${AGENT_EXT}@from-internal made by '${QM_LOGIN}'" )
exten => 20,3,AgentCallBackLogin(${AGENTCODE},,${AGENT_EXT}@from-internal)
exten => 20,4,Hangup

; extension 21: agent callback logoff
exten => 21,1,Answer
exten => 21,2,NoOp( "QM: Logging off Agent/${AGENTCODE} made by '${QM_LOGIN}'" )
exten => 21,3,System(asterisk -rx "agent logoff Agent/${AGENTCODE}")
exten => 21,4,Hangup

; extension 22: agent pause (with pause code)
exten => 22,1,Answer
exten => 22,2,NoOp( "QM: Pausing Agent/${AGENTCODE} with pause reason '${PAUSEREASON}' made by '${QM_LOGIN}' " )
exten => 22,3,PauseQueueMember(,Agent/${AGENTCODE})
exten => 22,4,System( echo "${EPOCH}|${UNIQUEID}|NONE|Agent/${AGENTCODE}|PAUSEREASON|${PAUSEREASON}" >> /var/log/asterisk/queue_log )
exten => 22,5,Hangup

; extension 23: agent unpause
exten => 23,1,Answer
exten => 23,2,NoOp( "QM: Unpausing Agent/${AGENTCODE} made by '${QM_LOGIN}' " )
exten => 23,3,UnpauseQueueMember(,Agent/${AGENTCODE})
exten => 23,4,Hangup

; extension 24: agent addqueuemember (for asterisk v1.2)
exten => 24,1,Answer
exten => 24,2,NoOp( "QM: AddQueueMember (asterisk v1.2) Agent/${AGENTCODE} on queue ${QUEUENAME} made by '${QM_LOGIN}'" )
exten => 24,3,System( echo "${EPOCH}|${UNIQUEID}|${QUEUENAME}|Local/${AGENTCODE}@from-internal|ADDMEMBER|" >> /var/log/asterisk/queue_log )
exten => 24,4,Hangup

; extension 25: agent addqueuemember (for asterisk v1.4+)
exten => 25,1,Answer
exten => 25,2,NoOp( "QM: AddQueueMember (asterisk v1.4+) Agent/${AGENTCODE} on queue ${QUEUENAME} made by '${QM_LOGIN}' with prioritylabel '${QM_AGENT_PRIOLBL}' and prioritynum '${QM_AGENT_PRIONUM}'" )
exten => 25,3,AddQueueMember(${QUEUENAME},Local/${AGENTCODE}@from-internal)
exten => 25,4,Hangup

; extension 26: agent removequeuemember
exten => 26,1,Answer
exten => 26,2,NoOp( "QM: RemoveQueueMember (asterisk v1.2) Agent/${AGENTCODE} on queue ${QUEUENAME} made by '${QM_LOGIN}'" )
exten => 26,3,System( echo "${EPOCH}|${UNIQUEID}|${QUEUENAME}|Local/${AGENTCODE}@from-internal|REMOVEMEMBER|" >> /var/log/asterisk/queue_log )
exten => 26,4,Hangup

; extension 27: agent removequeuemember (for asterisk v1.4+)
exten => 27,1,Answer
exten => 27,2,NoOp( "QM: RemoveQueueMember (asterisk v1.4+) Agent/${AGENTCODE} on queue ${QUEUENAME} made by '${QM_LOGIN}'" )
exten => 27,3,RemoveQueueMember(${QUEUENAME},Local/${AGENTCODE}@from-internal)
exten => 27,4,Hangup

; extension 28: agent custom dial
exten => 28,1,Answer
exten => 28,n,NoOp( "QM: Agent Custom Dial. Dialing ${EXTTODIAL} on queue ${OUTQUEUE}  made by '${QM_LOGIN}'" )
exten => 28,n,Set(QDIALER_QUEUE=${OUTQUEUE})
exten => 28,n,Set(QDIALER_NUMBER=${EXTTODIAL})
exten => 28,n,Set(QDIALER_AGENT=Agent/${AGENTCODE})
exten => 28,n,Set(QDIALER_CHANNEL=SIP/${QDIALER_NUMBER})
exten => 28,n,Set(QueueName=${QDIALER_QUEUE})
exten => 28,n,MixMonitor(Q-${QDIALER_QUEUE}-${UNIQUEID}.WAV,b,)
;exten => 28,n,Set(CALLERID(all)="1234567890" <1234567890>) ; Uncomment and change this if you need to set your own caller ID
exten => 28,n,Goto(qm-queuedial,s,1)
exten => 28,n,Hangup

; extension 29: agent send sms (for asterisk v10+)
;exten => 29,1,NoOp( "QM: Send Text from Live Page. Sending text to ${EXTTODIAL} made by '${QM_LOGIN}' " )
;exten => 29,n,Set(MESSAGE(body)=From: ${QM_LOGIN} - ${MESSAGEBODY})
;exten => 29,n,MessageSend(sip:${EXTTODIAL})
;exten => 29,n,Hangup

; extension 30: soft hangup
exten => 30,1,NoOp( "QM: Call Hangup made by ${QM_LOGIN} for callID: ${CALLID} with agent code ${AGENTCODE} from extension ${QM_AGENT_LOGEXT}")
exten => 30,n,ChannelRedirect(${CALLID},queuemetrics,10,3)
exten => 30,n,Hangup

; extension 31: redirect
exten => 31,1,NoOp( " QM: Call redirect ,ade by ${QM_LOGIN} for callID: ${CALLID} to extension ${REDIR_EXT}")
exten => 31,n,ChannelRedirect(${CALLID},from-internal,${REDIR_EXT},1)
exten => 31,n,Hangup

; extension 32: agent pause with hotdesking (with pause code)
exten => 32,1,Answer
exten => 32,2,NoOp( "QM: Pausing Agent/${AGENTCODE} at extension SIP/${QM_AGENT_LOGEXT} with pause reason '${PAUSEREASON}' made by '${QM_LOGIN}' " )
exten => 32,3,PauseQueueMember(,SIP/${QM_AGENT_LOGEXT})
exten => 32,4,System( echo "${EPOCH}|${UNIQUEID}|NONE|Agent/${AGENTCODE}|PAUSEREASON|${PAUSEREASON}" >> /var/log/asterisk/queue_log )
exten => 32,5,Hangup

; extension 33: agent unpause with hotdesking
exten => 33,1,Answer
exten => 33,2,NoOp( "QM: Unpausing Agent/${AGENTCODE} at extension SIP/${QM_AGENT_LOGEXT} made by '${QM_LOGIN}' " )
exten => 33,3,UnpauseQueueMember(,SIP/${QM_AGENT_LOGEXT})
exten => 33,4,Hangup

; extension 35: agent addqueuemember with hotdesking (for asterisk v1.4+)
exten => 35,1,Answer
exten => 35,2,NoOp( "QM: AddQueueMember (asterisk v1.4+) Agent/${AGENTCODE} at extension SIP/${QM_AGENT_LOGEXT} on queue ${QUEUENAME} made by '${QM_LOGIN}' with prioritylabel '${QM_AGENT_PRIOLBL}' and prioritynum '${QM_AGENT_PRIONUM}'" )
exten => 35,3,Macro(queuelog,${EPOCH},${UNIQUEID},NONE,Agent/${AGENTCODE},HOTDESK,SIP/${QM_AGENT_LOGEXT})
exten => 35,4,AddQueueMember(${QUEUENAME},SIP/${QM_AGENT_LOGEXT})
exten => 35,5,Hangup

; extension 37: agent removequeuemember with hotdesking (for asterisk v1.4+)
exten => 37,1,Answer
exten => 37,2,NoOp( "QM: RemoveQueueMember (asterisk v1.4+) Agent/${AGENTCODE} at extension SIP/${QM_AGENT_LOGEXT} on queue ${QUEUENAME} made by '${QM_LOGIN}'" )
exten => 37,3,RemoveQueueMember(${QUEUENAME},SIP/${QM_AGENT_LOGEXT})
exten => 37,4,Hangup

;
; ================================================================
; The following dialplan is used in order to make oubound calls
; that are tracked through QueueMetrics.
; See http://forum.queuemetrics.com/index.php?board=12.0
; ================================================================


[queuedial]
; this piece of dialplan is just a calling hook into the [qm-queuedial] context that actually does the
; outbound dialing - replace as needed - just fill in the same variables.
exten => _XXX.,1,Set(QDIALER_QUEUE=q-${EXTEN:0:3})
exten => _XXX.,n,Set(QDIALER_NUMBER=${EXTEN:3})
exten => _XXX.,n,Set(QDIALER_AGENT=Agent/${CALLERID(num)})
exten => _XXX.,n,Set(QDIALER_CHANNEL=SIP/${QDIALER_NUMBER})
exten => _XXX.,n,Set(QueueName=${QDIALER_QUEUE})
exten => _XXX.,n,MixMonitor(Q-${QDIALER_QUEUE}-${UNIQUEID}.WAV,b,)
;exten => _XXX.,n,Set(CALLERID(all)="1234567890" <1234567890>) ; Uncomment and change this if you need to set your own caller ID
exten => _XXX.,n,Goto(qm-queuedial,s,1)


[queuedial-loggedon]
; This piece of dialplan will let only logged on agents dial out
exten => _XXX.,1,Set(QDIALER_QUEUE=q-${EXTEN:0:3})
exten => _XXX.,n,Set(QDIALER_NUMBER=${EXTEN:3})
exten => _XXX.,n,Set(QDIALER_AGENT=Agent/${AGENTBYCALLERID_${CALLERID(num)}})
exten => _XXX.,n,Set(QDIALER_CHANNEL=SIP/${QDIALER_NUMBER})
exten => _XXX.,n,Set(QueueName=${QDIALER_QUEUE})
exten => _XXX.,n,MixMonitor(Q-${QDIALER_QUEUE}-${UNIQUEID}.WAV,b,)
exten => _XXX.,n,GotoIf($[${LEN(${QDIALER_AGENT})} > 6]?qm-queuedial,s,1)
exten => _XXX.,n,NoOp,Extension ${CALLERID(num)} is not logged on as agent.
exten => _XXX.,n,Playback(agent-loggedoff)
exten => _XXX.,n,Congestion


[qm-queuedial]
; We use a global variable to pass values back from the answer-detect macro.
; STATUS = U unanswered
;        = A answered    (plus CAUSECOMPLETE=C when callee hung up)
; The 'g' dial parameter must be used in order to track callee disconnecting.
; Note that we'll be using the 'h' hook in any case to do the logging when channels go down.
; We set the CDR(accountcode) for live monitoring by QM.
;
exten => s,1,NoOp( "Outbound call - A:${QDIALER_AGENT} N:${QDIALER_NUMBER} Q:${QDIALER_QUEUE} Ch:${QDIALER_CHANNEL}" )
exten => s,n,Set(CDR(accountcode)=QDIALAGI)
exten => s,n,Set(ST=${EPOCH})
exten => s,n,Set(GM=QDV-${QDIALER_AGENT})
exten => s,n,Set(GLOBAL(${GM})=U)
exten => s,n,Set(GLOBAL(${GM}ans)=0)
exten => s,n,Macro(queuelog,${ST},${UNIQUEID},${QDIALER_QUEUE},${QDIALER_AGENT},CALLOUTBOUND,,${QDIALER_NUMBER})
exten => s,n,Dial(${QDIALER_CHANNEL},300,gM(queuedial-answer^${UNIQUEID}^${GM}^${QDIALER_QUEUE}^${QDIALER_AGENT}^${ST}))
exten => s,n,Set(CAUSECOMPLETE=${IF($["${DIALSTATUS}" = "ANSWER"]?C)})

; Trapping call termination here
exten => h,1,NoOp( "Call exiting: status ${GLOBAL(${GM})} answered at: ${GLOBAL(${GM}ans)} DS: ${DIALSTATUS}"  )
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,Macro(queuelog,${EPOCH},${UNIQUEID},${QDIALER_QUEUE},${QDIALER_AGENT},ABANDON,1,1,${WT})
exten => h,n,Hangup()

; call answered: agent/callee hung
exten => h,n(case-A)i,Set(COMPLETE=${IF($["${CAUSECOMPLETE}" = "C"]?COMPLETECALLER:COMPLETEAGENT)})
exten => h,n,Set(WT=$[${GLOBAL(${GM}ans)} - ${ST}])
exten => h,n,Set(CT=$[${EPOCH} - ${GLOBAL(${GM}ans)}])
exten => h,n,Macro(queuelog,${EPOCH},${UNIQUEID},${QDIALER_QUEUE},${QDIALER_AGENT},${COMPLETE},${WT},${CT})
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,Macro(queuelog,${NOW},${ARG1},${ARG3},${ARG4},CONNECT,${WD})
exten => s,n,Set(GLOBAL(${ARG2})=A)
exten => s,n,Set(GLOBAL(${ARG2}ans)=${NOW})
exten => s,n,NoOp("Macro queuedial-answer terminating" )

[macro-queuelog]
; The advantage of using this macro is that you can choose whether to use the Shell version
; (where you have complete control of what gets written) or the Application version (where you
; do not need a shellout, so it's way faster).
;
; Expecting  $ARG1: Timestamp
;            $ARG2: Call-id
;            $ARG3: Queue
;            $ARG4: Agent
;            $ARG5: Verb
;            $ARG6: Param1
;            $ARG7: Param2
;            $ARG8: Param3
;
;exten => s,1,System( echo "${ARG1}|${ARG2}|${ARG3|${ARG4}|${ARG5}|${ARG6}|${ARG7}|${ARG8}" >> /var/log/asterisk/queue_log )
exten => s,1,QueueLog(${ARG3},${ARG2},${ARG4},${ARG5},${ARG6}|${ARG7}|${ARG8})

[queue-hold-logger]
exten => s-CONTROL_HOLD,1,Macro(queuelog,${EPOCH},${INUNIQUEID},${INQUEUENAME},NONE,CALLERONHOLD)
exten => s-CONTROL_HOLD,n,Hangup
exten => s-CONTROL_UNHOLD,1,Macro(queuelog,${EPOCH},${INUNIQUEID},${INQUEUENAME},NONE,CALLEROFFHOLD)
exten => s-CONTROL_UNHOLD,n,Hangup

[queue-on-answer]
exten => s,1,Set(FRAME_TRIGGER(CONTROL_HOLD,CONTROL_UNHOLD)=queue-hold-logger)
exten => s,n,Return

[queue-enterqueue]
; ${ARG1} - QueueName
exten => s,1,Set(__INUNIQUEID=${UNIQUEID})
exten => s,n,Set(__INQUEUENAME=${ARG1})
exten => s,n,Queue(${INQUEUENAME},t,,,,,,queue-on-answer)
exten => s,n,Return

; --------------------------------------------------------------------
; $Log: extensions_queuemetrics.conf,v $
; Revision 1.26  2015/06/10 10:34:02  marcos
; no message
;
; Revision 1.25  2015/05/08 10:57:57  marcos
; Merge 24 on trunk
;
; Revision 1.24.10.1  2014/11/06 14:52:46  marcos
; #2461: RTTF: Agent Page
;
; Revision 1.24  2012/05/04 08:46:55  marcos
; #1624: New actions on call processed on the realtime page
;
; Revision 1.23  2012/04/12 10:15:14  marcos
; #733: Log-on/off agents from the RT page
;
; Revision 1.22  2012/02/21 10:17:39  lenz-mobile
; #1520 - Uso CALLERONHOLD e CALLEROFFHOLD invece di STARTMOH / ENDMOH
;
; Revision 1.21  2012/01/31 09:30:37  marcos
; #1524 - MOH: tracking on vanilla Asterisk
;
; Revision 1.20  2011/11/28 10:52:50  lenz-mobile
; #1505 - Class info su Asterisk
;
; Revision 1.19  2010/12/22 15:39:49  marcos
; #1223: Setting caller-id for outbound dial
;
; Revision 1.18  2010/12/22 10:43:16  marcos
; #1216: Typo
;
; Revision 1.17  2010/12/21 17:12:59  marcos
; #1218: Passing penalties to Addmember entries
;
; Revision 1.16  2010/04/13 15:57:08  marcos
; 1062: Hotdesking: modifiche per Agents page
;
; Revision 1.15  2010/04/13 13:08:15  marcos
; 1062: Hotdesking: modifiche per Agents page
;
; Revision 1.14  2010/04/08 10:25:52  marcos
; #1039: Hotdesking: campo extension sbagliato a livello Asterisk
;
; Revision 1.13  2010/02/01 14:45:17  marcos
; #968: Default URLs for outbound queues are not displayed
;
; Revision 1.12  2009/11/19 08:24:23  lenz-mobile
; Bug #930 - Fixed NoOp command incompatible with 1.6.x
;
; Revision 1.11  2009/08/03 08:15:55  marcos
; #788: Pipes are forbidden by asterisk 1.6.
;
; Revision 1.10  2009/06/26 15:12:22  lenz-mobile
; Longer timeout for the outbound dial command.
;
; Revision 1.9  2009/04/09 10:18:39  marcos
; Added the extension 14 for monitoring outbound calls
;
; Revision 1.8  2009/03/06 11:10:17  marcos
; #620: Custom dial on agent's live page
;
; Revision 1.7  2009/02/16 10:37:47  marcos
; #619: Add AddQueueMember and RemoveQueueMember triggering buttons on agent's live page.
;
; Revision 1.6  2009/02/10 18:17:26  lenz
; Bug #498: CALLOUTBOUND
;
; Revision 1.5  2009/01/12 12:05:47  marcos
; #600 Added QM_LOGIN on all asterisk dialplan calls
;
; Revision 1.4  2008/06/10 16:53:50  lenz
; Aggiunto[queuedial-loggedon] per tutorial outbound 2.0
;
; Revision 1.3  2008/06/07 11:16:58  lenz
; Pure-scripting outbound solution.
;
; Revision 1.2  2007/07/30 15:43:55  lenz
; Bug #173: default compatibili con TrixBox.
;
; Revision 1.1  2007/06/18 13:30:24  lenz
; Prima versione.
;
;
;