System information

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. In Asterisk, when a
context receives a request for an extension that is not valid within that context (e.g.,
pressing 9 in the preceding example), the call is sent to the i extension. We also 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:
[TestMenu]
exten => start,1,Answer()
same => n,Background(main-menu)
same => n,WaitExten(5)
exten => 1,1,Playback(digits/1)
same => n,Goto(TestMenu,start,1)
exten => 2,1,Playback(digits/2)
same => n,Goto(TestMenu,start,1)
exten => i,1,Playback(pbx-invalid)
same => n,Goto(TestMenu,start,1)
exten => t,1,Playback(vm-goodbye)
same => n,Hangup()
Using the i and t extensions makes our menu a little more robust and user-friendly.
That being said, it is still quite limited, because outside callers still have no way of
connecting 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 much 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 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,
which we’ll look at next.
Building an Interactive Dialplan | 119