I'm using Asterisk :: AGI module to interact with Asterisk 1.8, but I did not see samples to use perl subroutines. I want to connect with a web service and organize the AGI better, would be a good idea to use subroutines instead to do all the code inside if-else block, sending args from dialplan and get the return of theses subroutines.
I know about get and set variables with this module but I want to know if there is something like this:
use Asterisk::AGI;
my $AGI = new Asterisk::AGI;
sub some_subroutine {
my ($param1, $param2, param3) = @ARGV;
# do something with parameters
$agi_data = something_done_with_parameters;
return $AGI->set_variable("agi_data", $agi_data);
}
In dialplan context:
[simple_interact]
exten = s,1,AGI(script.pl, some_subroutine, param1, param2, param3)
same = n,NoOp(${agi_data})