Hello, I use Distro 14 with Asterisk 16.
All my extensions are PJSIP extensions. Today I can send SIP SIMPLE IM message between extensions but only to one AOR contact of the PJSIP extension. If I have multiple phones connected to one extensions (multiple AOR), I can’t arrived to send a this message to all the phones.
My message_context is correctly set for all the PJSIP extension with astsms
With this custom context, it sends the message to the last registered AOR.
[astsms]
exten => _.,1,NoOp(SMS receiving dialplan invoked)
exten => _.,n,NoOp(To ${MESSAGE(to)})
exten => _.,n,NoOp(From ${MESSAGE(from)})
exten => _.,n,NoOp(Body ${MESSAGE(body)})
exten => _.,n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
exten => _.,n,MessageSend(${ACTUALTO},${MESSAGE(from)})
exten => _.,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => _.,n,GotoIf($["${MESSAGE_SEND_STATUS}" != “SUCCESS”]?sendfailedmsg)
exten => _.,n,Hangup()
;
; Handle failed messaging
exten => _.,n(sendfailedmsg),Set(MESSAGE(body)="[${STRFTIME(${EPOCH},%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} has failed. Retry later.")
exten => _.,n,Set(ME_1=${CUT(MESSAGE(from),<,2)})
exten => _.,n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
exten => _.,n,MessageSend(${ACTUALFROM},ServiceCenter)
exten => _.,n,Hangup()
exten => _.,n,Hangup()
I have tried this context too :
[astsms]
exten => s,1,NoOp(Sending message!)
same => n,NoOp(To ${MESSAGE(to)})
same => n,NoOp(From ${MESSAGE(from)})
same => n,NoOp(Body ${MESSAGE(body)})
same => n,Set(from=${CUT(MESSAGE(from),@,1)})
same => n,Set(from_domain=${CUT(MESSAGE(from),@,2)})
same => n,Set(from_domain=${CUT(from_domain,;,1)})
same => n,Set(from_domain=${CUT(from_domain,>,1)})
same => n,Set(from_no=${CUT(from,:,2)})
same => n,Set(to=${CUT(MESSAGE(to),@,1)})
same => n,Set(to_no=${CUT(to,:,2)})
same => n,Set(dial=${DB(DEVICE/${to_no}/dial)})
same => n,Set(tech=${TOLOWER(${CUT(dial,/,1)})})
same => n,GotoIf($["${tech}" != “pjsip”]?sendmsg)
same => n,Set(contacts=${PJSIP_AOR(${to_no},contact)})
same => n,While($["${SET(contact=${SHIFT(contacts,)})}" != “”])
same => n,Set(contacturi=${PJSIP_CONTACT(${contact},uri)})
same => n,Set(sipuri=${CUT(contacturi,;,1)})
same => n,Set(to_no=${CUT(contacturi,@,2)})
same => n(sendmsg),MessageSend(${tech}:${to_no},sip:${from_no}@${from_domain})
same => n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
same => n,GotoIf($[${EXISTS(${contacturi})}]?:end)
same => n,EndWhile
same => n(end),HangUp()
But when I send an IM, I have a SIP/2.0 404 Not Found SIP Response
**2021/02/15 21:54:53.938630 XX.XX.XX.XX:8780 -> YY.YY.YY.YY:1485**
SIP/2.0 **404** Not Found
Via: SIP/2.0/UDP 192.168.0.20:1485;rport=1485;received=XX.XX.XX.XX;branch=z9hG4bKBApZ9FbfI2GwNvjv
Call-ID: **28BF83481A8C3765C865DDAAAC987F3C5DB4E5D8**
From: "Charles" <sip:[email protected]>;tag=EDF6D3BC5254C0266B1DB6E01E33D0C2
To: <sip:[email protected]>;tag=z9hG4bKBApZ9FbfI2GwNvjv
CSeq: 2 MESSAGE
Server: FPBX-14.0.16.4.1(16.15.1)
Content-Length: 0
Do you have any idea ?
Thanks