* Asterisk POC‎ > ‎

4) AGI / FastAGI

AGI  = Asterisk Gateway Interface, can call a script in any language (Perl,Python, PHP, Java, etc...)
It works same way CGI script, use stdin/stdout, send vars via stdin like HTTP header, returns an HTTP like error codes, output commands to stdout, read results from stdin, etc...

The EAGI (enhanced AGI) application acts just like AGI but allows your AGI script to read the inbound audio stream on file descriptor number three.
The DeadAGI application is also just like AGI, but it works correctly on a channel that is dead (i.e., a channel that has been hung up). As this implies, the regular AGI application doesn’t work on dead channels.
The FastAGI application allows the AGI script to be called across the network.

exten => s,n,AGI("some_agi_script_name.agi"[,arg1][,arg2][,..])


FastAGI  = same over TCP
exten => s,n,AGI(agi://192.168.1.80/SomePath,${EXTEN},${UNIQUEID},${CALLERID(name)}) 



PYTHON AGI : 

from asterisk.agi import *

def main():
agi = AGI()
agi.verbose("python agi started")
callerId = agi.env['agi_callerid']
agi.verbose("call from %s" % callerId)
agi.answer()
agi.stream_file('greeting_audio')
agi.hangup()



PERL AGI : 

apt-get install libasterisk-agi-perl
examples (not tested) :

PHP AGI : 

install  phpagi , see examples : 


Comments