AGI()
Synopsis
Executes an AGI compliant application.
Description
Executes an Asterisk Gateway Interface compliant program on a channel. AGI allows Asterisk to launch external programs written in any language to control a telephony channel, play audio, read DTMF digits, etc. by communicating with the AGI protocol.
The following variants of AGI exist, and are chosen based on the value passed to command:
AGI
- The classic variant of AGI, this will launch the script specified by command as a new process. Communication with the script occurs onstdin
andstdout
. If the full path to the script is not provided, theastagidir
specified inasterisk.conf
will be used.FastAGI
- Connect Asterisk to a FastAGI server using a TCP connection. The URI to the FastAGI server should be given in the form[scheme]://host.domain[:port][/script/name]
, where scheme is eitheragi
orhagi
.
In the case ofhagi
, an SRV lookup will be performed to try to connect to a list of FastAGI servers. The hostname in the URI must be prefixed with_agi._tcp
. prior to the DNS resolution. For example, if you specify the URIhagi://agi.example.com/foo.agi
the DNS query would be for_agi._tcp.agi.example.com
. You will need to make sure this resolves correctly.AsyncAGI
- Use AMI to control the channel in AGI. AGI commands can be invoked using theAMI
action, with a variety of AGI specific events passed back over the AMI connection. AsyncAGI should be invoked by passingagi:async
to the command parameter.Example: Start the AGI script /tmp/my-cool-script.sh, passing it the contents of the channel variable FOOExample: Start the AGI script my-cool-script.sh located in the astagidir directory, specified in asterisk.confExample: Connect to the FastAGI server located at 127.0.0.1 and start the script awesome-scriptThis application sets the following channel variable upon completion:Example: Start AsyncAGI
AGISTATUS
- The status of the attempt to the run the AGI script text string, one of:- SUCCESS
- FAILURE
- NOTFOUND
- HANGUP
Syntax
AGI(command,arg1,[arg2[,...]])
Arguments
command
- How AGI should be invoked on the channel.args
- Arguments to pass to the AGI script or server.arg1
arg2
[,arg2
...]
See Also
- Asterisk 18 ManagerAction_AGI
- Asterisk 18 ManagerEvent_AsyncAGIStart
- Asterisk 18 ManagerEvent_AsyncAGIEnd
- Asterisk 18 Application_EAGI
- Asterisk 18 Application_DeadAGI
asterisk.conf
Import Version
This documentation was imported from Asterisk Version GIT-18-20d9158