<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/en/2171/18/9/_/styles/combined.css?spaceKey=AST&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>
Formatting and minor comment updates<br />
</div>
<br/>
<h4>Changes (30)</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;">h1. Asterisk call files <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">h1. Asterisk Call Files <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">h2. Overview <br> <br></td></tr>
<tr><td class="diff-unchanged" >Asterisk has the ability to initiate a call from outside of the normal methods such as the dialplan, manager interface, or spooling interface. <br> <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >* What to do when the call is answered <br> <br></td></tr>
<tr><td class="diff-changed-lines" >With call files you submit this information simply by creating a file with the required syntax and placing it in the <span class="diff-changed-words"><span class="diff-added-chars"style="background-color: #dfd;">{{</span>outgoing<span class="diff-added-chars"style="background-color: #dfd;">}}</span></span> spooling directory, located by default in <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">/var/spool/asterisk/outgoing/ (configurable</span> <span class="diff-added-words"style="background-color: #dfd;">{{/var/spool/asterisk/outgoing/}} (this is configurable</span> in <span class="diff-changed-words"><span class="diff-added-chars"style="background-color: #dfd;">{{</span>asterisk.conf<span class="diff-added-chars"style="background-color: #dfd;">}}</span>).</span> <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The pbx_spool module aggressively examines the directory contents every second, creating a new call for every call file it finds. Do NOT write or create the call file directly in the outgoing directory, but always create the file in another directory of the same filesystem and then move the file to the /var/spool/asterisk/outgoing directory, or Asterisk may read just a partial file. <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">The {{pbx_spool.so}} module watches the spooling directly, either using an event notification system supplied by the operating system such as {{[inotify|http://en.wikipedia.org/wiki/Inotify]}} or {{[kqueue|http://en.wikipedia.org/wiki/Kqueue]}}, 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. <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">{warning:title=Creating Files in the Spool Directory} <br>Do *not* write or create the call file directly in the {{outgoing}} directory, but always create the file in another directory of the same filesystem and then move the file to the /var/spool/asterisk/outgoing directory, or Asterisk may read just a partial file. <br></td></tr>
<tr><td class="diff-changed-lines" ><span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">h5.</span> <span class="diff-added-words"style="background-color: #dfd;">{warning}</span> <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The call file syntax <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">{note:title=NFS Considerations} <br>By default, Asterisk will prefer to use {{inotify}} or {{kqueue}} where available. When the spooling directory is on a remote server and is mounted via NFS, the {{inotify}} method will fail to work. You can force Asterisk to use the older polling method by passing the {{--without-inotify}} flag to {{configure}} during compilation (e.g. {{./configure --without-inotify}}). <br>{note} <br> <br>h2. Call File Syntax <br> <br></td></tr>
<tr><td class="diff-unchanged" >The call file consists of <Key>: <value> pairs; one per line. <br> <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >The following keys-value pairs are used to specify how setup a call: <br> <br></td></tr>
<tr><td class="diff-changed-lines" >* <span class="diff-changed-words"><span class="diff-added-chars"style="background-color: #dfd;">{{</span>Channel: <channel><span class="diff-added-chars"style="background-color: #dfd;">}}</span></span> - The channel to use for the new call, in the form *technology/resource* as in the Dial application. This value is required. <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">* {{Callerid: <callerid>}} - The caller id to use. <br>* {{WaitTime: <number>}} - How many seconds to wait for an answer before the call fails (ring cycle). Defaults to 45 seconds. <br>* {{MaxRetries: <number>}} - Number of retries before failing, not including the initial attempt. Default = 0 e.g. don't retry if fails. <br>* {{RetryTime: <number>}} - How many seconds to wait before retry. The default is 300 (5 minutes). <br>* {{Account: <account>}} - The account code for the call. This value will be assigned to CDR(accountcode) <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">* Callerid: <callerid> - The caller id to use. <br> <br>* WaitTime: <number> - How many seconds to wait for an answer before the call fails (ring cycle). Defaults to 45 seconds. <br> <br>* Maxretries: <number> - Number of retries before failing, not including the initial attempt. Default = 0 e.g. don't retry if fails. <br> <br>* RetryTime: <number> - How many seconds to wait before retry. The default is 300 (5 minutes). <br> <br>* Account: <account> - The account code for the call. This value will be assigned to CDR(accountcode) <br> <br></td></tr>
<tr><td class="diff-unchanged" >When the call answers there are two choices: <br> <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" ># Execute the dialplan at the specified context/extension/priority. <br> <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h5.To execute an application: <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">h3. To execute an application: <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-changed-lines" >* <span class="diff-changed-words"><span class="diff-added-chars"style="background-color: #dfd;">{{</span>Application: <appname><span class="diff-added-chars"style="background-color: #dfd;">}}</span></span> - The application to execute <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">* {{Data: <args>}} - The application arguments <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">* Data: <args> - The application arguments <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">h3. To start executing applications in the dialplan: <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">h5. To start executing applications in the dialplan: <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">* {{Context: <context>}} - The context in the dialplan <br>* {{Extension: <exten>}} - The extension in the specified context <br>* {{Priority: <priority>}} - The priority of the specified extension; (numeric or label) <br>* {{Setvar: <var=value>}} - 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. <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">* Context: <context> - The context in the dialplan <br> <br>* Extension: <exten> - The extension in the specified context <br> <br>* Priority: <priority> - The priority of the specified extension; (numeric or label) <br> <br>* Setvar: <var=value> - 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. <br> <br></td></tr>
<tr><td class="diff-unchanged" >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. <br> <br>To specify what to do with the call file at the end of processing: <br> <br></td></tr>
<tr><td class="diff-changed-lines" >* <span class="diff-changed-words"><span class="diff-added-chars"style="background-color: #dfd;">{{</span>Archive: <yes|no><span class="diff-added-chars"style="background-color: #dfd;">}}</span></span> - 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. <br></td></tr>
<tr><td class="diff-unchanged" > <br>If the call file is archived, Asterisk will append to the call file: <br> <br></td></tr>
<tr><td class="diff-changed-lines" >* <span class="diff-changed-words"><span class="diff-added-chars"style="background-color: #dfd;">{{</span>Status: <exitstatus><span class="diff-added-chars"style="background-color: #dfd;">}}</span></span> - Can be "Expired", "Completed" or "Failed" <br></td></tr>
<tr><td class="diff-unchanged" > <br>Other lines generated by Asterisk: <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >With the main process ID (pid) of the Asterisk process, the retry number, and the attempts start and end times in time_t format. <br> <br></td></tr>
<tr><td class="diff-changed-lines" ><span class="diff-changed-words">h<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">5</span><span class="diff-added-chars"style="background-color: #dfd;">2</span>.</span> Directory locations <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-changed-lines" >* <span class="diff-changed-words"><span class="diff-added-chars"style="background-color: #dfd;">{{</span><astspooldir>/outgoing<span class="diff-added-chars"style="background-color: #dfd;">}}</span></span> - The outgoing dir, where call files are put for processing <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">* {{<astspooldir>/outgoing_done}} - The archive dir <br>* {{<astspooldir>}} - Is specified in asterisk.conf, usually /var/spool/asterisk <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">* <astspooldir>/outgoing_done - The archive dir <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">h2. How to schedule a call <br></td></tr>
<tr><td class="diff-unchanged" > <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">* <astspooldir> - Is specified in asterisk.conf, usually /var/spool/asterisk <br> <br>h5. How to schedule a call <br> <br></td></tr>
<tr><td class="diff-unchanged" >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. <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 /var/spool/asterisk/outgoing directory, or Asterisk may read just 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 <Key>: <value> 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 (;----;) 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: <channel></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: <callerid></tt> - The caller id to use.</li>
        <li><tt>WaitTime: <number></tt> - How many seconds to wait for an answer before the call fails (ring cycle). Defaults to 45 seconds.</li>
        <li><tt>MaxRetries: <number></tt> - Number of retries before failing, not including the initial attempt. Default = 0 e.g. don't retry if fails.</li>
        <li><tt>RetryTime: <number></tt> - How many seconds to wait before retry. The default is 300 (5 minutes).</li>
        <li><tt>Account: <account></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: <appname></tt> - The application to execute</li>
        <li><tt>Data: <args></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: <context></tt> - The context in the dialplan</li>
        <li><tt>Extension: <exten></tt> - The extension in the specified context</li>
        <li><tt>Priority: <priority></tt> - The priority of the specified extension; (numeric or label)</li>
        <li><tt>Setvar: <var=value></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: <yes|no></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: <exitstatus></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: <pid> <retrycount> (<time>)
EndRetry: <pid> <retrycount> (<time>)</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><astspooldir>/outgoing</tt> - The outgoing dir, where call files are put for processing</li>
        <li><tt><astspooldir>/outgoing_done</tt> - The archive dir</li>
        <li><tt><astspooldir></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=4&originalVersion=3">View Changes</a>
|
<a href="https://wiki.asterisk.org/wiki/display/AST/Asterisk+Call+FIles?showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>