[asterisk-users] Explain AGI and AMI

Steve Edwards asterisk.org at sedwards.com
Tue Dec 4 08:18:39 CST 2007


On Tue, 4 Dec 2007, Olivier wrote:

> Can anyone explain the difference between Asterisk Gateway Interface and 
> Asterisk Management Interface ? Is it correct to consider AGI scope to 
> focus on call handling and AMI scope to anything which can be done with 
> Asterisk froma loading new modules to originating calls ?

AGI is a protocol for writing your own applications. These applications 
execute as a step or priority in a dialplan similar to Asterisk 
applications like background() or meetme(). They execute in the context of 
a single channel. You can't execute an AGI before you have a call and you 
usually don't have an AGI after the call is hung up (or shortly 
thereafter).

Each AGI executes as a separate process it does not have access to the 
"code" or memory space of the Asterisk process. Thus, you are executing in 
a much more limited environment than an Asterisk application. You also 
can't crash the Asterisk process with a simple coding error.

Think of an AGI (Asterisk Gateway Interface) like you would think of a CGI 
(Common Gateway Interface) in a web server. AGI doesn't define the source 
language you use. You could write an AGI in shell. I use C. A lot of 
people use Perl or PHP.

AMI is a tcp connection to Asterisk. Think of it as a connection to the 
Asterisk command line. You can control a call, but it is not limited to a 
specific call. You can ask Asterisk questions or just sit there and watch 
stuff wiz by :)

Thanks in advance,
------------------------------------------------------------------------
Steve Edwards      sedwards at sedwards.com      Voice: +1-760-468-3867 PST
Newline                                             Fax: +1-760-731-3000



More information about the asterisk-users mailing list