Best way to initiate an AGI script only on call, no other options

I have a PHP script that works, that is the only thing I want this system to do (I am running PBAIF 1.3) and I have manually added it to ‘extensions.conf’ at the very top of the config file. like:

;exten => s,n(dial),AGI(dialparties.agi)
exten => s,n(dial),AGI(mycustomapp.php)

Hey, it works… Bit I -KNOW- this is a crude full of holes hack, including it getting overwritten by FreePBX.

My question is, what is the RIGHT way to, within a FreePBX managed system,
especially as I want to ensure that this particular system does nothing other than run this agi-bin application. On my development system which is also a real system with extenstions, voice mail and such, I get to it via IVR.

My duct-tape answer is: disable the webserver and thus FreePBX and overwrite extentions.conf
on every system bootup (just in case), but I’d like to do this the right way and keep FreePBX involved.

So let me get this straight, you have replaced dialparties.agi with some modified version which you call mycustomapp.php - the quick and easy way would be to go to /var/lib/asterisk/agi-bin and rename dialparties.agi to dialparties.agi.backup, then copy your script to dialparties.agi and make sure the permisssions/ownership on your file are the same as on the original. I think that will survive anything short of a full FreePBX version upgrade and if FreePBX is upgraded, you’re probably going to want to compare the new dialparties.agi against the backup to see if anything has been added that you also need to add to your custom routine. I assume you can remember to do this on the infrequent occasion that you actually upgrade FreePBX to a newer version.

I am 99.9% sure that normal FreePBX activities don’t touch dialparties.agi and any other way I can think of to do this would be a lot uglier, although one of the developers might have a better suggestion.

I thought about that and it was mentioned in the dialparties file itself. And as “mycustomapp” doesn’t and should not do anything that dialparties does, and I’m happy with what little it does (does a caller ID lookup in a MySQL table, and reads back a some info for a person completely unrelated to phones, voip, cell minutes or anything like that), then that would work. I’m actually suprised that I can’t pick up the custom extension i use in extensions_additional.conf and tell the dial-in to go straight to it like any extension.

Thanks for the thoughts… at least I know I’m not the only person to consider replacing dialparties.agi.

As long as you play this close to the vest and don’t explain exactly what you are doing we can’t offer much more help. However, just a couple notes: First, you can put custom contexts that you write in extensions_custom.conf, then use those as the target of a custom extension or whatever. And also, there are places you can easily intercept the call flow in FreePBX - on an incoming call you can send the call to a custom context instead of from-trunk (see the context= statement in any trunk setting), do what you need to do, then send the call on to from-trunk for further processing. Similarly, on extension setup pages you can send all calls from particular extensions to a custom context instead of from-internal. There are also other ways to slide in your own code if you really need to. Look at some of the How-Tos and see if anything there is remotely close to wht you want to do - it might give you some ideas.