The Background application
Just like the Playback application, the Background application is used in Asterisk to play sound files. However, there is one important difference between these two applications – the Background application listens for the caller’s input (also called the DTMF input). When the caller presses a key on the keypad, the playback is stopped and the call is passed to the extension that corresponds with the pressed digit. For example, if a caller presses 3 while the sound file is playing, Asterisk stops the playback and the control of the call is sent to the first priority of the extension 3.
The Background application is often used to create voice menus (also known as auto attendants). These menus allow callers to direct themselves to various extensions, depending on their needs. For example, you might design a voice menu that will direct users to the sales department when they press 2 on their keypad or to the marketing department when 3 is pressed.
Here is an example of the Background application in action. Add the following code to the extensions.conf file:
exten => 500,1,Answer() same => n,Background(welcome) same => n,WaitExten(10) exten => 1,1,Playback(digits/1) exten => 2,1,Playback(digits/2) exten => 3,1,Playback(digits/3) exten => 4,1,Playback(digits/4) exten => 5,1,Playback(digits/5)
Reload the dialplan. Now, when the extension 500 is called, the welcome message will be played. After the sound, Asterisk will wait 10 seconds for an extension to be entered. If the user presses a number in the range of 1 to 5, the corresponding digit will be read.