<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/Answer%2C+Playback%2C+and+Hangup+Applications">Answer, Playback, and Hangup 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 a couple of examples of using silence/1 to avoid prompt cutoffs.<br />
    </div>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>The *Playback()* application&amp;nbsp;loads a sound prompt from disk and plays it to the caller, ignoring any touch tone input from the caller. The first parameter to the dialplan application is the filename of the sound prompt you wish to play, without a file extension. If the channel has not already been answered, *Playback()* will answer the call before playing back the sound prompt, unless you pass *noanswer* as the second parameter. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;"> <br>To avoid the first few milliseconds of a prompt from being cut off you can play a second of silence. For example, if the prompt you wanted to play was hello-world which would look like this in the dialplan: <br>{code:lang=javascript}exten =&gt; 1234,1,Playback(hello-world){code} <br> <br>You could avoid the first few seconds of the prompt from being cut off by playing the silence/1 file: <br>{code:lang=javascript}exten =&gt; 1234,1,Playback(silence/1) <br>exten =&gt; 1234,n,Playback(hello-world){code} <br> <br>Alternatively this could all be done on the same line by separating the filenames with an ampersand (&amp;amp;): <br>{code:lang=javascript}exten =&gt; 1234,1,Playback(silence/1&amp;hello-world){code} <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>As its name suggests, the <b>Answer()</b> application answers an incoming call. The <b>Answer()</b> application takes a delay (in milliseconds) as its first parameter. Adding a short delay is often useful for ensuring that the remote endpoing has time to begin processing audio before you play a sound prompt. Otherwise, you may not hear the very beginning of the prompt.</p>

<p><b>Knowing When to Answer a Call</b></p>

<p>When you're first learning your way around the Asterisk dialplan, it may be a bit confusing knowing when to use the <b>Answer()</b> application, and when not to.</p>

<p>If Asterisk is simply going to pass the call off to another device using the <b>Dial()</b> application, you probably don't want to call the answer the call first. If, on the other hand, you want Asterisk to play sound prompts or gather input from the caller, it's probably a good idea to call the <b>Answer()</b> application before doing anything else.</p>

<p>The <b>Playback()</b> application&nbsp;loads a sound prompt from disk and plays it to the caller, ignoring any touch tone input from the caller. The first parameter to the dialplan application is the filename of the sound prompt you wish to play, without a file extension. If the channel has not already been answered, <b>Playback()</b> will answer the call before playing back the sound prompt, unless you pass <b>noanswer</b> as the second parameter.</p>

<p>To avoid the first few milliseconds of a prompt from being cut off you can play a second of silence. For example, if the prompt you wanted to play was hello-world which would look like this in the dialplan:</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; 1234,1,Playback(hello-world)]]></script>
</div></div>

<p>You could avoid the first few seconds of the prompt from being cut off by playing the silence/1 file:</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; 1234,1,Playback(silence/1)
exten =&gt; 1234,n,Playback(hello-world)]]></script>
</div></div>

<p>Alternatively this could all be done on the same line by separating the filenames with an ampersand (&amp;):</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; 1234,1,Playback(silence/1&amp;hello-world)]]></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/Answer%2C+Playback%2C+and+Hangup+Applications">View Online</a>
        |
        <a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=4817437&revisedVersion=5&originalVersion=4">View Changes</a>
                |
        <a href="https://wiki.asterisk.org/wiki/display/AST/Answer%2C+Playback%2C+and+Hangup+Applications?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>