[asterisk-users] Strategy for custom data in the CDR

Mitch Claborn mitch_ml at claborn.net
Fri Sep 28 19:24:39 CDT 2012


Looking for ideas and comments on my strategy for getting a bit of 
custom data into the CDR.  It seems to work OK, but I'm open to better 
and/or more robust ways to do it.

Problem: get the customerid of the caller from our application into the CDR

Approach:
Before the Queue() command, save the caller's channel name in a varible 
_MMCALLERCHANNEL

In the Queue() connect macro, send that channel name along with other 
info to the application

The application determines the customerid and uses AMI Setvar to set 
variable MMCUSTOMERID on the given channel with the customerid. (Can't 
use AGI in-line because the customer will be determined by an actual 
human sitting at a terminal during the call and may take a while.)

In the hangup extension, set CDR(customerid) to value of MMCUSTOMERID

Here is the code that is working

[queues]
exten =>sales,1,Verbose(2,${CALLERID(all)} entering the sales queue)
   same =>n,Set(_MMCALLERCHANNEL=${CHANNEL(name)})
   same =>n,Queue(sales,t,,,,,QueueConnected)
   same =>n,Hangup()
exten =>h,1,NoOp(When a sales queue call is hung up)
   same =>n,Set(CDR(customerid)=${MMCUSTOMERID})

[macro-QueueConnected]
exten =>s,1,NoOp()
   same =>n,Monitor(wav,,mb)
   same 
=>n,Set(OPERATORID=${ODBC_OPERATORID_FROM_ADDRESS(${MEMBERINTERFACE})})
   ; userfield is mapped to operatorid in cdr_adaptive_odbc because 
setting operatorid directly doesn't work here
   same =>n,Set(CDR(userfield)=${OPERATORID})
   ; passes the call to the application
   same =>n,System(${MMAGI}/queue_action.sh 
action:connect,queue:sales,member_interface:\\"${MEMBERINTERFACE}\\",member_name:\\"${MEMBERNAME}\\",cidnum:\\"${CONNECTEDLINE(num)}\\",cidname:\\"${CONNECTEDLINE(name)}\\",uniqueid:\\"${MMLINKEDID}\\",channel:\\"${MMCALLERCHANNEL}\\")




-- 

Mitch




More information about the asterisk-users mailing list