Dial Plans:
The dialplan is the meat and bones of any Asterisk system, because it defines how Asterisk handles inbound and outbound calls. Basically, it consists of a list of instructions or steps that Asterisk will follow. Differing from traditional phone systems, Asterisk’s dialplan is fully customizable. To successfully run your own Asterisk system, you will need to understand dialplans. The Asterisk dialplan is specified in the configuration file named extensions.conf. It is made up of four main parts: contexts, extensions, priorities, and applications. Please look at examples in the Configuration Files section in order to get a better grasp and to see various dial plans.
Contexts :
hese are named groups of extensions that keep different parts of the dialplan from interacting with one another. An extension that is defined in one context is completely encapsulated from extensions in other contexts unless data sharing is specifically permited.
Contexts are declared by placing the name of the context within square brackets ([]). The name can consist of the letters A through Z (both uppercase and lowercase), the numbers 0 through 9, and the hyphen and underscore.* All of the instructions put after a context definition are part of that context, until the next context is declared. At the beginning of the dialplan, there are two special contexts named [general] and[globals]. Globals, as the name implies, is a section where you can define global variables.
The main use of contexts is to enforce security. By using contexts, you are able to give specific callers access to certain features that are not made available to others.
Extensions :
Extension are instructions that Asterisk will follow, triggered by an incoming call or by digits being dialed on a channel. You are able to define one or more extensions in each context. Extensions specify what happens to calls as they make their way through the dialplan. Although extensions can be used to specify phone extensions in the traditional sense, they can also be used for much more in Asterisk. A complete extension is composed of three parts:
- The name (or number) of the extension
- The priority (each extension can include multiple steps; the step number is called the “priority”)
- The application (or command) that performs some action on the call
These three components are separated by commas, like this:
exten => name,priority,application( )
Here’s a simple example of what a real extension might look like:
exten => 123,1,Answer( )
In this example, the extension name is 123, the priority is 1, and the application is Answer( ).
Priorities :
Every extension can have several steps, that are called priorities. Every priority is numbered sequentially, starting with 1. Each priority executes one specific application. As an example, the following extension would answer the phone (in priority number 1), and then hang it up (in priority number 2):
exten => 123,1,Answer( )
exten => 123,2,Hangup( )
You must be careful not to start your priorites at 1 and make sure they are numbered consecutively; skipping a step will cause Asterisk to do exectute as intended