Calling an external script from the dial plan

Visual Dialplan supports AGI (Asterisk Gateway Interface) that can be used to call external scripts from the dial plan.
The Asterisk Gateway Interface is an interface for adding functionality to dial plan with many different programming languages. Perl, PHP, C, Pascal, Bourne Shell - it's your choice.
The only requirements are:
  • AGI script must be executable
  • AGI script must be located in /var/lib/asterisk/agi-bin folder

How to use AGI?
AGI building block is located at the Exe sheet.
Simply place the AGI building block on the working area (in the dial plan) and enter AGI properties.
For example, on the picture below we instructed AGI to call hello_world.php PHP script. We used Simple AGI type and we didn't pass input parameters because this script does not expect it.

This is simple example of an AGI call.
For more complex AGI calls check the AGI help page in the Visual Dialplan documentation.

Hello World example
You will need the hello_world.php AGI script uploaded to your Asterisk server in order to execute the above AGI call.
Here is the simple PHP script that will play the tt-monkeys file from /var/lib/asterisk/sounds.
Simply create hello_world.php file in your /var/lib/asterisk/agi-bin folder with the following content and call the script using AGI block from Visual Dialplan.

 #!/usr/local/bin/php -q
 <?php
  set_time_limit(0);
  require('phpagi.php');

  $agi = new AGI();

  $agi->answer();

  // Play the tt-monkeys file from /var/lib/asterisk/sounds
  $agi->stream_file('tt-monkeys');

  $agi->hangup();
 ?>



Calling Java AGI
Here is how the AGI building block should be configured:


The hello.agi script (and much more details about this) can be found here:
http://asterisk-java.org/development/tutorial.html (external link)





How do you call a Java AGI written using the asterisk-java API?


Hello Barry,

I just added instructions to this wiki page explaining on how to call java AGI.
If you have any further question please do not hesitate to post another comment here or to contact Apstel support at .

Admin.


Hallo what comes in front and behind the AGI button???


It depends on the call flow you want to model.
Generally you may add whatever you want before and after the AGI building block, it really depends on the call flow you are modeling.
AGI building block should be used to call external script only.

John.


Hello,
what comes in output port from AGI button if this go behind a hangup extension ? Thanks !!

Post new comment

big grin confused cool cry eek evil exclaim frown idea lol mad mr green neutral question razz redface rolleyes sad smile surprised twisted wink arrow santa




Anti-Bot verification code: Random Image
Enter the code you see above:
Post new comment

Open Posting comments
Use [http://www.foo.com] or [http://www.foo.com|Description] for links.
HTML tags are not allowed inside posts.