Monday, June 1, 2015

Asterisk Dialplan

Asterisk Dialplan

How to Create a Dial-plan?

First,we need to understand what is a dial-plan.

The Dialplan consists of a collection of contexts. These context definitions are the most important part of the extensions.conf file and are the most important part of Asterisk configuration.

A context is just a collection of extensions. Here is a diagrammatic representation (i.e. not something you'd type into your extensions.conf file!) of a simple example context:

Context "default":
Extension Description
101 Mark Spencer
102 Wil Meadows
103 Greg Vance
104 Check voicemail
105 Conference Room
0 Operator

In this example context, which has been given the name "default", the first three extensions (101 to 103) all would be associated with ringing phones belonging to various employees. The fourth extension (104) would be associated with allowing someone to check their voicemail. The fifth extension (105) would be associated with a conference room. Finally, the "0" extension would be associated with the operator.

Here is another simple example of a context:


Context "mainmenu":
Extension Description
s Welcome message and instructions
1 Sales
2 Support
3 Accounting
9 Directory

  1. Hangup


This example context, given the name "mainmenu", has only single-digit extensions. The "s" extension is the start extension, where the caller begins. This extension would play a message along the lines of "Thank you for calling OurCompany. Press 1 for sales, 2 for support, 3 for accounting, 9 for a company directory, or # to hangup." Each menu option is, in fact, an extension and could either dial someone's real extension or could do something like sending the caller to another menu.

Contexts can be used to implement a number of important features including:

  • Security: Permit long distance calls from certain phones only
  • Routing: Route calls based on extension
  • Autoattendant: Greet callers and ask them to enter extensions
  • Multilevel menus: Menus for sales, support, etc.
  • Authentication: Ask for passwords for certain extensions
  • Callback: Reduce long distance charges
  • Privacy: Blacklist annoying callers from contacting you
  • PBX Multihosting: Yes, you can have "virtual hosts" on your PBX
  • Daytime/Nighttime: You can vary behavior after hours
  • Macros: Create scripts for commonly used functions

How Are Contexts Used?

When Asterisk receives a call connection, whether an incoming call from outside, or from an internal extension, that call belongs to a context. Which context the call belongs to depends on what channel the call came in on. When you configured the channels that you have on your Asterisk PBX, one of the things you had to do was to define what context an incoming connection on that channel would be put into, using a definition like:

context=incoming

So the first way contexts are used is to make Asterisk do different things depending on where a call is coming from. You most likely will have at least one context defined for how Asterisk handles an incoming call on your telephone line: it might ring some of your extensions or play an announcement and record a voicemail message. You want Asterisk to handle connections from your internal extensions differently — they will be permitted to dial a different extension, or make an outgoing call — so you define that calls from those different channels go into different contexts.

No comments:

Easy Way to Handle Android Notifications

Android Notifications Android Toast class provides a handy way to show users alerts but problem is that these alerts are not persist...