How to build a dial plan in Asterisk
The dial plan is built in extensions.conf and included files.
Basic terms
A dial plan consists of a number of extensions. Each extensions consists of a number of priorities. Extensions are grouped in Asterisk contexts. For each priority, an application is called.
Syntax example:
exten => id, priority, command
- Context: Is the name of the context. Names are alphanumerical. Reserved is contexts that start with macro- (See Asterisk cmd Macro).
- exten: Keyword, must be followed by either = or =>
- id: Alphanumeric extension, that is either dialed by callee or called by a Asterisk cmd Goto.
- priority: Numeric, starts with 1 and steps upward. Each extensions can have many priorities, grouped with the extension id
- command: What to do on this priority, which Asterisk – documentation of application commands to run
Some applications change the priority for the next execution step. Depending on the result, execution of the extension continues at priority+1 or something else. Check the application documentation.
There are also a number of standard extensions
Context inclusion
Contexts may be included in other contexts with the include command.
include => contextname
Inclusion may depend of date and time with arguments
include => daytime|9:00-17:00|mon-fri|*|*
Contexts and channels
For each Asterisk channels, there is a definition of a default context. This means that calls from this channel start in the context given as the default, if no routing information is received, at extension s.
For peers, phones defined in the channel configuration files, there may be a standard context defined. This overrides the standard context for the channel. This way, registred users can place call with other rules than incoming calls.
To add:
- Macros
- Extension matching _XNN constructs
- Expressions in goto $[]
- Variables ${}
Examples:
- Asterisk dial plan – working example: Real world example
- An expanded example showing integrations with a Panasonic KSU
See also:
- Asterisk config extensions.conf: The dial plan
- Asterisk contexts: About contexts
- Asterisk FAQ | Introduction | Tips & Tricks | Asterisk
