AGI Scripts

You are here:
← All Topics
Executes an Asterisk Gateway Interface compliant program on a channel. AGI allows Asterisk to launch external programs written in any language to control a telephony channel, play audio, read DTMF digits, etc. by communicating with the AGI protocol
Each AGI Script can have at least 5 parameters and some can be assigned by the admin and others can be assigned by the user.
When the AGI Script is used as a condition, the variable AGIRESULT is tested and if it is TRUE, the call flows as the condition is matched. A simple AGI Script to say the date and time. Remember to set the execution bit. #!/usr/bin/php
<?php
require_once(‘phpagi/phpagi.php’);
$agi = new AGI();
$agi­>exec(‘sayUnixTime’,$argv[1].”,”.$argv[2].”,”.$argv[3]);
?> Another simple AGI Script randmizing a number and comparing with the one provided as parameter. #!/usr/bin/php
<?php
54
$number=rand(1,10);
$agi = new AGI();
$agi­>Verbose(“Your guess is with the number “.$argv[1]);
$agi­>Verbose(“The random number $number as been selected”);
if ($number==$argv[1]) {
$agi­>set_variable(‘AGIRESULT’,”TRUE”);
} else {
$agi­>set_variable(‘AGIRESULT’,”FALSE”);
}
?>

Please contact support for more info on this feature.