System information

Updating the dialplan
Let’s modify extensions 1 and 2 in our menu to use the Dial() application:
[TestMenu]
exten => start,1,Answer()
same => n,Background(main-menu)
same => n,WaitExten(5)
exten => 1,1,Dial(SIP/0000FFFF0001,10) ; Replace 0000FFFF0001 with your device name
same => n,Playback(vm-nobodyavail)
same => n,Hangup()
exten => 2,1,Dial(SIP/0000FFFF0002,10) ; Replace 0000FFFF0002 with your device name
same => n,Playback(vm-nobodyavail)
same => n,Hangup()
exten => i,1,Playback(pbx-invalid)
same => n,Goto(TestMenu,start,1)
exten => t,1,Playback(vm-goodbye)
same => n,Hangup()
Blank arguments
Note that the second, third, and fourth arguments may be left blank; only the first
argument is required. For example, if you want to specify an option but not a timeout,
simply leave the timeout argument blank, like this:
exten => 1,1,Dial(DAHDI/1,,m)
Using Variables
Variables can be used in an Asterisk dialplan to help reduce typing, improve clarity, or
add logic. If you have some computer programming experience, you already under-
stand what a variable is. If not, we’ll briefly explain what variables are and how they
are used. They are a vitally important Asterisk dialplan concept (and something you
will not find in the dialplan of any proprietary PBX).
A variable is a named container that can hold a value. The advantage of a variable is
that its contents may change, but its name does not, which means you can write code
that references the variable name and not worry about what the value will be. So, for
example, we might create a variable called JOHN and assign it the value of DAHDI/1. This
way, when we’re writing our dialplan we can refer to John’s channel by name, instead
of remembering that John is using the channel named DAHDI/1. If at some point we
change John’s channel to something else, we don’t have to change any of our code that
references the JOHN variable; we only have to change the value assigned to the variable.
There are two ways to reference a variable. To reference the variable’s name, simply
type the name of the variable, such as LEIF. If, on the other hand, you want to reference
the contents of the value, you must type a dollar sign, an opening curly brace, the name
122 | Chapter 6:Dialplan Basics