System information
exten => i,1,Playback(pbx-invalid)
same => n,Goto(incoming,123,1)
exten => t,1,Playback(vm-goodbye)
same => n,Hangup()
You’ll notice we’ve added pseudonym extension names for our extension numbers. In
“Extensions” on page 110, we explained that Asterisk does not care which naming
scheme you use to identify an extension. We’ve simply added both numeric and named
extension identifiers for reaching the same endpoint; extensions 100 and leif both
reach the device located at SIP/0000FFFF0001, extensions 101 and jim both reach the
device located at SIP/0000FFFF0002, and both 102 and russell reach the device located
at SIP/0000FFFF0003. The devices are identified with the global variables ${LEIF}, $
{JIM}, and ${RUSSELL}, respectively, and we’re dialing those locations using the
Dial() application.
In our test menu we’ve simply picked a couple of random endpoints to dial, such as
DAHDI/1 and SIP/Jane. These could be replaced with any available endpoints that you
wish. Our TestMenu context has been built to start giving you an idea as to what an
Asterisk dialplan looks like.
Pattern Matching
If we want to be able to allow people to dial through Asterisk and have Asterisk connect
them to outside resources, we need a way to match on any possible phone number that
the caller might dial. For situations like this, Asterisk offers pattern matching. Pattern
matching allows you to create one extension in your dialplan that matches many dif-
ferent numbers. This is enormously useful.
Pattern-matching syntax
When using pattern matching, certain letters and symbols represent what we are trying
to match. Patterns always start with an underscore (_). This tells Asterisk that we’re
matching on a pattern, and not on an explicit extension name.
If you forget the underscore at the beginning of your pattern, Asterisk
will think it’s just a named extension and won’t do any pattern match-
ing. This is one of the most common mistakes people make when start-
ing to learn Asterisk.
After the underscore, you can use one or more of the following characters:
X
Matches any single digit from 0 to 9.
Z
Matches any single digit from 1 to 9.
Building an Interactive Dialplan | 125