[SOLVED] Working calls with custom click-to-call do not make CDR entries


I’ve created a custom click-to-call app for our internal web-based CRM to FreePBX, using Originate through AMI via a perl script on the PBX machine. The calls go through OK, complete with auto-answer on the headset or speakerphone, but they do not generate a CDR entry; whether they are answered or not, there’s no CDR.

Here’s the originate call from the Perl:

my $caller_id = "\"Click to Call\" <$number>";
my $resp = $ami->action({ 
  'Action' => 'Originate', 
  'Channel' => 'Local/' . $extension . '@tlc-click-to-call', 
  'Exten' => $number, 
  'Context' => 'from-internal', 
  'Priority' => '1', 
  'CallerID' => $caller_id

And the [tlc-click-to-call] context is simply this:

exten => _X.,1,SIPAddHeader(Alert-Info: Auto Answer)
exten => _X.,n,Dial(Local/${EXTEN}@from-internal)

So, it bridges the user’s phone via from-internal to an outbound route, also via from-internal.

The funny thing is, I have both CSV and MySQL CDR logging. I believe FreePBX only uses the MySQL CDR, which doesn’t get these calls… but the Master.csv file DOES show the click-to-call calls. I can’t see any difference between the configs for CSV vs. MySQL, so I’m stumped… I can attach those configs if they’re needed, but I think they’re unmodified from the sample configs.

Any advice?

This is on FreePBX, using Asterisk on Debian Wheezy (7.7)


I’ve figured it out. The CallerID for the originate needs to be the FreePBX device number. So my originate code is now this:

my $resp = $ami->action({
	'Action'   => 'Originate',
	'Channel'  => 'Local/' . $station . '@tlc-click-to-call',
	'Exten'    => $number,
	'Context'  => 'from-internal',
	'Priority' => '1',
	'CallerID' => "<$station>",
	'Variable' => "CTC_DEST=$number",

And I added a line to [tlc-click-to-call] to set the desired caller id (based on the CTC_DEST variable):

exten => _X.,1,SIPAddHeader(Alert-Info: Auto Answer)
same  =>     n,Set(CALLERID(all)="Click to Call" <${CTC_DEST}>)
same  =>     n,Dial(SIP/${EXTEN})

I also removed an extra local channel by dialing the SIP peer directly.

And it works like a charm!