Asterisk cmd BackGround


Play a sound file while awaiting extension



This application will play the given list of files while waiting for an extension to be dialed by the calling channel. To continue waiting for digits after this application has finished playing files, the WaitExten application should be used. The 'langoverride' option explicity specifies which language to attempt to use for the requested sound files. If a 'context' is specified, this is the dialplan context that this application will use when exiting to a dialed extension. If one of the requested sound files does not exist, call processing will be terminated.

Background() inside a macro
If you use Background() inside a macro, the context utilized for the extension is the one where the macro is called, not the context in which the macro is running [macro-xxxxx] . So if you want to use background with an extension inside your macro, you can use the context parameter, and make it match the one of the macro you are in. Tested successfully on Asterisk 1.4.17.


  • s - causes the playback of the message to be skipped if the channel is not in the 'up' state (i.e. it hasn't been answered yet.) If this happens, the application will return immediately.
  • n - don't answer the channel before playing the files
  • m - only break if a digit hit matches a one digit extension in the destination context


See for details of a crude patch to implement the return of ${BACKGROUNDSTATUS} ("FAILED" or "SUCCESS" in the same way Playback() does).

Wait for DTMF Input

If you want Asterisk to just wait for input without playing a sound file, see the WaitExten application.


; Sample 'main menu' context with submenu
exten => s,1,Answer
exten => s,2,Background(thanks) ; "Thanks for calling. Press 1 for sales, 2 for support, ..."
exten => 1,1,Goto(submenu,s,1)
exten => 2,1,Hangup

See also

Asterisk | Applications | Functions | Variables | Expressions | Asterisk FAQ

Created by: oej, Last modification: Sun 20 of May, 2012 (19:59 UTC) by admin
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+