A few questions about AGI and FreePBX


There does not appear to be any formal documentation on this topic – of calling external programs from the dialplan using AGI, without interfering with FreePBX. [color=blue]Solution: override the desired context in extensions_custom.conf by making a copy of it from the context generated by FreePBX; it won’t interfere with FreePBX, except that the context won’t be modifiable through the interface, but the custom-edited context will have to be updated.[/color] I have done extensive searching and reading, and all I was able to find were a few posts over 3 years old on the forums here regarding how to edit extensions-custom.conf. Furthermore, what little I could find only covers calling AGI when dialing a specific extension, and nowhere else (i.e. calling the script in response to a caller encountering an IVR or call queue). This hardly seems practical in light of how triggering events that ideally should happen automatically should not require a user to dial a specific number.

All I need to do is to call an external program/script, with no external handling of the call, when a user reaches a certain part of the dialplan, i.e. if coming in through a call route or dialing an extension. My aim is to keep track of calls using an external web application, sending it vital information about the call (i.e. CID, name) but setting it up so that it doesn’t interfere with FreePBX or vice versa.

I do not want to interfere with the preexisting IVRs and dialplans, which work, but merely to trigger the script when a caller enters. Considering the nature of Asterisk and what it is capable of doing, this does not seem like a non-trivial thing to set up. Or is it? Will FreePBX erase my work if I manually place AGI calls in the call route and queue configuration?

extensions_custom.conf is used for just what you describe.

Since it is the last file included you can copy a context from extensions.conf make your changes and put it in extensions_custom.

You will also find the FreePBX dial plan has many custom context “hooks” inside the dial plan for user code.

Thank you kindly for such a quick response! Also, it’s an honor; before I joined the forums, I trawled them for days as I was setting up my company’s FreePBX server, and I found your responses to other people’s questions useful.

Now, if I am understanding correctly, the context copied from extensions.conf will be overridden by the modified copy of it in extensions_custom.conf. Is this correct? If so, then all that’s left to do is find which context I need to inject the AGI command into, right?


That is correct, if you look in extensions.conf, you will see the order that the files are included. When you duplicate contexts the last one takes precedence.