AGI(command[,args])
Full arguments reference
commandrequired - How AGI should be invoked on the channel.args- Arguments to pass to the AGI script or server.arg1requiredarg2
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 onstdinandstdout. If the full path to the script is not provided, theastagidirspecified inasterisk.confwill 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 eitheragiorhagi.AsyncAGI- Use AMI to control the channel in AGI. AGI commands can be invoked using theAMIaction, with a variety of AGI specific events passed back over the AMI connection. AsyncAGI should be invoked by passingagi:asyncto the command parameter.
Note
As of 1.6.0, this channel will not stop dialplan execution on hangup inside of this application. Dialplan execution will continue normally, even upon hangup until the AGI application signals a desire to stop (either by exiting or, in the case of a net script, by closing the connection).
A locally executed AGI script will receive SIGHUP on hangup from the channel, except when it is already hung up. A fast AGI server will correspondingly receive a HANGUP inline with the command dialog. Both of these signals may be disabled by setting the AGISIGHUP channel variable to no before executing the AGI application. Alternatively, if you would like the AGI application to exit immediately after a channel hangup is detected, set the AGIEXITONHANGUP variable to yes.
same => n,AGI(/tmp/my-cool-script.sh,${FOO})
same => n,AGI(my-cool-script.sh)
same => n,AGI(agi://127.0.0.1/awesome-script)
same => n,AGI(agi:async)
This application sets the following channel variable upon completion:
- AGISTATUS - The status of the attempt to the run the AGI script text string, one of:
SUCCESSFAILURENOTFOUNDHANGUP
commandrequired - How AGI should be invoked on the channel.args- Arguments to pass to the AGI script or server.arg1requiredarg2
User Notes
Know a tip or gotcha for this topic? Share it below and help others.
Contribute a note
Share a tip, gotcha, or practical example. Keep it under 2000 characters. No questions (use the Asterisk community forums for support). Wrap code in backticks.