Building an Interactive Dialplan
The dialplan we just built was static; it will always perform the same actions on every call. We are going to start adding some logic to our dialplan so that it will perform different actions based on input from the user. To do this, we’re going to need to introduce a few more applications.
The Background(), WaitExten(), and Goto() Applications
One of the most important keys to building interactive
Asterisk dialplans is the Background()[75] application. Like Playback(), it plays a recorded sound
file. Unlike Playback(), however, when the caller
presses a key (or series of keys) on her telephone keypad, it
interrupts the playback and goes to the extension that corresponds
with the pressed digit(s). If a caller presses 5, for example,
Asterisk will stop playing the sound prompt and send control of the
call to the first priority of extension 5.
The most common use of the Background() application is to create voice menus (often called auto-attendants or phone
trees). Many companies use voice menus to direct callers to
the proper extensions, thus relieving their receptionists from having
to answer every single call.
Background() has the same
syntax as Playback():
exten => 123,1,Answer() exten => 123,n,Background(main-menu)
In earlier versions of Asterisk, if the Background() application finished playing the sound prompt and there were no more priorities in the current extension, Asterisk would sit and wait for input from the caller. Asterisk no longer does ...