The Asterisk dialplan is divided into sections, and each section is
called a context. Any dialplan must begin with a [general]
context where global configuration entries reside, but the subsequent
contexts can have any name. Contexts are the means by which actual
physical devices (usually telephones, but not always; for example, SIP or
Zap devices) are bound to the dialplan. The configuration for every
device, be it a softphone, hardphone or outgoing trunk, must specify the
default context for that device. Here's an example from a
sip.conf file:
[2000] type=friend context=internal-phones secret=1234 host=dynamic
This SIP device called 2000 always initiates
calls in the internal-phones context. This means that if a
caller uses this phone to dial a number, Asterisk will look in the
internal-phones context for an extension matching
that number. If no matching extension is present, nothing happens.
|
|
|
Understanding Asterisk contexts is essential for effective programming and administration of an Asterisk system. It is not always clear to a beginner how important correct use of contexts really is. If you're not sure, please follow the step-by-step example for a simple PBX system in the chapter Chapter 1, Installation and "Hello World". |
Contexts are defined by a name inside square brackets
("[" and "]"). Ideally the name is relevant
and helps to describe the intended use for the context. This name will
also be used to refer to the context elsewhere, be it in other contexts
or in other Asterisk configuration files. All lines following a context
name are considered part of that context, until the next context name is
encountered:
[general] [internal-phones] Rules, instructions, etc. [widgets] Rules, instructions, etc.