Jump to Navigation

Hacking freepbx dialplan to change call recording default filename

Many of the Asterisk based distro's such as Trixbox and Elastix , and many custom Asterisk installs make use of FreePBX to handle the creation of their dialplan. Whilst I think FreePBX is a great tool, and makes the setup and creation of complex dial plans easy, it also has its downsides. In particular, if you decide that you need to do something that cannot be configured via the web based gui you are pretty stuffed.

FreePBX weaknesses

In this case you have to wade into the mass of undocumented dialplan scripts which is the heart of FreePBX. The problem I have with FreePBX is finding documentation about their custom macros and AGI scripts. The only way I have found to understand what is going on, is to read the code. Even this does not help sometimes because of the way Asterisk handles things like parameters for macros. Basically there is no "method signature" so you have no idea, by looking at the macro, how many parameters it expects and what order to send them in. Of course the pain does not stop there. AGI scripts can also have side-effects in setting variables, that are defined in the dial plan scope. So without documentation, or reading the code, you do not know, for example, that the recordingcheck script actually changes the CALLFILENAME variable. Whats more frustrating is that the variable is not passed in as a parameter.

When to use FreePBX

So generally we use FreePBX only when we deploy a PBX as a traditional PBX for a business. This is where the configuration gui can be extremely benificial, but in call centres where you often need to hack the dialplan, its best to go without FreePBX. No using FreePBX here is not such a problem, as usually the dial plan is quiet simple, especially for outbound campaigns only.

Hacking FreePBX to change default filename of recordings

 Ok, enough ranting. So a question which often comes up, is how to change the default filename for call recordings, from the pretty meaningless default, to a name which includes the date, number called and calling extension. To do this I had to edit the dialplan in two places. First in /etc/asterisk/extensions_additional.conf under the context you have defined for your outgoing routes eg: [outrt-001-9_outside], the name will vary in your file depending on your setup but will start with [outrt-, change the line 

exten => _9.,n,Macro(record-enable,${AMPUSER},OUT,)

to

exten => _9.,n,Macro(record-enable,${AMPUSER},OUT,${EXTEN:1)
 

 then in /etc/asterisk/extensions.conf under the [macro-record-enable] macro definition, change the line:

 exten => s,999,MixMonitor(${CALLFILENAME}.wav)

to

exten => s,999,MixMonitor(${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${ARG3}-${CALLERID(num)}.wav)
 

This will ensure that files are now named  accrording to date-time-called number-extension calling.wav. The problem with this, is that you will no longer be able to use the gui tools that come with FreePBX to monitor calls, but since this currently has poor search and filtering abilities it is not such a loss.

Another way to change the filename would be to hack the  recordingcheck script under /var/lib/asterisk/agi-bin, to change the setting of the CALLFILENAME variable to what you want. Unfortunately I coulnd't find a variable in the script which held the number dialed so had to do it the way described above.

Open Source: 

Comments

Hi,

I cant find [macro-record-enable] line in extensions.conf in elastix.
Any suggestion please?



by Dr. Radut.