asterisk auto dialing using call file
Asterisk call files are structured files which, when moved to the appropriate directory, are able to automatically place calls using Asterisk.
Asterisk has the ability to initiate a call from outside of the normal methods such as the dialplan, manager interface, or spooling interface.
Using the call file method, you must give Asterisk the following information:
- How to perform the call, similar to the Dial() application
- What to do when the call is answered
Call File Syntax
The call file consists of <Key>: <value> pairs; one per line.
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.
The following keys-value pairs are used to specify how setup a call:
Channel: <channel>– The channel to use for the new call, in the form technology/resource as in the Dial application. This value is required.
Callerid: <callerid>– The caller id to use.
WaitTime: <number>– How many seconds to wait for an answer before the call fails (ring cycle). Defaults to 45 seconds.
MaxRetries: <number>– Number of retries before failing, not including the initial attempt. Default = 0 e.g. don’t retry if fails.
RetryTime: <number>– How many seconds to wait before retry. The default is 300 (5 minutes).
Account: <account>– The account code for the call. This value will be assigned to CDR(accountcode)
When the call answers there are two choices:
- Execute a single application, or
- Execute the dialplan at the specified context/extension/priority.
Let us have an complete example:
Dialplan setting to process auto dialing
[voicebroadcast] exten => 777,1,Answer() exten => 777,n,Wait(1) exten => 777,n,Playback(hello-world) exten => 777,n,Wait(1) exten => 777,n,Hangup()
/tmp/with the following content:
Channel: SIP/1000 MaxRetries: 2 RetryTime: 60 WaitTime: 30 Context: voicebroadcast Extension: 777
mv /tmp/broadcast.call /var/spool/asterisk/outgoing/
Understanding asterisk call file
Asterisk polls the
/var/spool/asterisk/outgoing/for new call files and processes any it finds.
Asterisk opens a connection to device
SIP/1000. If the device is in use or not answered, Asterisk tries two more times (see
If someone answers
SIP/1000, Asterisk begins processing extension
777in the context
[voicebroadcast]. In this case, Asterisk plays
hello-worldto the answering party.
Parameters used in call file
Name Explanation/Notes Channel: <channel> The channel upon which to initiate the call Callerid: <id> The caller ID to be used for the call. WaitTime: <seconds> Number of seconds the system waits for the call to be answered. If not specified, defaults to 45 seconds. MaxRetries: <integer> Maximum number of dial retries (if an attempt fails because the device is busy or not reachable). If not specified, defaults to 0 (only one attempt is made). RetryTime: <seconds> Number of seconds to wait until the next dial attempt. If not specified, defaults to 300 seconds. Account: <account> The account code for the CDR. Context: <context> The destination context. Extension: <exten> The destination extension, in which dialplan execution begins if the device is answered. Priority: <priority> The destination priority. If not specified, defaults to 1. Setvar: <var=value> lets you set one or more channel variables Archive: <yes|no> By default, call files are deleted immediately upon execution. If Archive: yes is set, they are copied into /var/spool/asterisk/outgoing_done/ instead. Asterisk adds a line to the call file which describes the result:Status: <Expired|Completed|Failed>
Issue with Call file
For any query or issue, feel free to discuss on http://discuss.eduguru.in