Asterisk Outgoing CDR Logging To Mysql

Posted by user3295551 on Server Fault See other posts from Server Fault or by user3295551
Published on 2014-05-30T00:57:34Z Indexed on 2014/05/30 3:30 UTC
Read the original article Hit count: 421

Filed under:

Trying to utilize the cdr logging (to mysql) using custom fields. The problem I am facing is only when an outbound call is placed, during inbound calls the custom field I am able to log no problem.

The reason I am having an issue is because the custom cdr field I need is a unique value for each user on the system.

sip.conf

 ...
 ...

 [sales_department](!)
 type=friend
 host=dynamic
 context=SalesAgents
 disallow=all
 allow=ulaw
 allow=alaw
 qualify=yes
 qualifyfreq=30


 ;; company sales agents:
 [11](sales_agent)
 secret=xxxxxx
 callerid="<...>"

 [12](sales_agent)
 secret=xxxxxx
 callerid="<...>"

 [13](sales_agent)
 secret=xxxxxx
 callerid="<...>"

 [14](sales_agent)
 secret=xxxxxx
 callerid="<...>"

extensions.conf

 [SalesAgents]
 include => Services

 ; Outbound calls
 exten=>_1NXXNXXXXXX,1,Dial(SIP/${EXTEN}@myprovider)


 ; Inbound calls
 exten=>100,1,NoOp()
 same => n,Set(CDR(agent_id)=11)
 same => n,CELGenUserEvent(Custom Event)
 same => n,Dial(${11_1},25)
 same => n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail)
 same => n(unavail),VoiceMail(11@asterisk)
 same => n,Hangup()
 same => n(busy),VoiceMail(11@asterisk)
 same => n,Hangup()

 exten=>101,1,NoOp()
 same => n,Set(CDR(agent_id)=12)
 same => n,CELGenUserEvent(Custom Event)
 same => n,Dial(${12_1},25)
 same => n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail)
 same => n(unavail),VoiceMail(12@asterisk)
 same => n,Hangup()
 same => n(busy),VoiceMail(12@asterisk)
 same => n,Hangup()

 ...
 ...

For the inbound section of the dialplan in the above example I am able to insert the custom cdr field (agent_id). But above it you can see for the Oubound section of the dialplan I have been stumped on how I would be able to tell the dialplan which agent_id is making the outbound call.

My Question: how to take the agent_id=[11] & agent_id=[12] and agent_id=[13] and agent_id=[14] etc and use that as a custom field for cdr on outbound calls?

© Server Fault or respective owner

Related posts about asterisk