Just some VoIP Stuff I Learn from internet and return the knowledge back to the internet.

Monday, October 24, 2011

Asterisk Dial-plan exercise [Speed-Dial]

Creating a Speed-Dial Functionality :

This was a test exercise I gave in one my teaching classes here last year. The idea is to develop a Speed-Dial functionality context for PBX users.

What we'll learn:

1- Connect to MySQL DB from Dial-plan.

2- Use of Asterisk Dial-plan functions CUT, FIELDQTY.

3- Use of GOTOIF Dial-plan application.

4- Use of restricted extension pattern matching by use of [ ].

Problem Statement:

The users should be able to edit their own speed dial-lists via web-interface. And whenever a SIP user dials single digit extension ranging from 0-9 should be able to speed-dial to their contacts saved in DB.

(The Php web-interface for editing contacts isn't included here, it shouldn't be difficult to make a simple page for this.)

Solution Algorithm:

Final Dial-Plan Code:

Corresponding Dial-plan for the above Algorithm is as follows.A few exceptions were handled where if no user speed-dial lists exists or no user data existed.

So, we made a Speed-Dial context here, include this context in your [default] dial-plan context and all one-digit extensions will be matched in Speed-Dial context and perform the functionality if anything matches else it'll be skipped.