Author Topic: Sharing: hack extensions_queue.conf for Asterisk 1.2 to show custom callerid  (Read 4430 times)

dionv

  • Newbie
  • *
  • Posts: 16
  • Karma: 2
    • View Profile
Thought I'd share this, as it may help someone else out.

If you need to broadcast a custom callerid when dialling out, the stock extensions_queuemetrics.conf will not work (in my testing, at least).

Let's say your main number is 615-555-1212, and you have rollover lines of 615-555-1213 and 519-615-1214. Dialling out will pick one of those rollover lines and broadcast that number as the callerid. Someone calling back on that number gets a busy signal or dumped into the wrong area of your phone tree. It all depends on how your system is setup. Plus it confuses them when they see 615-555-1214 on their call display, as they do not know your company by that number. Or, you are running a multi-project contact centre and need to show a specific callback number for each client.

If you use the "outbound callerid" setting in the trunk to set your callerid to 615-555-1212, then all outbound calls will appear in QM as being from Agent/6155551212, which will make it difficult to track who actually made the call.

I was not able to find the right variable in Asterisk 1.2 (we use Trixbox CE 2.2) that would help with this, so I ended up creating a hack to handle a couple of things. First the [queuedial] section:

Quote
[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,NoOp( "Entering queuedial context..." )
exten => _XXX.,n,Set(QDIALER_QUEUE=${EXTEN:0:3})
exten => _XXX.,n,Set(QDIALER_NUMBER=${EXTEN:3})
; Let's get the agent's extension now, before we lose it
exten => _XXX.,n,Set(QDIALER_AGENT=${CALLERID(num)})
; Note, the QueueName is prefixed with "outq", you can choose your own, of course
exten => _XXX.,n,Set(QueueName=outq${QDIALER_QUEUE})
; This is one long line for debugging, you can comment it out if you want
exten => _XXX.,n,NoOp( "Outbound call -> Agent:${QDIALER_AGENT} NumberToCall:${QDIALER_NUMBER} QueueNumber:${QDIALER_QUEUE} QueueName:${QueueName} Ch:${QDIALER_CHANNEL}" )
; Note, we're creating a filename like: outq123-20090322-145523-123456789.1234.WAV
exten => _XXX.,n,MixMonitor(${QueueName}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${UNIQUEID}.WAV|b|)
; The following calls a Gosub based on the QueueName to set callerid and outbound channel
exten => _XXX.,n,NoOp( "Gosub setcid-${QueueName} next..." )
exten => _XXX.,n,Gosub(setcid-${QueueName})
exten => _XXX.,n,NoOp( "Returning from setting callerid..." )
; Now we call qm-queuedial
exten => _XXX.,n(call-qm-queuedial),NoOp( "Going to call qm-queuedial..." )
exten => _XXX.,n,Goto(qm-queuedial,s,1)
exten => _XXX.,n,Congestion


; Set the outbound CALLERID, based on the project code used
; 102 = Project Alpha
exten => _XXX.,n(setcid-outq102),Set(CALLERID(all)=Project Alpha <8665551212>)
; Note, this trunk uses a "6" prefix for dialling out, we set it here...
exten => _XXX.,n,Set(QDIALER_CHANNEL=IAX2/alphatrunk/6${QDIALER_NUMBER})
exten => _XXX.,n,NoOp( "Callerid set to: ${CALLERID(all) using channel: $QDIALER_CHANNEL" )
exten => _XXX.,n,Return
; 104 = Project Beta
exten => _XXX.,n(setcid-outq104),Set(CALLERID(all)=Beta Support <8665551234>)
exten => _XXX.,n,Set(QDIALER_CHANNEL=SIP/mysiptrunk/${QDIALER_NUMBER})
exten => _XXX.,n,NoOp( "Callerid set to: ${CALLERID(all) using channel: $QDIALER_CHANNEL" )
exten => _XXX.,n,Return
; 999 = Main line
exten => _XXX.,n(setcid-outq999),Set(CALLERID(all)=My Company <6155551212>)
exten => _XXX.,n,Set(QDIALER_CHANNEL=SIP/mysiptrunk/${QDIALER_NUMBER})
exten => _XXX.,n,NoOp( "Callerid set to: ${CALLERID(all) using channel: $QDIALER_CHANNEL" )
exten => _XXX.,n,Return

And then in the [qm-queuedial] we adjust for Asterisk 1.2 by calling the queueDial.agi script:

Quote
[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( "Entering qm-queuedial. Outbound call info -> 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)
; Note that we pass QueueName to queueDial.agi, instead of QDIALER_QUEUE
exten => s,n,DeadAGI(queueDial.agi|${QDIALER_NUMBER}|${QDIALER_CHANNEL}|${QueueName}|Local/${QDIALER_AGENT})
exten => s,n,Set(CAUSECOMPLETE=${IF($["${DIALSTATUS}" = "ANSWER"]?C)})

; Note sure if this section is still needed/used since we are using queueDial.agi, but it doesn't seem to hurt anything
; Trapping call termination here
exten => h,1,NoOp( "qm-queuedial Call exiting: status ${GLOBAL(${GM})} answered at: ${GLOBAL(${GM}ans)} DIAL_STATUS: ${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,NoOp( "qm-queuedial UNanswered case flow" )
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,NoOp( "qm-queuedial answered case flow" )
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()

I'm sure there is a more elegant way to do this, but it does not seem easily possible with Asterisk 1.2.

Now, outbound calls will appear in QM with the proper information to let you know which person made the call.

Hopefully this will help someone.

Comments/feedback welcomed.

DionV

QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Thanks a lot for sharing! :D

carlosmp

  • Newbie
  • *
  • Posts: 27
  • Karma: 0
    • View Profile
It's been a while since this post, but couldn't you add a line in the queuedial-loggedon context as follows:

exten => _XXX.,n,ExecIf($[ "${QDIALER_QUEUE}" = "555" ] ,Set,CALLERID(all)="Customer Service" <5555555555>)

You could simply have one line per outbound queue, and have them all in one place.  You could also have a default "" to send out in case there isn't a match.
« Last Edit: April 05, 2010, 02:54:25 by carlosmp »