System information
As we work through the book, we will be introducing you to many more Asterisk
applications.
A Simple Dialplan
OK, enough theory. Open up the file /etc/asterisk/extensions.conf, and let’s take a look
at your first dialplan (which was created in Chapter 5). We’re going to add to that.
Hello World
As is typical in many technology books (especially computer programming books), our
first example is called “Hello World!”
In the first priority of our extension, we answer the call. In the second, we play a sound
file named hello-world, and in the third we hang up the call. The code we are interested
in for this example looks like this:
exten => 200,1,Answer()
same => n,Playback(hello-world)
same => n,Hangup()
If you followed along in Chapter 5, you’ll already have a channel or two configured, as
well as the sample dialplan that contains this code. If not, what you need is an exten-
sions.conf file in your /etc/asterisk/ directory that contains the following code:
[LocalSets] ; this is the context name
exten => 100,1,Dial(SIP/0000FFFF0001) ; Replace 0000FFFF0001 with your device name
exten => 101,1,Dial(SIP/0000FFFF0002) ; Replace 0000FFFF0002 with your device name
exten => 200,1,Answer()
same => n,Playback(hello-world)
same => n,Hangup()
If you don’t have any channels configured, now is the time to do so.
There is real satisfaction that comes from passing your first call into an
Asterisk dialplan on a system that you’ve built from scratch. People get
this funny grin on their faces as they realize that they have just created
a telephone system. This pleasure can be yours as well, so please, don’t
go any further until you have made this little bit of dialplan work. If you
have any problems, get back to Chapter 5 and work through the
examples there.
If you don’t have this dialplan code built yet, you’ll need to add it and reload the dialplan
with this CLI command:
*CLI> dialplan reload
A Simple Dialplan | 115