Return to site

Asterisk Call File Example

broken image
Asterisk Call File Example

After restarting Asterisk we can connect to the AMI on port 5038 from the system shell using telnet: $ telnet 127.0.0.1 5038 Trying 127.0.0.1. Connected to localhost. Escape character is '^'. Asterisk Call Manager/1.0 Now you can enter commands, usually consisting of multiple lines, by hand. This is an extension module for the Asterisk Gateway Interface (AGI) that adds commands to allow the transfer of audio files to and from Asterisk via the AGI session. This is useful when using FastAGI from a remote host; sounds recorded by Asterisk may be retrieved by remote FastAGI-providing service, for example, or sound files required by the. There are a couple of things that you will have to think about to determine the best approach for your situation, here is what I can tell you though - If you do.not. need to listen for DTMF input (keypresses) while playing the audio file then you can play an audio file on an AgiChannel in Java by using something like `agiChannel.exec('playback.

Skip to end of metadataGo to start of metadata

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

With call files you submit this information simply by creating a file with the required syntax and placing it in the outgoing spooling directory, located by default in /var/spool/asterisk/outgoing/ (this is configurable in asterisk.conf).

The pbx_spool.so module watches the spooling directly, either using an event notification system supplied by the operating system such as inotify or 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.

Creating Files in the Spool Directory

Icon

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 outgoing directory, or Asterisk may read a partial file.

Asterisk Call File Example

NFS Considerations

How to unzip files on mac computers. Unzipping a file on a mac computer is user-friendly and intuitive. To unzip files on a mac, simply follow the steps below: Double click the zipped file. The file will automatically be decompressed by Archive Utility into the same folder the compressed file is in. P7zip is the command line version of 7-Zip for Linux / Unix, made by an independent developer. Some unofficial p7zip packages for Linux and other systems: p7zip for Debian (and Ubuntu). IZip is a free powerful archiving utility designed specifically for Mac. Easily manage ZIP and RAR files directly from the OS X Finder. Open and securely share ZIP, encrypted ZIP and RAR plus other compressed file formats. With WinZip for Mac 2.0 or later, you can right-click (or press CTRL and click) your saved Zip files and use the Context Menu to unzip them. Click on Services at the bottom of the Context menu, then choose Unzip, Email as Zip File and Add to Zip. Mac zip tool. Winzip is the world's leading zip utility for file compression, encryption, sharing, and backup. Save time and space on your Mac with Winzip.

Icon

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).

Asterisk Call Manager

The call file consists of : 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: - The channel to use for the new call, in the form technology/resource as in the Dial application. This value is required.
  • Callerid: - The caller id to use.
  • WaitTime: - How many seconds to wait for an answer before the call fails (ring cycle). Defaults to 45 seconds.
  • MaxRetries: - Number of retries before failing, not including the initial attempt. Default = 0 e.g. don't retry if fails.
  • RetryTime: - How many seconds to wait before retry. The default is 300 (5 minutes).
  • Account: - The account code for the call. This value will be assigned to CDR(accountcode)

When the call answers there are two choices:

  1. Execute a single application, or
  2. Execute the dialplan at the specified context/extension/priority.

To execute an application:

  • Application: - The application to execute
  • Data: - The application arguments

To start executing applications in the dialplan:

  • Context: - The context in the dialplan
  • Extension: - The extension in the specified context
  • Priority: - The priority of the specified extension; (numeric or label)
  • Setvar: - 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.

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.

To specify what to do with the call file at the end of processing:

Asterisk Call File Example
  • Archive: - 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.

If the call file is archived, Asterisk will append to the call file:

  • Status: - Can be 'Expired', 'Completed' or 'Failed'

Asterisk Call File Example Excel

Other lines generated by Asterisk:

Asterisk Call Status

Asterisk keep track of how many retries the call has already attempted, appending to the call file the following key-pairs in the form:

With the main process ID (pid) of the Asterisk process, the retry number, and the attempts start and end times in time_t format.

  • /outgoing - The outgoing dir, where call files are put for processing
  • /outgoing_done - The archive dir
  • - Is specified in asterisk.conf, usually /var/spool/asterisk
Asterisk

After restarting Asterisk we can connect to the AMI on port 5038 from the system shell using telnet: $ telnet 127.0.0.1 5038 Trying 127.0.0.1. Connected to localhost. Escape character is '^'. Asterisk Call Manager/1.0 Now you can enter commands, usually consisting of multiple lines, by hand. This is an extension module for the Asterisk Gateway Interface (AGI) that adds commands to allow the transfer of audio files to and from Asterisk via the AGI session. This is useful when using FastAGI from a remote host; sounds recorded by Asterisk may be retrieved by remote FastAGI-providing service, for example, or sound files required by the. There are a couple of things that you will have to think about to determine the best approach for your situation, here is what I can tell you though - If you do.not. need to listen for DTMF input (keypresses) while playing the audio file then you can play an audio file on an AgiChannel in Java by using something like `agiChannel.exec('playback.

Skip to end of metadataGo to start of metadata

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

With call files you submit this information simply by creating a file with the required syntax and placing it in the outgoing spooling directory, located by default in /var/spool/asterisk/outgoing/ (this is configurable in asterisk.conf).

The pbx_spool.so module watches the spooling directly, either using an event notification system supplied by the operating system such as inotify or 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.

Creating Files in the Spool Directory

Icon

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 outgoing directory, or Asterisk may read a partial file.

NFS Considerations

How to unzip files on mac computers. Unzipping a file on a mac computer is user-friendly and intuitive. To unzip files on a mac, simply follow the steps below: Double click the zipped file. The file will automatically be decompressed by Archive Utility into the same folder the compressed file is in. P7zip is the command line version of 7-Zip for Linux / Unix, made by an independent developer. Some unofficial p7zip packages for Linux and other systems: p7zip for Debian (and Ubuntu). IZip is a free powerful archiving utility designed specifically for Mac. Easily manage ZIP and RAR files directly from the OS X Finder. Open and securely share ZIP, encrypted ZIP and RAR plus other compressed file formats. With WinZip for Mac 2.0 or later, you can right-click (or press CTRL and click) your saved Zip files and use the Context Menu to unzip them. Click on Services at the bottom of the Context menu, then choose Unzip, Email as Zip File and Add to Zip. Mac zip tool. Winzip is the world's leading zip utility for file compression, encryption, sharing, and backup. Save time and space on your Mac with Winzip.

Icon

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).

Asterisk Call Manager

The call file consists of : 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: - The channel to use for the new call, in the form technology/resource as in the Dial application. This value is required.
  • Callerid: - The caller id to use.
  • WaitTime: - How many seconds to wait for an answer before the call fails (ring cycle). Defaults to 45 seconds.
  • MaxRetries: - Number of retries before failing, not including the initial attempt. Default = 0 e.g. don't retry if fails.
  • RetryTime: - How many seconds to wait before retry. The default is 300 (5 minutes).
  • Account: - The account code for the call. This value will be assigned to CDR(accountcode)

When the call answers there are two choices:

  1. Execute a single application, or
  2. Execute the dialplan at the specified context/extension/priority.

To execute an application:

  • Application: - The application to execute
  • Data: - The application arguments

To start executing applications in the dialplan:

  • Context: - The context in the dialplan
  • Extension: - The extension in the specified context
  • Priority: - The priority of the specified extension; (numeric or label)
  • Setvar: - 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.

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.

To specify what to do with the call file at the end of processing:

  • Archive: - 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.

If the call file is archived, Asterisk will append to the call file:

  • Status: - Can be 'Expired', 'Completed' or 'Failed'

Asterisk Call File Example Excel

Other lines generated by Asterisk:

Asterisk Call Status

Asterisk keep track of how many retries the call has already attempted, appending to the call file the following key-pairs in the form:

With the main process ID (pid) of the Asterisk process, the retry number, and the attempts start and end times in time_t format.

  • /outgoing - The outgoing dir, where call files are put for processing
  • /outgoing_done - The archive dir
  • - Is specified in asterisk.conf, usually /var/spool/asterisk

Asterisk Call File Example Template

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.





broken image