How to enable instant messaging support for PJSIP endpoints on Asterisk 18+

Here is /etc/asterisk/extensions_custom.conf
[message]
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()

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()

It form

PJSIP:202 send message to PJSIP:101(offline)
when pjsip:202 send fail, the system will send a new message to pjsip:202 in expected. But It not happened
It is work on chan_sip and asterisk 13.
Sending failed msg doesn’t work in asterisk 18+
please help

You have 1, not 102. What is is in the From header in the actual MESSAGE request from the phone?

I meant 202, not 102.

However you should be sending to pjsip:202, not to sip:202, for whatever 202 should really be. The dirty way of doing this would be pj${ACTUALFROM}

sorry i fix the demo number。

PJSIP:202 send message to PJSIP:101(offline)
when pjsip:202 send fail, the system will send a new message to pjsip:202 in expected. But It not happened
It is work on chan_sip and asterisk 13.

this is log

asterisk -rvvvvvvv
Connected to Asterisk 18.16.0 currently running on freepbx (pid = 2584)
– Executing [101@messages:1] NoOp(“Message/ast_msg_queue”, “SMS receiving dialplan invoked”) in new stack
– Executing [101@messages:2] NoOp(“Message/ast_msg_queue”, “To pjsip:[email protected]”) in new stack
– Executing [101@messages:3] NoOp(“Message/ast_msg_queue”, “From “1” sip:[email protected]”) in new stack
– Executing [101@messages:4] NoOp(“Message/ast_msg_queue”, “Body thisismessage”) in new stack
– Executing [101@messages:5] Set(“Message/ast_msg_queue”, “ACTUALTO=pjsip:101”) in new stack
– Executing [101@messages:6] MessageSend(“Message/ast_msg_queue”, “pjsip:101,“1” sip:[email protected]”) in new stack
[2023-03-07 02:27:44] ERROR[20645]: res_pjsip_messaging.c:1257 msg_send: PJSIP MESSAGE - Could not find endpoint ‘101’ and no default outbound endpoint configured
– Executing [101@messages:7] NoOp(“Message/ast_msg_queue”, “Send status is FAILURE”) in new stack
– Executing [101@messages:8] GotoIf(“Message/ast_msg_queue”, “1?sendfailedmsg”) in new stack
– Goto (messages,101,10)
– Executing [101@messages:10] Set(“Message/ast_msg_queue”, “MESSAGE(body)=”[07032023-02:27:44] Your message to 101 has failed. Retry later.“”) in new stack
– Executing [101@messages:11] Set(“Message/ast_msg_queue”, “ME_1=sip:[email protected]>”) in new stack
– Executing [101@messages:12] Set(“Message/ast_msg_queue”, “ACTUALFROM=sip:202”) in new stack
– Executing [101@messages:13] MessageSend(“Message/ast_msg_queue”, “sip:202,ServiceCenter”) in new stack
[2023-03-07 02:27:44] WARNING[2604][C-00000011]: message.c:1290 msg_send_exec: No message technology ‘sip’ found.
– Executing [101@messages:14] Hangup(“Message/ast_msg_queue”, “”) in new stack
== Spawn extension (messages, 101, 14) exited non-zero on ‘Message/ast_msg_queue’

asterisk -r
Connected to Asterisk 18.16.0 currently running on freepbx (pid = 2584)
[2023-03-07 01:24:14] WARNING[14606]: res_pjsip_messaging.c:327 handle_single_token: Dest: ‘101’ MSG SEND FAIL: Found endpoint ‘101’ but didn’t find an aor/contact for it
[2023-03-07 01:24:14] ERROR[14606]: res_pjsip_messaging.c:1257 msg_send: PJSIP MESSAGE - Could not find endpoint ‘101’ and no default outbound endpoint configured
[2023-03-07 01:24:14] WARNING[2604][C-00000011]: message.c:1290 msg_send_exec: No message technology ‘sip’ found.

perhaps there are some error in here.
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)})

You are still trying to send to chan_sip, not chan_pjsip. See previous reply.

exten => _.,n,MessageSend(pj${ACTUALFROM},ServiceCenter)
It works when I add pj.
It only has a WARNING,
WARNING[14336]: res_pjsip_messaging.c:719 update_to_uri: To address ‘[email protected]’ is not a valid SIP/SIPS URI
It may not matter

Thanks. David

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