Page 158 - Asterisk™: The Future of Telephony
P. 158
Handling Invalid Entries and Timeouts
Now that our first voice menu is starting to come together, let’s add some additional
special extensions. First, we need an extension for invalid entries; when a caller presses
an invalid entry (e.g., pressing 9 in the above example), the call is sent to the i extension.
Second, we need an extension to handle situations when the caller doesn’t give input
in time (the default timeout is 10 seconds). Calls will be sent to the t extension if the
caller takes too long to press a digit after WaitExten() has been called. Here is what our
dialplan will look like after we’ve added these two extensions:
[incoming]
exten => 123,1,Answer()
exten => 123,n,Background(enter-ext-of-person)
exten => 123,n,WaitExten()
exten => 1,1,Playback(digits/1)
exten => 1,n,Goto(incoming,123,1)
exten => 2,1,Playback(digits/2)
exten => 2,n,Goto(incoming,123,1)
exten => 3,1,Playback(digits/3)
exten => 3,n,Goto(incoming,123,1)
exten => i,1,Playback(pbx-invalid)
exten => i,n,Goto(incoming,123,1)
exten => t,1,Playback(vm-goodbye)
exten => t,n,Hangup()
Using the i and t extensions makes our dialplan a little more robust and user-friendly.
That being said, it is still quite limited, because outside callers have no way of con-
necting to a live person. To do that, we’ll need to learn about another application, called
Dial().
Using the Dial() Application
One of Asterisk’s most valuable features is its ability to connect different callers to each
other. This is especially useful when callers are using different methods of communi-
cation. For example, caller A might be communicating over the traditional analog
telephone network, while user B might be sitting in a café halfway around the world
and speaking on an IP telephone. Luckily, Asterisk takes most of the hard work out of
connecting and translating between disparate networks. All you have to do is learn how
to use the Dial() application.
The syntax of the Dial() application is a little more complex than that of the other
applications we’ve used so far, but don’t let that scare you off. Dial() takes up to four
arguments. The first is the destination you’re attempting to call, which (in its simplest
form) is made up of a technology (or transport) across which to make the call, a forward
130 | Chapter 5: Dialplan Basics