Understanding Asterisk call files

Asterisk PBXAsterisk call files are text files with a certain structure that tell Asterisk to initiate a call when moved to /var/spool/asterisk/outgoing directory. You can use them in order to initiate calls without an extension or bypass the dialplan for troubleshooting purposes. They can be scheduled on any time and date you want and used for call campaigns.

Requirements and general information on how Asterisk call file works

  • pbx_spool.so module needs to be loaded into Asterisk
  • Calls files will only be read when they are moved into astspooldir directory defined in asterisk.conf (usually /var/spool/asterisk/outgoing/)
  • Upon detection Asterisk will immediately execute the directives unless the modification time is in the future, in which Asterisk will wait for the time on the server to match before execute file.
  • Upon completion asterisk will remove the call from spooling directory

Asterisk call file syntax

  • Specify where and how to call:
    • Channel: <channel>: Channel to use for the call (SIP, DAHDI, IAX …).
    • CallerID: “name” <number>. The format is mandatory “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 in case destination is unavailable or busy. 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 )
    • Application: Asterisk Application to run (use instead of specifiying context, extension and priority)
    • Data: The options to be passed to application
  • Other parameters
    • 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.

Asterisk call file examples

playback.call

channel: DAHDI/1/123456789
application: Playback
data: Demo-congrats

SendFax.call

channel: SIP/PROVIDER/1234567890
application: SendFax
data: fax.tiff
setvar=FAXID=3804452466
setvar=FAXOPT(ecm)=yes
setvar=FAXOPT(minrate)=2400
setvar=FAXOPT(maxrate)=14400
ConnectToDialplan.call
Channel: SIP/0673330000@provider
Context: office
Extension: s
Set: CALLERIDNUM=0443330000
MaxRetries: 2
RetryTime: 10
Archive: yes

How to create Asterisk call file

  1. Create a callfile using a script in any preferred language or manually in text editor
  2. Set file permissions with chmod 777 <filename>
  3. Move the file to the proper spool directory with # mv /tmp/callfile /var/spool/asterisk/outgoing/
Note: it’s not recommended to copy the file to the spool directory because asterisk could start reading the file before the operating system stop writing it and call will fail.

 

Be sociable 🙂 Share!

Comments/Коментарі/Комментарии