Asterisk Gateway Interface is an implementation that allows any external program to control and interact with Asterisk's Dialplan using STDIN (standard input), STDOUT (standard output), and STDERR (standard error) data streams.
We consider as STDIN all the information sent from Asterisk to the program, and as STDOUT all the data sent back to Asterisk. In other words, AGI lets us add more functionality with Asterisk using any program from bash, Perl, PHP, Visual Basic, and so on. We can even write programs that allow us to communicate with databases, open files, and so on.
The way an AGI program is invoked from Dialplan is as follows:
[context] exten => 8888,1,Answer exten => 8888,n,AGI(script.agi, arg1, arg2, …) exten => 8888,n,Hangup()
All the AGI scripts or program are stored in the /var/lib/asterisk/agi-bin
folder.
The most common AGI frameworks are:
Asterisk PERL Library: http://asterisk.gnuinter.net/
py-Asterisk: http://py-asterisk.berlios.de/py-asterisk.php
C libagiNow: http://www.open-tk.de/libagiNow/
.NET MONO-TONE: http://gundy.org/asterisk
The information passed between Asterisk and any AGI is given in the following table:
The list of commands executed from the AGI is given as follows:
Tip
To learn more about Asterisk's Gateway Interface, visit http://www.voip-info.org/wiki/view/Asterisk+AGI.