Leandro Arruda
Leandro Arruda

Reputation: 506

How to send arguments from dialplan to Perl subroutines AGI and send respectives returns back to dialplan

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

Upvotes: 0

Views: 527

Answers (1)

Leandro Arruda
Leandro Arruda

Reputation: 506

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.

Upvotes: 0

Related Questions