More information on the various ways a client can be configured can be seen in AMI Configuration.
Sometimes, the term command may be used instead of the term action. With respect to AMI actions, command is synonymous with action, and the two can be treated the same. For the sake of consistency, we've attempted to use the term action where possible.
Various options for configuration of clients can control which events are sent to a client. Events can be whitelisted/blacklisted explicitly via event filters, or implicitly by class authorizations.
AMI is an ASCII protocol that provides bidirectional communication with clients. An AMI message – action or event – is composed of fields delineated by the '\r\n' characters. Within a message, each field is a key value pair delineated by a ':'. A single space MUST follow the ':' and precede the value. Fields with the same key may be repeated within an AMI message. An action or event is terminated by an additional '\r\n' character.
If present, the Action's corresponding ActionId that caused this event to be created. If an Action contained an ActionId, any event relating the success or failure of that action MUST contain an ActionId field with the same value.
The class authorizations associated with this particular event. The class authorizations for a particular event are in a comma-delineated list. For more information, see class authorizations.
Event responses to an Action only occur if the Action was executed, which means the user had the appropriate class authorization. Therefore they will not have a Privilege field.
The current Asterisk channel name. This corresponds to the Channel field in actions.
A universal unique identifier for the channel. This corresponds to the Uniqueid field in actions.
The text description of the channel state. This will be one of the State descriptions in the table in ChannelState.
The current caller ID number. If the caller ID number is not known, the string "<unknown>" is returned instead.
All channels begin with a Newchannel event. A Newchannel will always contain the following fields:
- The current Channel name that acts as a handle to the channel for that channel's lifetime for a single Asterisk system.
- The Uniqueid for the channel, that allows systems to have a globally unique identifier for the channel.
Changes in the state of the channel, i.e., the ChannelState field, are conveyed via Newstate events.
For each channel variable that is changed, a VarSet event is sent to the client. The VarSet event contains the new value of the appropriate channel variable. Note that channel variables can also be conveyed in ChanVariable fields.
DTMF is indicated via a DTMFBegin/DTMFEnd events. A DTMFEnd event MUST convey the duration of the DTMF tone in milliseconds.