A Simple Dialplan
Now we’re ready to create our first dialplan. We’ll start with a very simple example. We will design this dialplan so that as a call comes in, Asterisk will answer the call, play a sound file, and then hang up the call. We’ll use this simple example to point out the most important dialplan fundamentals.
For the examples in this chapter to work correctly, we’re assuming
that at least one Zap channel has been created and configured (as
described in the previous chapter), and that all incoming calls are sent
to the [incoming]
context. If you’re
using other types of channels, you may need to adjust these examples to
fit your particular circumstances.
The s Extension
Before we get started with our dialplan, we ought to explain a
special extension called s
. When
calls enter a context without a specific destination extension (for
example, a ringing FXO line), they are handled automatically by the
s
extension. (The s
stands for “start,” as most calls start in
the s
extension.) 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 we need to create an extension
called s
with three priorities.
We’ll place the three priorities inside [incoming]
, as all incoming calls should
start in this context:
[incoming] exten => s,1,application()
exten => s,2,application()
exten => s,3,application()
Now all we need to do is fill in the applications, and we’ve ...
Get Asterisk: The Future of Telephony now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.