System information

Sample Configuration Files
If you installed the sample configuration files when you installed Asterisk, you will most
likely have an existing extensions.conf file. Instead of starting with the sample file, we
suggest that you build your extensions.conf file from scratch. Starting with the sample
file is not the best or easiest way to learn how to build dialplans.
That being said, the sample extensions.conf file remains a fantastic resource, full of
examples and ideas that you can use after you’ve learned the basic concepts. If you
followed our installation instructions, you will find the file extensions.conf.sample in
the folder /usr/src/asterisk-complete/asterisk/1.8/configs (along with many other sample
config files).
Contexts
Dialplans are broken into sections called contexts. Contexts keep different parts of the
dialplan from interacting with one another. An extension that is defined in one context
is completely isolated from extensions in any other context, unless interaction is spe-
cifically allowed. (We’ll cover how to allow interaction between contexts near the end
of the chapter. See “Includes” on page 129 for more information.)
As a simple example, let’s imagine we have two companies sharing an Asterisk server.
If we place each company’s automated attendant in its own context, they will be com-
pletely separated from each other. This allows us to independently define what happens
when, say, extension 0 is dialed: Callers dialing 0 from Company A’s voice menu will
get Company A’s receptionist, while callers dialing 0 at Company B’s voice menu will
get Company B’s receptionist. (This assumes, of course, that we’ve told Asterisk to
transfer the calls to the receptionists when callers press 0.
*
)
Contexts are defined by placing the name of the context inside square brackets ([]).
The name can be made up of the letters A through Z (upper- and lowercase), the num-
bers 0 through 9, and the hyphen and underscore.
A context for incoming calls might
look like this:
[incoming]
* This is a very important consideration. With traditional PBXs, there are generally a set of defaults for things
like reception, which means that if you forget to define them, they will probably work anyway. In Asterisk,
the opposite is true. If you do not tell Asterisk how to handle every situation, and it comes across something
it cannot handle, the call will typically be disconnected. We’ll cover some best practices later that will help
ensure this does not happen. See “Handling Invalid Entries and Timeouts” on page 119 for more information.
† Please note that the space is conspicuously absent from the list of allowed characters. Don’t use spaces in
your context names—you won’t like the result!
108 | Chapter 6:Dialplan Basics