I need to have a perl or php script run every time a call is answered (by a person using a sip phone).
I am using FreePBX, and that system will be used to manage extensions, so whatever I do I need to make sure that adding a new extension or modifying one from the FreePBX interface won't wipe out the part that calls the script.
The person may dial the extension directly, have gotten to the extension via a Ring Group or IVR, or they may have been transferred. The script needs to run in all cases.
I know I need to add a line in one of the configuration files along the lines of:
exten => s,n,System(myperlscript.pl "caller=${ARG1} exten=${ARG2} called=${ARG3}")
That is just a sample bit of code, and I can most likely figure out that part.
The problem is I don't know what configuration file to put it in, or where to put it in that file.