Tutorials, dial plan examples, voice grammars and tools
You need to register to post on Forums - "Register" link in the upper right corner of this page.
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
Post new comment
HTML tags are not allowed inside posts.