<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/en/2171/18/9/_/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/Asterisk+Call+Files">Asterisk Call Files</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://wiki.asterisk.org/wiki/display/~seanbright">Sean Bright</a>
    </h4>
        <div id="versionComment">
        <b>Comment:</b>
        Fix title<br />
    </div>
        <br/>
                         <h4>Changes (0)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="AsteriskCallFiles-AsteriskCallFiles"></a>Asterisk Call Files</h1>

<h2><a name="AsteriskCallFiles-Overview"></a>Overview</h2>

<p>Asterisk has the ability to initiate a call from outside of the normal methods such as the dialplan, manager interface, or spooling interface.</p>

<p>Using the call file method, you must give Asterisk the following information:</p>

<ul>
        <li>How to perform the call, similar to the Dial() application</li>
        <li>What to do when the call is answered</li>
</ul>


<p>With call files you submit this information simply by creating a file with the required syntax and placing it in the <tt>outgoing</tt> spooling directory, located by default in <tt>/var/spool/asterisk/outgoing/</tt> (this is configurable in <tt>asterisk.conf</tt>).</p>

<p>The <tt>pbx_spool.so</tt> module watches the spooling directly, either using an event notification system supplied by the operating system such as <tt><a href="http://en.wikipedia.org/wiki/Inotify" class="external-link" rel="nofollow">inotify</a></tt> or <tt><a href="http://en.wikipedia.org/wiki/Kqueue" class="external-link" rel="nofollow">kqueue</a></tt>, or by polling the directory each second when one of those notification systems is unavailable.  When a new file appears, Asterisk initiates a new call based on the file's contents.</p>

<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>Creating Files in the Spool Directory</b><br />Do <b>not</b> write or create the call file directly in the <tt>outgoing</tt> directory, but always create the file in another directory of the same filesystem and then move the file to the <tt>outgoing</tt> directory, or Asterisk may read a partial file.</td></tr></table></div>

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>NFS Considerations</b><br />By default, Asterisk will prefer to use <tt>inotify</tt> or <tt>kqueue</tt> where available.  When the spooling directory is on a remote server and is mounted via NFS, the <tt>inotify</tt> method will fail to work.  You can force Asterisk to use the older polling method by passing the <tt>--without-inotify</tt> flag to <tt>configure</tt> during compilation (e.g. <tt>./configure --without-inotify</tt>).</td></tr></table></div>

<h2><a name="AsteriskCallFiles-CallFileSyntax"></a>Call File Syntax</h2>

<p>The call file consists of &lt;Key&gt;: &lt;value&gt; pairs; one per line.</p>

<p>Comments are indicated by a '#' character that begins a line, or follows a space or tab character.  To be consistent with the configuration files in Asterisk, comments can also be indicated by a semicolon.  However, the multiline comments &#40;;&#45;&#45;&#45;&#45;;&#41; used in Asterisk configuration files are not supported. Semicolons can be escaped by a backslash.</p>

<p>The following keys-value pairs are used to specify how setup a call:</p>

<ul>
        <li><tt>Channel: &lt;channel&gt;</tt> - The channel to use for the new call, in the form <b>technology/resource</b> as in the Dial application.  This value is required.</li>
        <li><tt>Callerid: &lt;callerid&gt;</tt> - The caller id to use.</li>
        <li><tt>WaitTime: &lt;number&gt;</tt> - How many seconds to wait for an answer before the call fails (ring cycle). Defaults to 45 seconds.</li>
        <li><tt>MaxRetries: &lt;number&gt;</tt> - Number of retries before failing, not including the initial attempt. Default = 0 e.g. don't retry if fails.</li>
        <li><tt>RetryTime: &lt;number&gt;</tt> - How many seconds to wait before retry. The default is 300 (5 minutes).</li>
        <li><tt>Account: &lt;account&gt;</tt> - The account code for the call. This value will be assigned to CDR(accountcode)</li>
</ul>


<p>When the call answers there are two choices: </p>

<ol>
        <li>Execute a single application, or</li>
        <li>Execute the dialplan at the specified context/extension/priority.</li>
</ol>


<h3><a name="AsteriskCallFiles-Toexecuteanapplication%3A"></a>To execute an application:</h3>

<ul>
        <li><tt>Application: &lt;appname&gt;</tt> - The application to execute</li>
        <li><tt>Data: &lt;args&gt;</tt> - The application arguments</li>
</ul>


<h3><a name="AsteriskCallFiles-Tostartexecutingapplicationsinthedialplan%3A"></a>To start executing applications in the dialplan:</h3>

<ul>
        <li><tt>Context: &lt;context&gt;</tt> - The context in the dialplan</li>
        <li><tt>Extension: &lt;exten&gt;</tt> - The extension in the specified context</li>
        <li><tt>Priority: &lt;priority&gt;</tt> - The priority of the specified extension; (numeric or label)</li>
        <li><tt>Setvar: &lt;var=value&gt;</tt> - You may also assign values to variables that will be available to the channel, as if you had performed a Set(var=value) in the dialplan. More than one Setvar: may be specified.</li>
</ul>


<p>The processing of the call file ends when the call is answered and terminated; when the call was not answered in the initial attempt and subsequent retries; or if the call file can't be successfully read and parsed.</p>

<p>To specify what to do with the call file at the end of processing:</p>

<ul>
        <li><tt>Archive: &lt;yes|no&gt;</tt> - If "no" the call file is deleted. If set to "yes" the call file is moved to the "outgoing_done" subdirectory of the Asterisk spool directory. The default is to delete the call file.</li>
</ul>


<p>If the call file is archived, Asterisk will append to the call file:</p>

<ul>
        <li><tt>Status: &lt;exitstatus&gt;</tt> - Can be "Expired", "Completed" or "Failed"</li>
</ul>


<p>Other lines generated by Asterisk:</p>

<p>Asterisk keep track of how many retries the call has already attempted, appending to the call file the following key-pairs in the form:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">StartRetry: &lt;pid&gt; &lt;retrycount&gt; (&lt;time&gt;)
EndRetry: &lt;pid&gt; &lt;retrycount&gt; (&lt;time&gt;)</pre>
</div></div>

<p>With the main process ID (pid) of the Asterisk process, the retry number, and the attempts start and end times in time_t format.</p>

<h2><a name="AsteriskCallFiles-Directorylocations"></a>Directory locations</h2>

<ul>
        <li><tt>&lt;astspooldir&gt;/outgoing</tt> - The outgoing dir, where call files are put for processing</li>
        <li><tt>&lt;astspooldir&gt;/outgoing_done</tt> - The archive dir</li>
        <li><tt>&lt;astspooldir&gt;</tt> - Is specified in asterisk.conf, usually /var/spool/asterisk</li>
</ul>


<h2><a name="AsteriskCallFiles-Howtoscheduleacall"></a>How to schedule a call</h2>

<p>Call files that have the time of the last modification in the future are ignored by Asterisk. This makes it possible to modify the time of a call file to the wanted time, move to the outgoing directory, and Asterisk will attempt to create the call at that time.</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+Call+Files">View Online</a>
        |
        <a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=4259976&revisedVersion=7&originalVersion=6">View Changes</a>
                |
        <a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+Call+Files?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>