Page 148 - Asterisk™: The Future of Telephony
P. 148

they  work  together.  After  explaining  the  role  each  of  these  elements  plays  in  the
               dialplan, we will step you though the process of creating a basic, functioning dialplan.


                                       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. This will be very beneficial,
                  as it will give you a better understanding of dialplan concepts and fundamentals.
                  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. We suggest
                  you rename the sample file to something like extensions.conf.sample. That way, you
                  can  refer  to  it  in  the  future.  You  can  also  find  the  sample  configuration  files  in
                  the /configs/ directory of the Asterisk source.



               Contexts

               Dialplans are broken into sections called contexts. Contexts are named groups of ex-
               tensions, which serve several purposes.

               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 specifically allowed. (We’ll cover how to allow in-
               teraction between contexts near the end of the chapter.)
               As a simple example, let’s imagine we have two companies sharing an Asterisk server.
               If we place each company’s voice menu in its own context, they are effectively separated
               from each other. This allows us to independently define what happens when, say, ex-
               tension 0 is dialed: people pressing 0 at Company A’s voice menu will get Company
               A’s receptionist, and callers pressing 0 at Company B’s voice menu will get Company
               B’s receptionist. (This example assumes, of course, that we’ve told Asterisk to transfer
               the calls to the receptionists when callers press 0.)

               Contexts are denoted 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.  For example, a context for incoming
               calls looks like this:
                   [incoming]







               * 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!

               120 | Chapter 5: Dialplan Basics
   143   144   145   146   147   148   149   150   151   152   153