Asterisk perl agi
NAME
Asterisk::AGI - Simple Asterisk Gateway Interface ClassSYNOPSIS
use Asterisk::AGI;$AGI = new Asterisk::AGI;
- pull AGI variables into %input
%input = $AGI->ReadParse();
- say the number 1984
$AGI->say_number(1984);
DESCRIPTION
This module should make it easier to write scripts that interact with the asterisk open source pbx via AGI (asterisk gateway interface)CALLBACKS
Callbacks provide a handy way receiving events like hangups. To use the callback function, simply define a function to handle the callback and then tell Perl AGI which funtion it is by sending it a reference. Here is an example:use Asterisk::AGI;
- the AGI object
- send callback reference
- our callback function
warn "The call has ended\n";
set_context($context);
exit;
}
AGI COMMANDS
- $AGI->stream_file($filename, $digits)
This command instructs Asterisk to play the given sound file and listen for the given dtmf digits. The fileextension must not be used in the filename because Asterisk will find the most appropriate file type.
Example: $AGI->stream_file('demo-echotest', '0123');
Returns: -1 on error or hangup, 0 if playback completes without a digit being pressed, or the ASCII numerical value of the digit if a digit was pressed.
- $AGI->send_text($text)
Sends the given text on a channel. Most channels do not support the transmission of text.
Example: $AGI->send_text('You've got mail!');
Returns: -1 on error or hangup, 0 if the text was sent or if the channel does not support text transmission.
- $AGI->send_image($image)
Sends the given image on a channel. Most channels do not support the transmission of images.
Example: $AGI->send_image('image.png');
Returns: -1 on error or hangup, 0 if the image was sent or if the channel does not support image transmission.
- $AGI->say_number($number, $digits)
Says the given $number, returning early if any of the $digits are received.
Example: $AGI->say_number('98765');
Returns: -1 on error or hangup, 0 if playback completes without a digit being pressed, or the ASCII numerical value of the digit of one was pressed.
- $AGI->say_digits($number, $digits)
Says the given digit string $number, returning early if any of the $digits are received.
Example: $AGI->say_digits('8675309');
Returns: -1 on error or hangup, 0 if playback completes without a digit being pressed, or the ASCII numerical value of the digit of one was pressed.
- $AGI->answer()
Answers channel if not already in answer state.
Example: $AGI->answer();
Returns: -1 on channel failure, or 0 if successful.
- $AGI->get_data($filename, $timeout, $maxdigits)
Streams $filename and returns when $maxdigits have been received or when $timeout has been reached. Timeout is specified in ms.
Example: $AGI->get_data('demo-welcome', 15000, 5);
- $AGI->set_callerid($number)
Changes the callerid of the current channel to <number>.
Example: $AGI->set_callerid('9995551212');
Returns: Always returns 1.
- $AGI->set_context($context)
Changes the context for continuation upon exiting the agi application.
Example: $AGI->set_context('dialout');
Returns: Always returns 0.
- $AGI->set_extension($extension)
Changes the extension for continuation upon exiting the agi application.
Example: $AGI->set_extension('7');
Returns: Always returns 0.
- $AGI->set_priority($priority)
Changes the priority for continuation upon exiting the agi application.
Example: $AGI->set_priority(1);
Returns: Always returns 0.
- $AGI->hangup($channel)
Hangs up the passed $channel, or the current channel if $channel is not passed. It is left to the AGI script to exit properly, otherwise you could end up with zombies.
Example: $AGI->hangup();
Returns: Always returns 1.
- $AGI->exec($app, $options)
The most powerful AGI command. Executes the given application passing the given options.
Example: $AGI->exec('Dial', 'Zap/g2/8005551212');
Returns: -2 on failure to find application, or what ever the given application returns.
- $AGI->set_variable($variable, $value)
Sets the channel variable <variablename> to <value>.
Example: $AGI->set_variable('status', 'authorized');
Returns: Always returns 1.
- $AGI->get_variable($variable)
Gets the channel variable <variablename>.
Example: $AGI->get_variable('status');
Returns: The value of the variable, or undef if variable does not exist.
- $AGI->verbose($message, $level)
Logs $message with verboselevel $level.
Example: $AGI->verbose("System Crashed\n", 1);
Returns: Always returns 1.
- $AGI->database_get($family, $key)
Example: $var = $AGI->database_get('test', 'status');
Returns: The value of the variable, or undef if variable does not exist.
- $AGI->database_put($family, $key, $value)
Set/modifes database entry <family>/<key> to <value>.
Example: $AGI->database_put('test', 'status', 'authorized');
Returns: 1 on success, 0 otherwise.
- $AGI->database_del($family, $key)
Removes database entry <family>/<key>.
Example: $AGI->database_del('test', 'status');
Returns: 1 on success, 0 otherwise.
- $AGI->database_deltree($family, $key)
Deletes a family or specific keytree within a family in the Asterisk database.
Example: $AGI->database_deltree('test', 'status');
Example: $AGI->database_deltree('test');
Returns: 1 on success, 0 otherwise.
Documentation on version 0.08
- Back to Asterisk perl library | AGI
Featured -
Search:

Page Changes














