Automatically use Gizmo5 "Backdoor Dialing" for free calls to cell phones - if you can modify some code, that is

This will probably appeal more to those of us who use FreePBX and Asterisk in a home system and will take free calls anywhere we can get them, but it might also appeal to anyone who wants free calling to USA cell phones and doesn’t care that there is a short announcement played at the start of each call. Anyway, take a look at this blog post:

Simplified Gizmo5 Backdoor Dialing Asterisk Gateway Interface Script

What this does is, when you call a number that might be accessible via “Backdoor Dialing” it does a quick lookup using a web-based tool that can tell you if the number can be called for free. If so then the call is routed via your Gizmo5 account, otherwise via your normal trunks. Also the results are cached in a database so you don’t have to do a web lookup every time you place a call to a number you’ve called before. Please note that this paragraph is my understanding of how this is supposed to work based on a cursory inspection of the AGI script - I am not the author of the code, nor have I tested it, for reasons that will become apparent in the next paragraph.

The problem is that this was written for plain Asterisk, not FreePBX. Worse yet, the gizmo5backdoor_shell.agi script requires SQLite3 if you want to cache numbers in a database, and as we all know, FreePBX uses MySQL and I doubt any of us want to be running two different database programs on the same system (not that you couldn’t; I just think it would be an inefficient use of system resources). If someone could convert the script to use MySQL instead of SQLite3, it would be much more useful to FreePBX users.

The other issue would be integrating this in FreePBX. If some variation of the dial plan code in the blog post were put in extensions_custom.conf, I’m sure there’s a way to access it via a Custom Trunk. For example, using something like

Local/$OUTNUM$@macro-gizmo5backdoor

for the Custom Dial String would probably get you to that dial plan code (feel free to correct me if I am wrong, but I’m certain there is a way to do it) and then that custom trunk could be the first trunk selected for a route. What I don’t know without further experimentation is how you’d then direct the call to the actual trunk you’d really want. Actually, a better approach would be that if Gizmo5 can’t handle the call then the custom trunk should return congestion, so that the FreePBX route will fall through to the next trunk on the list.

I could probably figure out most of this EXCEPT converting the gizmo5backdoor_shell.agi script to use MySQL. Databases have always mystified me (or I should say, database software has always mystified me - in the old days, if I needed a database for some reason I’d have written a custom program in BASIC to do what I wanted - I “get” the concept of a database, but I haven’t ever found database software that operates in a manner that I understand, not that I’ve had any great need).

Anyway, just thought I’d point out this blog post in case anyone feels like modifying it to work with FreePBX. And before anyone mentions the Nerd Vittles article (linked from the blog post), the difference there is that the NV approach only works if you dial a code in front of a number, which means you have to already know that the call is eligible for “Backdoor Dialing” OR just try it and risk rejection, then having to dial the call again. The problem there is that most users won’t want to dial the code, nor will they appreciate having to redial the call if it doesn’t go through via Backdoor Dialing. The approach taken in the gizmo5backdoor_shell.agi is to treat every call (that you send to it) as POTENTIALLY eligible for Backdoor Dialing, then check the database and/or the web-based lookup to see if that’s actually the case. So, you can set it up so the user doesn’t have to think about it - if a call is eligible for Backdoor Dialing, that’s how it will go out. Assuming, of course, that you can figure out how to modify this to work with FreePBX (and if you can, please post a reply and tell us what you did!).