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

The s Extension
               Because of the technology we are using in our channels, we need to cover one more
               thing before we get started with our dialplan. We need to explain extension s. When
               calls enter a context without a specific destination extension (for example, a ringing
               FXO line), they are passed to the s extension. (The s stands for “start,” as this is where
               a call will start if no extension information was passed with the call.)
               Since this is exactly what we need for our dialplan, let’s begin to fill in the pieces. We
               will be performing three actions on the call (answer it, play a sound file, and hang it
               up), so our extension called s will need three priorities. We’ll place the three priorities
               below [incoming], because we have decided that all incoming calls should start in this
               context. ‡
                   [incoming]
                   exten => s,1,application()
                   exten => s,n,application()
                   exten => s,n,application()
               Now all we need to do is fill in the applications, and we’ve created our first dialplan.


                           Note that we could have numbered each priority as shown below, but
                           this is no longer the preferred method, as it makes it harder to make
                           changes to the dialplan at a later time:
                              [incoming]
                              exten => s,1,application()
                              exten => s,2,application()
                              exten => s,3,application()
               The Answer(), Playback(), and Hangup() Applications

               If we’re going to answer the call, play a sound file, and then hang up, we’d better learn
               how to do just that. The Answer() application is used to answer a channel that is ringing.
               This does the initial setup for the channel that receives the incoming call. (A few ap-
               plications don’t require that you answer the channel first, but properly answering the
               channel before performing any other actions is a very good habit.) As we mentioned
               earlier, Answer() takes no arguments.
               The Playback() application is used for playing a previously recorded sound file over a
               channel. When using the Playback() application, input from the user is simply ignored.



               ‡ There  is  nothing  special  about  any  context  name.  We  could  have  named  this  context
                 [stuff_that_comes_in], and as long as that was the context assigned in the channel definition in sip.conf,
                 iax.conf, zaptel.conf, et al., the channel would enter the dialplan in that context. Having said that, it is strongly
                 recommended that you give your contexts names that help you to understand their purpose. Some good
                 context names might include [incoming], [local_calls], [long_distance], [sip_telephones], [user_services],
                 [experimental], [remote_locations], and so forth. Always remember that a context determines how a channel
                 enters the dialplan, so name accordingly.

                                                                        A Simple Dialplan | 125
   148   149   150   151   152   153   154   155   156   157   158