Asterisk cmd MessageSend

MessageSend

Asterisk 10 now has protocol independent support for processing text messages outside of a call. Messages are routed through the Asterisk dialplan. SIP MESSAGE and XMPP are currently supported. There are options in jabber.conf and sip.conf to allow enabling these features.

jabber.conf: see the "sendtodialplan" and "context" options.
sip.conf: see the "accept_outofcall_message", "auth_message_requests" and "outofcall_message_context" options.

The MESSAGE() dialplan function and MessageSend() application have been added to go along with this functionality. More detailed usage information can be found on the Asterisk wiki (https://wiki.asterisk.org/wiki/display/AST/Asterisk+10+Application_MessageSend).

Examples


exten => send_msg,1,NoOp()
same => n,Answer()
same => n,Set(MESSAGE_DATA(X-Movial-Content)=application/x-movial-control\;forwarding=true)
same => n,MessageSend(sip:127.0.0.1:5060)
same => n,Hangup()

; = SIP MESSAGE only works if in sip.conf "accept_outofcall_message=yes" is set! =
exten => 123,1,GotoIf($[${LEN(${MESSAGE(from)})} < 1]?nomessage)
exten => 123,n,NoOp(Message from: ${MESSAGE(from)})
exten => 123,n,NoOp(Message to: ${MESSAGE(to)})
exten => 123,n,NoOp(Message body: ${MESSAGE(body)})
; = Asterisk 11.1.0 has a bug in SIPPEER(ip) that only shows the first two octets of the IP address =
~np~;exten => 123,n,MessageSend(sip:username@w.x.y.z:61018,${MESSAGE(from)})~/np~
exten => 123,n,MessageSend(sip:$[SIPPEER(mypeername,ip)]:$[SIPPEER(mypeername,port)])
exten => 123,n,NoOp(Message send status: ${MESSAGE_SEND_STATUS})
exten => 123,n,HangUp
exten => 123,n(nomessage),Dial(SIP/mypeername,30)
exten => 123,n,HangUp

Connecting a GoIP GSM VoIP gateway to an Asterisk AGI

Related AMI command


> Regarding the AMI MessageSend function available on Asterisk 11, I see
> on the syntax that it supports an argument named "Variable:". The doc is
> not very clear on this. Does this argument allows us to add custom SIP
> headers to the MESSAGE as well?

Yes. The syntax is similar to the Variable: header in other AMI commands,
such as Originate. Instead of setting a dialplan variable, however, you
are instead setting a Message technology variable that will be interpreted
by the channel technology that services the Message request. For the SIP
channel driver, that implies that each one specifies a header to set.

For example:

Action: MessageSend
To: sip:foo.com
From: mypeer
Variable: X-Movial-Content=application/x-movial-control;forwarding=true
Variable: X-Other-Header=bar

Another Example (PJSIP/Asterisk 13.x):

Based on documentation at: (https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+ManagerAction_MessageSend)

and within res_pjsip_messaging.c

The following works with a Kamailio registrar to send a message from Asterisk to a registered phone.

Action: MessageSend
ActionID: 3
To: pjsip:endpoint/sip:user@domain.com
From: "Billy Bob" <sip:billy@billybob.com>
Body: test..test..test


See also


MessageSend

Asterisk 10 now has protocol independent support for processing text messages outside of a call. Messages are routed through the Asterisk dialplan. SIP MESSAGE and XMPP are currently supported. There are options in jabber.conf and sip.conf to allow enabling these features.

jabber.conf: see the "sendtodialplan" and "context" options.
sip.conf: see the "accept_outofcall_message", "auth_message_requests" and "outofcall_message_context" options.

The MESSAGE() dialplan function and MessageSend() application have been added to go along with this functionality. More detailed usage information can be found on the Asterisk wiki (https://wiki.asterisk.org/wiki/display/AST/Asterisk+10+Application_MessageSend).

Examples


exten => send_msg,1,NoOp()
same => n,Answer()
same => n,Set(MESSAGE_DATA(X-Movial-Content)=application/x-movial-control\;forwarding=true)
same => n,MessageSend(sip:127.0.0.1:5060)
same => n,Hangup()

; = SIP MESSAGE only works if in sip.conf "accept_outofcall_message=yes" is set! =
exten => 123,1,GotoIf($[${LEN(${MESSAGE(from)})} < 1]?nomessage)
exten => 123,n,NoOp(Message from: ${MESSAGE(from)})
exten => 123,n,NoOp(Message to: ${MESSAGE(to)})
exten => 123,n,NoOp(Message body: ${MESSAGE(body)})
; = Asterisk 11.1.0 has a bug in SIPPEER(ip) that only shows the first two octets of the IP address =
~np~;exten => 123,n,MessageSend(sip:username@w.x.y.z:61018,${MESSAGE(from)})~/np~
exten => 123,n,MessageSend(sip:$[SIPPEER(mypeername,ip)]:$[SIPPEER(mypeername,port)])
exten => 123,n,NoOp(Message send status: ${MESSAGE_SEND_STATUS})
exten => 123,n,HangUp
exten => 123,n(nomessage),Dial(SIP/mypeername,30)
exten => 123,n,HangUp

Connecting a GoIP GSM VoIP gateway to an Asterisk AGI

Related AMI command


> Regarding the AMI MessageSend function available on Asterisk 11, I see
> on the syntax that it supports an argument named "Variable:". The doc is
> not very clear on this. Does this argument allows us to add custom SIP
> headers to the MESSAGE as well?

Yes. The syntax is similar to the Variable: header in other AMI commands,
such as Originate. Instead of setting a dialplan variable, however, you
are instead setting a Message technology variable that will be interpreted
by the channel technology that services the Message request. For the SIP
channel driver, that implies that each one specifies a header to set.

For example:

Action: MessageSend
To: sip:foo.com
From: mypeer
Variable: X-Movial-Content=application/x-movial-control;forwarding=true
Variable: X-Other-Header=bar

Another Example (PJSIP/Asterisk 13.x):

Based on documentation at: (https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+ManagerAction_MessageSend)

and within res_pjsip_messaging.c

The following works with a Kamailio registrar to send a message from Asterisk to a registered phone.

Action: MessageSend
ActionID: 3
To: pjsip:endpoint/sip:user@domain.com
From: "Billy Bob" <sip:billy@billybob.com>
Body: test..test..test


See also


Created by: JustRumours, Last modification: Wed 21 of Oct, 2015 (01:11 UTC) by phatjmo
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+