login | register
Wed 03 of Dec, 2008 [02:32 UTC]

voip-info.org

Discuss [6] History

Asterisk cmd BackGround

Created by: oej,Last modification on Mon 10 of Mar, 2008 [15:37 UTC] by johnlange

Synopsis

Play a sound file while awaiting extension

Description

 Background(filename1[&filename2...][|options[|langoverride][|context]])

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.

Options

  • 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

Returns

See http://bugs.digium.com/view.php?id=7835 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.

Example

 ; 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


Comments

Comments Filter
222

333Using Background with FastAGI to assist interactive voice menus

by JonathanR, Thursday 14 of February, 2008 [11:37:10 UTC]
I'm currently using FastAGI to create an interactive voice menu. I wanted the user to be able to 'break' out of the menu by pressing a key at any time.
I had been using :

 "EXEC PLAYBACK voicemenu"
 "WAIT FOR DIGIT 5000"

but this doesn't allow for the user to interrupt the menu.

The undocumented fact about Background() is that when it is used with AGI, it will return the ASCII digit the user has pressed while the sound file is being played back, or 0 if nothing is pressed, in exactly the same way as WAIT FOR DIGIT does.

So if you don't want the user to be able to interrupt the playing back of a sound file, use "EXEC Playback soundfile".
If you want the user to be able to interrupt and enter a digit, use "EXEC Background soundfile" and process the "200 result = X" response to discover if a digit has been pressed.
222

333Re: Just upgraded --- Help

by lwb12915, Saturday 12 of January, 2008 [09:48:32 UTC]
exten => s,1,Ringing() ; Let's play some ringing sound for inbound callers
exten => s,2,wait(5) ; Listen to ringing for 5 seconds
exten => s,3,Set(TIMEOUT(digit)=8); Increased timeout digit
exten => s,4,Set(TIMEOUT(response)=15)
exten => s,5,Answer()
exten => s,6,Background(messages/psc)
exten => s,7,WaitExten(10)
exten => h,1,Hangup()
exten => i,1,Playback(invalid) ; "That's not valid, try again"
exten => t,1,Hangup()

222

333Just upgraded --- Help

by dptom, Friday 28 of December, 2007 [01:16:39 UTC]
I've just completed an upgrade from ASterisk 1.2 to 1.4.16 and I'm In big trouble.... This section of my dialplan has stopped working and we cannot receive any inbound calls:

exten => s,1,Ringing() ; Let's play some ringing sound for inbound callers
exten => s,2,wait(5) ; Listen to ringing for 5 seconds
exten => s,3,Set(TIMEOUT(digit)=8); Increased timeout digit
exten => s,4,Set(TIMEOUT(response)=15)
exten => s,5,Answer()
exten => s,6,Background(messages/psc)
exten => h,1,Hangup()
exten => i,1,Playback(invalid) ; "That's not valid, try again"
exten => t,1,Hangup()


Here is the output from the cli:

  — Executing s@inboundpsc:1 Ringing("IAX2/voicepulse-7", "") in new stack
   — Executing s@inboundpsc:2 Wait("IAX2/voicepulse-7", "5") in new stack
   — Executing s@inboundpsc:3 Set("IAX2/voicepulse-7", "TIMEOUT(digit)=8") in new stack
   — Digit timeout set to 8
   — Executing s@inboundpsc:4 Set("IAX2/voicepulse-7", "TIMEOUT(response)=15") in new stack
   — Response timeout set to 15
   — Executing s@inboundpsc:5 Answer("IAX2/voicepulse-7", "") in new stack
   — Executing s@inboundpsc:6 BackGround("IAX2/voicepulse-7", "messages/psc") in new stack
   — <IAX2/voicepulse-7> Playing 'messages/psc' (language 'en')
 == Auto fallthrough, channel 'IAX2/voicepulse-7' status is 'UNKNOWN'
   — Executing h@inboundpsc:1 Hangup("IAX2/voicepulse-7", "") in new stack

When the call comes in, it goes to background and then falls out the the h extension to hang up. Any ideas?


222

333m option in 1.4

by cowlemon, Thursday 25 of January, 2007 [19:09:04 UTC]
In my dialplan, I have the following:

exten => s,1,Background(${RECORDING}|m)
exten => s,n,Voicemail(${DID_NO})
exten => 0,1,Voicemail(${DID_NO})
exten => a,1,VoiceMailMain(${DID_NO})
exten => h,1,Hangup

In version 1.2, when I hit "0" during the playback, I will be directed to voicemail. But in verison 1.4, the call hangs up.

Jan 24 16:05:37 DTMF5754: channel.c:2148 __ast_read: DTMF begin '0' received on SIP/5060-08c53e68
Jan 24 16:05:37 DTMF5754: channel.c:2128 __ast_read: DTMF end '0' received on SIP/5060-08c53e68
== Spawn extension (play_recording, s, 1) exited non-zero on 'SIP/5060-08c53e68'
-- Executing h@play_recording:1 Hangup("SIP/5060-08c53e68", "") in new stack
== Spawn extension (play_recording, h, 1) exited non-zero on 'SIP/5060-08c53e68'


Does anyone tell me why this is happening?


222

333Sound formats

by quad, Wednesday 05 of April, 2006 [02:45:16 UTC]
Can other file formats be used instead of gsm for audio files? What about wav or mp3? If not, what's the recommended way of converting an existing audio file to the gsm format? Thanks!

Edit:
Nevermind. Just had a look at http://www.voip-info.org/tiki-index.php?page=Convert+WAV+audio+files+for+use+in+Asterisk
222

333String Multiple Files Together

by abombss, Tuesday 22 of March, 2005 [06:29:35 UTC]
On the CVS version you can play multiple messages back to back by using an & to seperate the file names.

Ex: prompt,1,Background(press-1&for-sales&press-2&for-billing)