Remote API Call Question

Hey Everyone, first post here although I’ve been a long time user of FreePBX. I have a question that I hope is an easy answer.

We develop custom applications and want to use some data from FreePBX but not actually write much into the system; we’d rather do it via API calls to a remote server.

Now I know at first glance people are going to probably think we’re doing this wrong, but based on our setup this is how we need to have this done. Let’s create an example:

Incoming Call > Dialplan sends API Call to with post data about the remote caller id, time of call, DID, etc.

Think of it as pushing events vs reading from Asterisk directly. I realize writing a client to listen for asterisk events would work, but to integrate into an existing system we need for the PBX to send information during the dialplan.

Long story short, Can we post this data through the dialplan easily?


  • Chris

You can call an AGI file from the dialplan that would do the POST for you. If you wanted to call the AGI at the end of the call, you could do something like this in /etc/asterisk/extensions_custom.conf:

[from-pstn-custom] ; This context should run on all incoming calls exten => _X.,1,Set(CHANNEL(hangup_handler_push)=post-agi,s,1)

; this context will run after hangup on all incoming calls
exten => s,1,AGI(postdata.agi)
exten => s,n,Return()

Then you need to create the postdata.agi file which gathers all the channel variables you need and posts the result.

Would I add this as a custom destination through the app, or edit a file directly? Is there a how-to on doing this somewhere? Sorry, I’ve yet to dig deep into anything custom other than what’s out of the box.