O'Reilly logo

Asterisk: The Future of Telephony by Leif Madsen, Jared Smith, Jim Van Meggelen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

AGI() — Executes an AGI-compliant application

Synopsis

    [E]AGI(program[,arguments])

Executes an Asterisk Gateway Interface-compliant program on the current channel. AGI programs allow external programs (written in almost any language) to control the telephony channel by playing audio, reading DTMF digits, and so on. Asterisk communicates with the AGI program on STDIN and STDOUT. The specified arguments are passed to the AGI program.

The program must be set as executable in the underlying filesystem. The program path is relative to the Asterisk AGI directory, which by default is /var/lib/asterisk/agi-bin/.

If you want to run an AGI when no channel exists (such as in an h extension), use the DeadAGI() application instead. You may want to use the FastAGI() application if you want to do AGI processing across the network.

If you want access to the inbound audio stream from within your AGI program, use EAGI() instead of AGI(). Inbound audio can then be read in on file descriptor number three.

Returns -1 on hangup or if the program requested a hangup, or 0 on non-hangup exit.

    ; call the demo AGI program
    exten => 123,1,AGI(agi-test)
    exten => 123,2,EAGI(eagi-test)

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required