Renaming Recording File name?

Samo was almost there, so here’s how to do the whole thing. You just have to pass your variables to the PHP AGI script from your dialplan.

Like above, paste the following to /etc/asterisk/extensions_override_freepbx.conf:

------------ CUT -------------
[macro-record-enable]
include => macro-record-enable-custom
exten => s,1,GotoIf($["${BLINDTRANSFER}" = “”]?check)
exten => s,n,ResetCDR(w)
exten => s,n,StopMonitor()
exten => s,n(check),AGI(recordingcheck,${STRFTIME(${EPOCH},%Y%%d%H%M%S)},${UNIQUEID},${REALCALLERIDNUM},${CALLERID(dnid)})
exten => s,n,MacroExit()
exten => s,1+998(record),MixMonitor(${MIXMON_DIR}${CALLFILENAME}.${MIXMON_FORMAT},${MIXMON_POST})

; end of [macro-record-enable]

------------ CUT -------------

Now, edit /var/lib/asterisk/agi-bin/recordingcheck and add these two lines just below the line $agi = new AGI();:

$icid = $argv[3];
$dial = $argv[4];

Now you can use {$icid} and {$dial} for your incoming and outgoing numbers. Just insert those variables into the filename strings lower down in the recordingcheck file.

For reference:

$icid = Incoming Caller ID
$dial = Outbound Number Dialed

There you have it!

Gary Allen
Solution Stars, LLC


Also do not forget to chmod the recordingcheck file to read only or it will get overwritten. Changing permissions on this file will not cause any other issues that I have found.

Inbound Usage Example:

$agi->verbose(“Recording enabled for”.$exten);
$agi->verbose(“CALLFILENAME=IN{$exten}-{$timestamp}-{$icid}”); $agi->set_variable(“CALLFILENAME”,“IN{$exten}-{$timestamp}-{$icid}”);
$agi->set_priority(‘record’);
exit(0);

Outbound Usage Example:

$agi->verbose(“Outbound recording enabled.”); $agi->verbose(“CALLFILENAME=OUT{$exten[‘data’]}-{$timestamp}-{$dial}”); $agi->set_variable(“CALLFILENAME”,“OUT{$exten[‘data’]}-{$timestamp}-{$dial}”);
$agi->set_priority(‘record’);
exit(0);