text
stringlengths
0
152
AGI Communication Overview
|
323
AGI command
SPEECH ACTIVATE
GRAMMAR
SPEECH DEACTIVATE
GRAMMAR
SPEECH RECOGNIZE
GOSUB
Description
Activate a grammar that has been loaded.
Deactivate a grammar.
Play a prompt and perform speech recognition, as well as wait for digits to be pressed.
Execute a dialplan subroutine. This will perform in the same way as the GoSub() dialplan
application.
a When the HANGUP AGI command is used, the channel is not immediately hung up. Instead, the channel is marked as
needing to be hung up. Your AGI application must exit first before Asterisk will continue and perform the actual hangup
process.
b While Asterisk includes a core API for handling speech recognition, it does not come with a module that provides a speech
recognition engine. Digium currently provides two commercial options for speech recognition: Lumenvox and Vestec.
Process-based AGI/FastAGI
AGI commands are sent to Asterisk on a single line. The line must end with a single
newline character. Once a command has been sent to Asterisk, no further commands
will be processed until the last command has finished and a response has been sent
back to the AGI application. Here is an example response to an AGI command:
200 result=0
The Asterisk console allows debugging the communications with
an AGI application. To enable AGI communication debugging, run
the agi set debug on command. To turn debugging off, use agi
set debug off. While this debugging mode is on, all communica‐
tion to and from an AGI application will be printed out to the
Asterisk console. An example of this output can be found in
“Quick Start” on page 315.
Async AGI
When you’re using async AGI, you issue commands by using the AGI manager
action. To see the built-in documentation for the AGI manager action, run manager
show command AGI at the Asterisk CLI. A demonstration will help clarify how AGI
commands are executed using the async AGI method. First, an extension is created in
the dialplan that runs an async AGI session on a channel:
exten => 240,AGI(agi:async)
When the AGI dialplan application is executed, a manager event called AsyncAGI will
be sent out with all the AGI environment variables. Details about this event are in
“Async AGI” on page 321. After this, AGI manager actions can start to take place via
AMI.
324
|
Chapter 18: Asterisk Gateway Interface
The following shows an example manager-action execution and the manager events
that are emitted during async AGI processing. After the initial execution of the AGI
manager action, there is an immediate response to indicate that the command has
been queued up for execution. Later, there is a manager event that indicates that the
queued command has been executed. The CommandID header can be used to associate
the initial request with the event that indicates that the command has been executed:
Action: AGI
Channel: SIP/0004F2060EB4-00000013
ActionID: my-action-id
CommandID: my-command-id
Command: VERBOSE "Puppies like cotton candy." 1
Response: Success
ActionID: my-action-id
Message: Added AGI command to queue
Event: AsyncAGI
Privilege: agi,all
SubEvent: Exec
Channel: SIP/0004F2060EB4-00000013
CommandID: my-command-id
Result: 200%20result%3D1%0A
The following output is what was seen on the Asterisk console during this async AGI
session:
-- Executing [7011@phones:1] AGI("SIP/0004F2060EB4-00000013",
"agi:async") in new stack
agi:async: Puppies like cotton candy.
== Spawn extension (phones, 7011, 1)
exited non-zero on 'SIP/0004F2060EB4-00000013'