0
votes

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})
1
okay, and what is question?arheops
@arheops Is there a way to use Perl AGI module sending parameters to functions from dialplan and return values back dialplan? I don't know how to use subroutines in perl AGI.Leandro Arruda
Sure. There are alot of examples availible online. Is that all you want to know?arheops
@arheops Yes, just that. I just can find Perl AGI with conditional statements not using functions receiving parameters from dialplan. Can you show me some of these samples?Leandro Arruda
Wait. So are you asking now how to use functions inside perl script? It is usual way and described in every and each book about perl.arheops

1 Answers

0
votes

Seems that doesn't has how to call one function passing the name of function as argument natively. So, one of the ways that I found to work with AGI, with Perl o PHP, was instead of has a file with various functions, we must to define a function to generate dynamic calls to theses functions passing the identifier of function and the parameters needed via dialplan.