Asterisk Call File Example

Skip to end of metadataGo to start of metadata

  1. Asterisk Call File Example Excel
  2. Asterisk Call Manager

The extensions.conf file is one of the most used and most important configuration file in Asterisk PBX - it contains the dialplan. What is a dialplan? The dialplan, or we can say 'the heart of the Asterisk System', defines how Asterisk PBX will handle incoming and outgoing calls, it also contains all extension numbers. The call is initiated and registered by device B, through a “call file', type mechanism, by calling an extension of the tested Asterisk server which runs in “echo' regime. From device B a random prompt is played (standard Asterisk hello-world prompt has been chosen).

Asterisk call file example pythonCall

Another example is to use callfiles and Local channels so that you can execute some dialplan prior to performing a Dial(). We'll construct a callfile which will then utilize a Local channel to lookup a bit of information in the AstDB and then place a call via the channel configured in the AstDB.

First, lets construct our callfile that will use the Local channel to do some lookups prior to placing our call. More information on constructing callfiles is located in the doc/callfiles.txt file of your Asterisk source.

Our callfile will simply look like the following:

Asterisk outgoing call file example

Add the callfile information to a file such as 'callfile.new' or some other appropriately named file.

Our dialplan will perform a lookup in the AstDB to determine which device to call, and will then call the device, and upon answer, Playback() the silence/1 (1 second of silence) and the tt-weasels sound files.

Before looking at our dialplan, lets put some data into AstDB that we can then lookup from the dialplan. From the Asterisk CLI, run the following command:

We've now put the device destination (SIP/0004f2040001) into the 201/device key within the phones family. This will allow us to lookup the device location for extension 201 from the database.

We can then verify our entry in the database using the 'database show' CLI command:

Now lets create the dialplan that will allow us to call SIP/0004f2040001 when we request extension 201 from the extensions context via our Local channel.

Then, we can perform a call to our device using the callfile by moving it into the /var/spool/asterisk/outgoing/ directory.

Asterisk Call File Example Excel

Then after a moment, you should see output on your console similar to the following, and your device ringing. Information about what is going on during the output has also been added throughout.

You'll see the line above as soon as Asterisk gets the request from the callfile.

This is where we performed our lookup in the AstDB. The value of SIP/0004f2040001 was then returned and saved to the DEVICE channel variable.

We perform a check to make sure ${DEVICE} isn't NULL. If it is, we'll just hangup here.

Now we call our device SIP/0004f2040001 from the Local channel.

We answer the call.

We then start playing back the files.

Asterisk Call Manager

At this point we now see the Local channel has been optimized out of the call path. This is important as we'll see in examples later. By default, the Local channel will try to optimize itself out of the call path as soon as it can. Now that the call has been established and audio is flowing, it gets out of the way.

We can now see the tt-weasels file is played directly to the destination (instead of through the Local channel which was optimized out of the call path) and then a NOTICE stating the call was completed.

Asterisk auto-dial out December 9, 2009

Posted by jbanju in System VoIP Asterisk.
trackback

Call files

  • Move a call file into /var/spool/asterisk/outgoing
  • if autoload=no in modules.conf be sure to load pbx_spool.so, otherwise call files will not work
  • Asterisk will notice and immediately call the indicated channel and connect it to the specified extension at the priority specified in the call file.
  • If the modification date on the call file is in the future, Asterisk will wait until the modification date arrives before executing the call file.
  • Example: See “sample.call”

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

Examples

Example 1

Filename: 1.call

Channel: Zap/1/1XXXXXXXXXXXX
MaxRetries: 2
RetryTime: 60
WaitTime: 30
Context: callme
Extension: 800
Priority: 2

Example 2

To create a call to 14109850123 on an analog channel in group 2 and then connect it to the hypothetical extension 84 (which would map to 84,1,Dial(SIP/84) ) inside your network, here’s the file you’d create in /var/spool/asterisk/outgoing:

Asterisk outgoing call file example

#
# Create the call on group 2 dial lines and set up
# some re-try timers
#
Channel: Zap/g2/14109850123
MaxRetries: 2
RetryTime: 60
WaitTime: 30
#
# Assuming that your local extensions are kept in the
# context called [extensions]
#
Context: extensions
Extension: 84
Priority: 1