[asterisk-users] Event response (AMI)

Matthew Jordan mjordan at digium.com
Fri May 11 08:31:33 CDT 2012


----- Original Message ----- 

> From: "Shahid H" <shahidh at gmail.com>
> To: asterisk-users at lists.digium.com
> Sent: Friday, May 11, 2012 6:12:25 AM
> Subject: [asterisk-users] Event response (AMI)

> When I execute the ACTION commands set then the EVENT would response
> back. How would I know which ACTION are they belong/reference to?

> For example:

> ACTION: Originate
> Channel: SIP/test
> Exten: 215
> Timeout: 30000
> Context: test
> Priority: 1
> ActionID: 111112222333

> Response: Success
> ActionID: 111112222333
> Message: Originate successfully queued

> EVENT response when I hang up the call:

> Event: Hangup
> Privilege: call,all
> Channel: SIP/test-0000007f
> Uniqueid: 1336690030.189
> CallerIDNum: <unknown>
> CallerIDName: <unknown>
> Cause: 16
> Cause-txt: Normal Clearing

> As you can see, how would I know which which ACTION was that belong
> to?

> If I were coding in PHP (AMI) to Originate the calls then I want to
> detect which call hanged up.

> Thanks

In general, there is no explicit tying of events with a particular action
that caused those events, as AMI events are completely independent of AMI
actions.  The exception to this, of course, are AMI events that are reporting
success/failure of an AMI action, in which case they will share the same
ActionId header (if the action specified an ActionId as well).

In your particular case, if I were writing a system that wanted to associate
a created channel with an Originate Action, after I issue the Originate,
I'd listen for a NewChannel event.  If that NewChannel event specified a
channel that was created in the context I specified and with a
technology/extension that I specified, I'd set that as the channel I just
asked to be created. From there on, subsequent events (VarSet, NewExten,
Hangup, etc.) that are associated with that channel will contain a Channel:
header with that value.

--
Matthew Jordan
Digium, Inc. | Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org



More information about the asterisk-users mailing list