All posts by edhorton

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

 

Thoughts on Asterisk

I have been using Asterisk for a long time.  Since I started before many support, configuration and management tools were available, I was forced to develop my own.  So, I have stuck with the base Asterisk disto from Digium and written various support programs to help me.  I have deployed many Asterisk servers, ranging from high availability, cluster configurations to Raspberry Pi Google Voice interfaces.  For PBX installs, I always use MySql / ODBC as a database / interface for most of the configuration files that drive the Asterisk server.  Voicemail is handled by an IMAP server, either on the same machine or on a remote server.  I have written front end interface scripts mostly in PHP that are delivered by a WEB server on the same machine.  These scripts allow you to easily configure extensions, voicemail, Polycom phone configurations, SCCP configurations, instant messaging and so forth.  Mailboxes can easily be added or changed since all of the scripts interact with the same Asterisk and Dovecot  databases.

I have used many VOIP providers, but recently I have been experimenting with Twilio.  It works very well, either as a SIP interface or through their elastic SIP trunking.   And the ability to send and receive text messages is an added bonus.

For our staff, friends and family, we use  a SIP client on smart phones.  This client,  Groundwire by Acrobits works very well and allows G.722 audio as well as SIP SIMPLE messaging.  After so many years of piece meal VOIP offerings, finally a provider seems to understand what we need!

So, just wanted to throw out my thoughts and also post a few programs that make life with Twilio easy.  I also included a simple PHP script that demonstrates a Polycom phone remote reset should the Asterisk server not be operational.  Nothing new, but I like it!

I don’t do this sort of thing for a living, but I do love it and any help I may be to someone, either seasoned or a newcomer, don’t be afraid to ask.