<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/2041/1/7/_/styles/combined.css?spaceKey=AST&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/AST/Background+and+WaitExten+Applications">Background and WaitExten Applications</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://wiki.asterisk.org/wiki/display/~lmadsen">Leif Madsen</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        Add an example.<br />
    </div>
        <br/>
                         <h4>Changes (8)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The Background() application plays a sound prompt, but listens for DTMF input. Asterisk then tries to find an extension in the current dialplan context that matches the DTMF input. If it finds a matching extension, Asterisk will send the call to that extension. <br>The Background() application takes the name of the sound prompt as the first parameter just like the Playback() application, so remember not to include the file extension. <br></td></tr>
            <tr><td class="diff-unchanged" >The *Background()* application plays a sound prompt, but listens for DTMF input. Asterisk then tries to find an extension in the current dialplan context that matches the DTMF input. If it finds a matching extension, Asterisk will send the call to that extension. <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >The <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">*Background()*</span> <span class="diff-added-words"style="background-color: #dfd;">Background()</span> application takes the name of the sound prompt as the first parameter just like the <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">*Playback()*</span> <span class="diff-added-words"style="background-color: #dfd;">Playback()</span> application, so remember not to include the file extension. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;"> <br></td></tr>
            <tr><td class="diff-changed-lines" >{tip:title=Multiple Prompts}If you have multiple prompts you&#39;d like to play during the Background() application, simply concatenate them together with the ampersand <span class="diff-changed-words">(&amp;<span class="diff-added-chars"style="background-color: #dfd;">amp;</span>)</span> character, like this: <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">{code:lang=javascript}exten=&gt;6123,1,Background(prompt1&amp;prompt2&amp;prompt3) <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{code:lang=javascript}exten =&gt; 6123,1,Background(prompt1&amp;prompt2&amp;prompt3) <br></td></tr>
            <tr><td class="diff-unchanged" >{code}{tip} <br></td></tr>
            <tr><td class="diff-changed-lines" >One problems you may encounter with the *Background()* application is that you may want Asterisk to wait a few more seconds after playing the sound prompt. In order to do this, you can call the <span class="diff-changed-words">*WaitExten<span class="diff-added-chars"style="background-color: #dfd;">()</span>*</span> application. You&#39;ll usually see the <span class="diff-changed-words">*WaitExten<span class="diff-added-chars"style="background-color: #dfd;">()</span>*</span> application called immediately after the *Background()* application. The first parameter to the <span class="diff-changed-words">*WaitExten<span class="diff-added-chars"style="background-color: #dfd;">()</span>*</span> application is the number of seconds to wait for the caller to enter an extension. If you don&#39;t supply the first parameter, Asterisk will use the built-in response <span class="diff-changed-words">timeout<span class="diff-added-chars"style="background-color: #dfd;"> (which can be modified with the *TIMEOUT()* dialplan function)</span>.</span> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;"> <br>{code:lang=javascript}exten =&gt; start,1,Verbose(2,Incoming call from ${CALLERID(all)}) <br>same =&gt; n,Playback(silence/1) <br>same =&gt; n,Background(prompt1&amp;prompt2&amp;prompt3) <br>same =&gt; n,WaitExten(10) <br>same =&gt; n,Goto(timeout-handler,1) <br> <br>exten =&gt; timeout-handler,1) <br>same =&gt; n,Dial(${GLOBAL(OPERATOR)},30) <br>same =&gt; n,Voicemail(operator@default,${IF($[${DIALSTATUS} = BUSY]?b:u)}) <br>same =&gt; n,Hangup(){code} <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>The <b>Background()</b> application plays a sound prompt, but listens for DTMF input. Asterisk then tries to find an extension in the current dialplan context that matches the DTMF input. If it finds a matching extension, Asterisk will send the call to that extension.</p>

<p>The Background() application takes the name of the sound prompt as the first parameter just like the Playback() application, so remember not to include the file extension.</p>

<div class='panelMacro'><table class='tipMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/check.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>Multiple Prompts</b><br />If you have multiple prompts you'd like to play during the Background() application, simply concatenate them together with the ampersand (&amp;) character, like this:
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="toolbar: false; theme: Confluence; brush: javascript; gutter: false"><![CDATA[exten =&gt; 6123,1,Background(prompt1&amp;prompt2&amp;prompt3)
]]></script>
</div></div></td></tr></table></div>
<p>One problems you may encounter with the <b>Background()</b> application is that you may want Asterisk to wait a few more seconds after playing the sound prompt. In order to do this, you can call the <b>WaitExten()</b> application. You'll usually see the <b>WaitExten()</b> application called immediately after the <b>Background()</b> application. The first parameter to the <b>WaitExten()</b> application is the number of seconds to wait for the caller to enter an extension. If you don't supply the first parameter, Asterisk will use the built-in response timeout (which can be modified with the <b>TIMEOUT()</b> dialplan function).</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<script type="syntaxhighlighter" class="toolbar: false; theme: Confluence; brush: javascript; gutter: false"><![CDATA[exten =&gt; start,1,Verbose(2,Incoming call from ${CALLERID(all)})
same =&gt; n,Playback(silence/1)
same =&gt; n,Background(prompt1&amp;prompt2&amp;prompt3)
same =&gt; n,WaitExten(10)
same =&gt; n,Goto(timeout-handler,1)

exten =&gt; timeout-handler,1)
same =&gt; n,Dial(${GLOBAL(OPERATOR)},30)
same =&gt; n,Voicemail(operator@default,${IF($[${DIALSTATUS} = BUSY]?b:u)})
same =&gt; n,Hangup()]]></script>
</div></div>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://wiki.asterisk.org/wiki/users/viewnotifications.action" class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://wiki.asterisk.org/wiki/display/AST/Background+and+WaitExten+Applications">View Online</a>
        |
        <a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=4817385&revisedVersion=4&originalVersion=3">View Changes</a>
                |
        <a href="https://wiki.asterisk.org/wiki/display/AST/Background+and+WaitExten+Applications?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>