Author Topic: Track inbound direct call (outside of an inbound queue)  (Read 8398 times)

peterbokune

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
    • View Profile
Hi,

I have a group of users, members in a queue, who will give out their direct number for callback.  These direct inbound calls obviously don't appear in queue stats.  Their manager would like their call activity to be recorded and reported.

Has this already been done and I just can't find the thread?

My initial thought was to add a queue and put his agents into the queue (9999) named Direct Inbound.  In the dialplan [from-pstn-custom] I'd use the DID to determine the extension and look in QUEUE_MEMBER_LIST(9999).  If the extension is logged into the queue, I'd setup the QDIALER_ vars and pass the call to qm-queuedial (like for outbound) to log and connect the call.

[Yes, a CDR report is probably a better solution for these calls, but then the manager has to use two systems and it really needs to be simple for him.]

FreePBX 2.7
QueueMetrics 1.6.0.3

Thoughts, ideas, pointers?

Thanks!
« Last Edit: August 06, 2010, 07:18:19 by peterbokune »

QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Re: Track inbound direct call (without queue)
« Reply #1 on: August 02, 2010, 11:20:33 »
Quick question: does this need to be done in real-time or just for historical reporting?

peterbokune

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
    • View Profile
Re: Track inbound direct call (without queue)
« Reply #2 on: August 02, 2010, 19:07:50 »
Historical reporting is sufficient.  I'm not using asterisk real-time, but I'm now curious what you're thinking... <grin>

peterbokune

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
    • View Profile
Re: Track inbound direct call (without queue)
« Reply #3 on: August 02, 2010, 21:49:08 »
I got to doodling something like this [mildly tested] as I'm using it with FreePBX:

Code: [Select]
[from-pstn-custom]
; ... your existing dialplan
; We use the last 4 digits of the DID as the user's extension (check for your install)
exten => _X.,n,Set(user=${EXTEN:-4:4})
; eg. user=1111
; Set InQ to be the queue you want to track for incoming queue
; comma separated -- quotes are essential!
exten => _X.,n,Set(InQueues="125,126")

exten => _X.,n,Set(IsInQueue=0)
exten => _X.,n,While(${EXISTS(${InQueues})})
exten => _X.,n,Set(InQ="${CUT(InQueues,\,,1)}")
exten => _X.,n,Set(InQueues="${CUT(InQueues,\,,2-)}")
exten => _X.,n,Set(QML="${QUEUE_MEMBER_LIST(${InQ})}")
exten => _X.,n,While(${EXISTS(${QML})}))
exten => _X.,n,Set(IsInQueue=${IF($[ ${CUT(CUT(QML,@,1),/,2)} = ${user}]?$[${IsInQueue}+1]:${IsInQueue})})
exten => _X.,n,GotoIf($[${IsInQueue}]?matched) ; track it, stop looking!
exten => _X.,n,Set(QML="${CUT(QML,\,,2-)}")
exten => _X.,n,EndWhile
exten => _X.,n,EndWhile

exten => _X.,n(matched),Set(QDIALER_NUMBER=${CALLERID(number)})
exten => _X.,n,Set(QDIALER_QUEUE=q-${InQ})
exten => _X.,n,Set(QDIALER_AGENT=Local/${user}@from-internal)
exten => _X.,n,Set(QDIALER_CHANNEL=SIP/${user})

exten => _X.,n,NoOp(Branch to qm-queuedial?  ${IsInQueue})
exten => _X.,n,GotoIf($[${IsInQueue}]?queue:noqueue)
exten => _X.,n(queue),NoOp( "Inbound call - A:${QDIALER_AGENT} N:${QDIALER_NUMBER} Q:${QDIALER_QUEUE} Ch:${QDIALER_CHANNEL}" )
exten => _X.,n,Goto(qm-queuedial,s,1)
exten => _X.,n,Hangup()
exten => _X.,n(noqueue),NoOp(Normally handling call to: ${EXTEN})
exten => _X.,n,Goto(ext-did,${EXTEN},1)


I'm not much of a dialplan hacker (thus my use of FreePBX).  I'd like to try it but I'm still wildly open to "not invented here" solutions.

Other ideas?

Edit: Updated to latest tested, added multiple queue loop
« Last Edit: August 06, 2010, 07:09:55 by peterbokune »

QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Re: Track inbound direct call (without queue)
« Reply #4 on: August 03, 2010, 14:14:14 »
Yes that's what I was thinking about.
Otherwise - but it will take a few coding days - one could write a converter from CDR-CSV to the queue_log format and upload changes nightly to QM.

peterbokune

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
    • View Profile
Re: Track inbound direct call (without queue)
« Reply #5 on: August 03, 2010, 22:38:53 »
With my code above, the agents are logged as Local/xxxx@from-internal and therefore don't match agents.

Given my trouble getting the ability to use Agent/xxxx instead of Local/xxxx@from-queue I might have some other configuration problems that contributes to this.

Hmmm....

QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Re: Track inbound direct call (without queue)
« Reply #6 on: August 04, 2010, 09:50:33 »
No problem - as long as Local/123@from-internal and Agent/123 are the same person, you can trick QM into reading them just the same by setting rewriteLocal to true

peterbokune

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
    • View Profile
Re: Track inbound direct call (without queue)
« Reply #7 on: August 06, 2010, 07:06:28 »
Today will be the first day with this config.  I figured out my rewriteLocal issue -- I hadn't updated the queues to have the agents with the Agents/xxxx members.  I did the change and looked at the historical reports and it all looked good and right.  Even the Local/xxxx@from-inside got rewritten as you suggested.

The code above has been updated to reflect my current configuration.
« Last Edit: August 06, 2010, 07:11:00 by peterbokune »

QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Re: Track inbound direct call (outside of an inbound queue)
« Reply #8 on: August 06, 2010, 11:24:58 »
 ;D

peterbokune

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
    • View Profile
Re: Track inbound direct call (outside of an inbound queue)
« Reply #9 on: August 09, 2010, 21:37:06 »

I need to re-factor this.  I never give inbound callers to the ability to get to voicemail.

Perhaps I'll make a new qm-queuedial context to pass the calls to which use the existing FreePBX framework for passing the calls.


peterbokune

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
    • View Profile
Re: Track inbound direct call (outside of an inbound queue)
« Reply #10 on: August 10, 2010, 03:13:04 »
Can you help me understand what you're doing in qm-queuedialer please?

I can trap the DIALSTATUS for the direct inbound calls in a context called: ext-local-custom

Given this I'm reconsidering moving to this code.  Does it make sense?

Code: [Select]
[from-pstn-custom]
; ... your existing dialplan; We use the last 4 digits of the DID as the user's extension (check for your install)
exten => _X.,n,Set(user=${EXTEN:-4:4})
; eg. user=1111
; Set InQ to be the queue you want to track for incoming queue
; comma separated -- quotes are essential!
exten => _X.,n,Set(InQueues="125,126")

exten => _X.,n,Set(IsInQueue=0)
exten => _X.,n,While(${EXISTS(${InQueues})})
exten => _X.,n,Set(InQ="${CUT(InQueues,\,,1)}")
exten => _X.,n,Set(InQueues="${CUT(InQueues,\,,2-)}")
exten => _X.,n,Set(QML="${QUEUE_MEMBER_LIST(${InQ})}")
exten => _X.,n,While(${EXISTS(${QML})}))
exten => _X.,n,Set(IsInQueue=${IF($[ ${CUT(CUT(QML,@,1),/,2)} = ${user}]?$[${IsInQueue}+1]:${IsInQueue})})
exten => _X.,n,GotoIf($[${IsInQueue}]?matched) ; track it, stop looking!
exten => _X.,n,Set(QML="${CUT(QML,\,,2-)}")
exten => _X.,n,EndWhile
exten => _X.,n,EndWhile

exten => _X.,n(matched),Set(QDIALER_NUMBER=${CALLERID(number)})
exten => _X.,n,Set(QDIALER_QUEUE=q-${InQ})
exten => _X.,n,Set(QDIALER_AGENT=Local/${user}@from-queue)
exten => _X.,n,Set(QDIALER_CHANNEL=SIP/${user})

exten => _X.,n,NoOp(Track Call?  ${IsInQueue})
exten => _X.,n,GotoIf($[${IsInQueue}]?queue:noqueue)
exten => _X.,n(queue),NoOp( "Inbound call - A:${QDIALER_AGENT} N:${QDIALER_NUMBER} Q:${QDIALER_QUEUE} Ch:${QDIALER_CHANNEL}" )

exten => _X.,n,Set(CDR(accountcode)=QDIALAGI)
exten => _X.,n,Set(ST=${EPOCH})
exten => _X.,n,Set(GM=QDV-${QDIALER_AGENT})
exten => _X.,n,Set(GLOBAL(${GM})=U)
exten => _X.,n,Set(GLOBAL(${GM}ans)=0)
exten => _X.,n,Macro(queuelog,${ST},${UNIQUEID},${QDIALER_QUEUE},${QDIALER_AGENT},CALLOUTBOUND,,${QDIALER_NUMBER})

exten => _X.,n(noqueue),Goto(ext-did,${EXTEN},1)


[ext-local-custom]
; Trapping call termination here
exten => h,1,Set(CAUSECOMPLETE=${IF($["${DIALSTATUS}" = "ANSWER"]?C)})
exten => h,n,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()

; Call not tracked
exten => h,n(case-),NoOp(here)
exten => h,n,Hangup()

The problem with this is that it doesn't get called when connected and terminated. 

Maybe the "cook the CDR" approach is better...

QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Re: Track inbound direct call (outside of an inbound queue)
« Reply #11 on: August 11, 2010, 11:02:42 »

I need to re-factor this.  I never give inbound callers to the ability to get to voicemail.

Perhaps I'll make a new qm-queuedial context to pass the calls to which use the existing FreePBX framework for passing the calls.



If you have problems with INBOUND, you should use simple queues, as their logging is already correct. The script is used for outbound,.



peterbokune

  • Newbie
  • *
  • Posts: 11
  • Karma: 0
    • View Profile
Re: Track inbound direct call (outside of an inbound queue)
« Reply #12 on: August 11, 2010, 15:22:05 »

I need to re-factor this.  I never give inbound callers to the ability to get to voicemail.

Perhaps I'll make a new qm-queuedial context to pass the calls to which use the existing FreePBX framework for passing the calls.



If you have problems with INBOUND, you should use simple queues, as their logging is already correct. The script is used for outbound,.




This would imply then one queue for every employee that would be tracked.  In rough numbers, this would be about 50 more queues added.  Yes, this is probably the best solution. It adds clutter to the FreePBX config but the QueueMetrics config isn't cosmetically different (it won't increase menus, etc).  I'll go that way next.

QueueMetrics

  • Loway
  • Hero Member
  • *
  • Posts: 2999
  • Karma: 39
    • View Profile
    • QueueMetrics
Re: Track inbound direct call (outside of an inbound queue)
« Reply #13 on: August 13, 2010, 09:35:15 »
I think this is the best way, unless you want to do the loggiong manually like one does for outbound. If you do not need to do anything fancy with the line, like e.g dtecting DND, voicemail, follow me's etc, I think thi sis the easiset way to go.