Phonetree for Asterisk

As I have mention, I love working with Asterisk and trying new things by adding some WEB interaction.  Also, most of mu Asterisk work is either for me or for one of several non-profits I support.  From time to time, a need arrises to place calls to a predetermined list of people.  Meeting notices, school cancellations, general information, etc.  I put together a simple system, driven by MySql and a few PHP scripts, that allow you to set up lists of people to call from a master list, cell or home numbers.  It works well, and I even have a phone interface to initiate calls from a remote location due to bad weather or any other reason the WEB interface many not be available.  This also makes use of a background PHP scripts to manage the call, report successes and reschedule missed calls.

The code is a work in progress, but is a great platform to start from.  Any interest and I am happy to share.  Just drop me a note!

Twilio and Asterisk were made for each other!

I have had fun with twilio and this is just the tip of the iceberg.  From unlimited trunk capacity to very inexpensive phone numbers, Twilio is hard to beat.

twilio_helpers

This zip file contains a php scripts that routes text messages received by Twilio to the proper extension on an Asterisk server.  If the extension is on a remote server, mapped by DUNDI, it will call the included remote WEB Service to route it to that server and deliver to the proper extension out of band from the call.  The config file is a collection of variables and is used by both scripts.  Finally, I needed a way to get a Polycom phone to reload its configuration outside of a sip notify from the Asterisk server.  So it is included for fun.

I did not include the support PHP libraries since they are available for download on the web.  I did modify the PAMI library to support MessageSend, so if the newest release does not include this, let me know at edhorton@edwinhorton.com.

Asterisk Outbound Routing using json

For years, my Asterisk dial plan as been complicated because I use a combination of wire line carriers and VOIP providers to route the outbound calls.  The wire line guys don’t want E.164 formatted numbers and the use, or inclusion of the area code is based on the three digit exchange you are calling from.  Also, different area codes included in “metro calling” plans are a headache.  In my case, I have also assigned private VOIP numbers to staff.  I would like to assign the correct outbound called-id to these private extensions.  Lastly, some VOIP providers allow you to alter the outbound caller-id if you prove to them you own the number.  This is very helpful to always present the same company caller-id regardless of the outbound trunk used.   To address this, I wrote a simple php script that queries a couple of mysql tables to correctly format the dial string.  Along the way, I found an Asterisk addition that worked perfectly and allows you to parse json data in the dial plan!  Even though it is two years old, it compliled with no problems on both CentOS x64 and Raspbian on the Raspberry Pi 2 board.  The creator of this add in did a great job.  This can be found at:

https://github.com/drivefast/asterisk-res_json

Since json is relatively compact and widely used, I wanted to give it a try,  There are many ways to solve this problem, even initiating the call from the PHP script.  But this is a simple example using json in the dial plan.   The scripts are attached as well as a simple sql dump. Note that in the case if 6 digit routing such as area code + exchange, they should be entered in the “outbound” table first since the search is ordered by ID ASC.  Also, the majority of the script is actually for logging, and may be removed for a production release.  Also, the dial plan could be shortened but I kept it verbose for logging sake.

Example table structure: outbound

PHP script: get_route

Sample dial plan usage:  dial