O'Reilly logo

Asterisk: The Future of Telephony by Leif Madsen, Jared Smith, Jim Van Meggelen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding Logic to the Dialplan

The dialplan we just built was static—it always performs the same actions on every call. Now we’ll start adding some logic to our dialplan so that it will perform different actions based on input from the user. We’ll start by introducing a few more applications.

The Background() and Goto() Applications

One important key to building interactive Asterisk systems is the Background() 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 file 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,Background(hello-world)

Another useful application is Goto(). As its name implies, it is used to send the call to another context, extension, and priority. The Goto() application makes it easy to programmatically move a call between different parts of the dialplan. The syntax for the Goto() application calls for us to pass the destination context, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required