Asterisk call files are structured files which, when moved to the appropriate directory, are able to automatically place calls using Asterisk. Call files are a great way place calls automatically without using more complex Asterisk features like the AGI, AMI, and dialplan, and require very little technical knowledge to use.
The Asterisk dial plan extensions.conf responds to someone calling an extension on a channel. If you want to initiate a call from an external application, there are several ways to do this.
There are basically four ways to initiate outgoing calls in Asterisk
- Use .call files. A call file is a text file that when placed in the correct directory makes Asterisk make an outgoing call.
- Use the manager API to activate a call. See Asterisk manager dialout
- Use the Asterisk CLI originate command
- FollowMe command of Asterisk 1.4: Since this has the abitility to fork (create multiple calls) it could be ‘misused’ to initiate outgoing calls.
New in Asterisk 1.8: A new application Originate has been introduced, that allows asynchronous call origination from the dialplan.
How Does It Work?
- Move a call file into /var/spool/asterisk/outgoing/ (or the equivalent astspooldir directory defined in asterisk.conf).
- If autoload=no in modules.conf be sure to load pbx_spool.so, otherwise call files will not work.
- If the modification date on the call file is in the future, Asterisk will wait until the system time matches the modification time before executing the call file.
- Asterisk will notice and immediately execute the directives defined in the call file. This can include either connecting to an Asterisk dial plan context, or performing a single Asterisk dial plan function call.
- Asterisk will then remove the call file from the spooling directory (typically /var/spool/asterisk/outgoing).
- Examples: See Minimal Call File Example and Syntax of Call Filessections.
Syntax of call files
- Specify where and how to call
- Channel: <channel>: Channel to use for the call.
- CallerID: “name” <number> Caller ID, Please note: It may not work if you do not respect the format: CallerID: “Some Name” <1234>
- MaxRetries: <number> Number of retries before failing (not including the initial attempt, e.g. 0 = total of 1 attempt to make the call). Default is 0.
- RetryTime: <number> Seconds between retries, Don’t hammer an unavailable phone. Default is 300 (5 min).
- WaitTime: <number> Seconds to wait for an answer. Default is 45.
- Account: Set the account code to use.
- If the call answers, connect it here:
- Context: <context-name> Context in extensions.conf
- Extension: <ext> Extension definition in extensions.conf
- Priority: <priority> Priority of extension to start with
- Set: Set a variable for use in the extension logic (example: file1=/tmp/to ); in Asterisk 1.0.x use ‘SetVar’ instead of ‘Set’
- Application: Asterisk Application to run (use instead of specifiying context, extension and priority)
- Data: The options to be passed to application
- New (?) in Asterisk 1.4
- Set: Can now also write to dialplan functions like CDR()
- AlwaysDelete: Yes/No – If the file’s modification time is in the future, the call file will not be deleted
- Archive: Yes/No – Move to subdir “outgoing_done” with “Status: value”, where value can be Completed, Expired or Failed.
At least one of app or extension must be specified, along with channel and destination
Minimal Call File Example
The most minimal call file example that we can make does nothing more than dial a number, and play a sound file.
hello-world.call
Channel: SIP/trunkname/18882223333 Application: Playback Data: hello-world<
To run the call file above, you would type the following commands (we assume that the file already belongs to the asterisk user:
mv hello-world.call /var/spool/asterisk/outgoing/
How does this work? Asterisk does the following when reading the above call file:
- Dial the number 18882223333 out of the trunkname SIP trunk.
- Once the call has been answered, play the sound file /var/lib/asterisk/sounds/hello-world (this sound file is included by default)
- Hang up the call.
As you can see, this is a very minimal call file example.
Source – Voip-Info