Module To Add Lines to extensions_additional.conf

I am currently writing a module with FreePBX with the attempt to monitor some IVR traffic. I am able to modify the existing IVR Module code to achieve what I want (although this is not a solution I deem satisfying).

I currently have modified the IVR module functions where it writes out it’s part to extensions_additional.conf with the following line:

$ext->add($id, $dest['selection'],'', new ext_system('echo "$(date +%s)|${CDR(uniqueid)}|'.$item['ivr_id'].'|'.$dest['selection'].'" >> /var/log/ivr-track.txt'));

This allows a secondary script to read up the logs and do tracking on it.

My curiosity is whether there is a way I can write a module myself that would add these lines without mucking up the IVR module’s code.

I am relatively new with modifying code in FreePBX and if I am in the completely wrong direction I would appreciate if anyone would let me know.

Thanks! :slight_smile:

John

If I understand what you are asking, you want to hook into dialplan created by another module and “splice” lines of your own module code , which is not too difficult to do. See this page:
http://www.freepbx.org/trac/wiki/ModuleHooks#GeneratingDialplan

in your functions.inc.php define a function named with the format:

function [your_module_rawname]_hookGet_config { << put the dialplan modifications here >> }

You will find some simple-ish dialplan examples here that hook into the Blacklist dialplan:

I appreciate your response and am investigating the recommended solutions you have provided.

Thanks for your time with your response, especially with providing example!

John