Consuming AMI UserEvent body

Hello, I wrote a c# client to connect to Asterisk 13. It is a simple code, where I mainly open a socket, connect to the Asterisk and then I send an originate.
My dialplan is also really simple, please take a look at it below:

exten => s,1,Verbose(Tech example context originate_context)
exten => s,n,UserEvent(event_entereddialplano, fabio carvalho)
exten => s,n,Hangup()

All the communication works fine, I am able to start a call with the originate and i can receive all the events coming from Asterisk.
But when i decided to read the body of the user event, in my dial plan “fabio carvalho” for example, i can’t get it in my socket connection.
According to the documentation, the UserEvent data model contains the following fields:

Event: UserEvent
Channel: <value>
ChannelState: <value>
ChannelStateDesc: <value>
CallerIDNum: <value>
CallerIDName: <value>
ConnectedLineNum: <value>
ConnectedLineName: <value>
Language: <value>
AccountCode: <value>
Context: <value>
Exten: <value>
Priority: <value>
Uniqueid: <value>
Linkedid: <value>
UserEvent: <value>

And this is exactly what I can read.

My question is, how can I read the body (or the params) I can pass in the UserEvent ?

Thanks in advance,

I was able to fix it. I found the issue.
When setting the UserEvent variables (or body), i need to give a name to a variable and concatenate it with “:” delimiter

exten => s,n,UserEvent(event_entereddialplan, name:fabio carvalho, age:38)

And i got in my client socket the following:

Event: UserEvent
Privilege: user,all
SequenceNumber: 1956
File: manager.c
Line: 1855
Func: manager_default_msg_cb
Channel: PJSIP/dialer2trunk-00018434
ChannelState: 6
ChannelStateDesc: Up
CallerIDNum: 7167515500
CallerIDName: <unknown>
ConnectedLineNum: 7167515500
ConnectedLineName: <unknown>
Language: en
Context: originate_context
Exten: s
Priority: 3
Uniqueid: 1566576935.144229
Linkedid: 1566576935.144229
UserEvent: event_entereddialplan
 name: fabio carvalho
 age: 38
1 Like

Wiki make references about it, The body may be specified as a , delimited list of key:value pairs.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.