Calling a shell script for inbound routes not working

We are trying to intercept all incoming external calls and call up a shell script to lookup our CRM as to who is calling and then pass the call back to the dialplan for normal processing - ringing of the proper extension etc.
We already got the hard part to work, interfacing with the CRM, but surprisingly we cannot find anywhere a simple example of calling up the shell script, and we have looked - or we just don’t get it.

We can run the script successfully with # echo “agi_callerid:xxxx”|

We placed the following context in extensions_custom.conf:
exten => s,1,AGI(/usr/local/bin/
exten => s,n,Goto(ext-did-0002,s,1)

also, tried Goto(ext-did,s,1)

We created a Custom Destination:
custom-openerp-cid-lookup,s,1 in the Custom Destination Module

We pointed the Inbound Route to the Custom Destination.

Nothing is working. We even tried the Dialplan injection module, which we got installed but comes up as “broken” in the module admin and so cannot use it.

We really don’t know where to go next. We just want to see an example of what really ought to be a simple process.

Can anyone help??

First, try adding this context to the file /etc/asterisk/extensions_custom.conf:

[from-pstn-custom] exten=>_X.,1,AGI(/usr/local/bin/
This context should get executed as an include for all inbound calls. If I recall correctly, it gets called very early in the call handling process and your script may rely on dialplan code that gets executed after this context, YMMV.

Secondly, what version of FreePBX and what version of Dialplan injection are you using?

Possibly you’ve already tried this, but there is a “Caller ID Lookup” module. Description says it “Allows CallerID Lookup of incoming calls against different sources (OpenCNAM, MySQL, HTTP, ENUM, Phonebook Module)”

Many thanks. We are not feeling too bright right now. We actually saw a reference to from-pstn-custom early on in our search but didn’t realise the obvious.

We are using 1.818.210.58-1 where FreePBX is - we will be looking to upgrade when we have time but requires a full reinstall and restore.

For Dialplan Injection Module we used initially the 0.1.1 version which would not install due to SQL Table issues. These seem to be corrected in 0.1.1m as the module installed but it was marked as broken and would not uninstall. We removed the directory with rm -rf instead.

Many thanks for your help.

… but we didn’t pursue it as we were so close with the above.
Ultimately the .sh script looks up a Postgresql database which not only displays whose calling on the phone but offers to create a new contact or if already existing pulls up the crm, accounts, records, call logs or documentation of the caller in our ERP system. Works pretty well now.

Thanks for your input.

Why don’t you put the code in the user contributed section? What kind of phones does it work on?

What contact manager? Is it something like Sugar or ACT that would have a wide audience?

Agreed. It could probably be integrated into Caller ID Superfecta which already has a module to query a postgre dbase.

Based on his comments above, it looks like he’s using openERP.

I would also be interested in seeing this code, if you’re willing to share!

The original author of the OpenERP interface modules to asterisk is here:

Here it gives pretty good instructions how to set it all up but was missing the FreePBX last detail.

For the moment we just have all our contacts in OpenERP and are basically using asterisk to populate the database as calls arise. This is essentially our contact manager.
We are using Grandstream phones, next time though we will buy something else like Snom.

Happy to share the code, not sure how to get it into this forum …