How to transfer pjsip simple sip message

I used chan_dongle to recvice sms message. How to transfer this to pjsip message. Please

I can only receive SIM card messages into CLR, or send “simlple sip” messages between extensions
vi /etc/asterisk/extensions_custom.conf
[from-SIM]
exten => s,n,goto(from-trunk,${DONGLEIMEI},1)
exten => sms,1,Verbose(Incoming SMS from ${CALLERID(num)} ${SMS})
exten => sms,n,System(echo ‘${STRFTIME(${EPOCH},%Y-%m-%d %H:%M:%S)} - ${DONGLENAME} - ${CALLERID(num)}: ${SMS}’ >> /var/log/asterisk/sms.log)
exten => sms,n,Hangup()
exten => ussd,1,Verbose(Incoming USSD: ${USSD})
exten => ussd,n,System(echo ‘${STRFTIME(${EPOCH},%Y-%m-%d %H:%M:%S)} - ${DONGLENAME} : ${USSD}’ >> /var/log/asterisk/ussd.log)
exten => ussd,n,Hangup()

[messages]
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()

Thank you for your help, but I don’t know how to do it

This is receive SMS profile:
vi /etc/asterisk/extensions_custom.conf
[from-trunk]
exten => s,n,goto(from-trunk,${DONGLEIMEI},1)
exten => sms,1,Verbose(Incoming SMS from ${CALLERID(num)} ${SMS})
exten => sms,n,Hangup()

When some message comes from +8613812345678. The content is “Hello world”. The logs:
freepbx*CLI>
[SIM] Got single SM from +8613812345678: ‘hello world’
[SIM] Got full SMS from +8613812345678: ‘hello world’
– Executing [sms@from-trunk:1] Verbose(“Local/sms@from-trunk-00000016;1”, “Incoming SMS from +8613812345678 hello world”) in new stack
Incoming SMS from +8613812345678 hello world
– Executing [sms@from-trunk:2] Hangup(“Local/sms@from-trunk-00000016;1”, “”) in new stack
== Spawn extension (from-trunk, sms, 2) exited non-zero on ‘Local/sms@from-trunk-00000016;1’
– Executing [h@from-trunk:1] Macro(“Local/sms@from-trunk-00000016;1”, “hangupcall,”) in new stack
– Executing [s@macro-hangupcall:1] GotoIf(“Local/sms@from-trunk-00000016;1”, “1?theend”) in new stack
– Goto (macro-hangupcall,s,3)
– Executing [s@macro-hangupcall:3] ExecIf(“Local/sms@from-trunk-00000016;1”, “0?Set(CDR(recordingfile)=)”) in new stack
– Executing [s@macro-hangupcall:4] Hangup(“Local/sms@from-trunk-00000016;1”, “”) in new stack
== Spawn extension (macro-hangupcall, s, 4) exited non-zero on ‘Local/sms@from-trunk-00000016;1’ in macro ‘hangupcall’
== Spawn extension (from-trunk, h, 1) exited non-zero on ‘Local/sms@from-trunk-00000016;1’

On the other hand, Extension to extension profile:
vi /etc/asterisk/extensions_custom.conf
[messages]
exten => _.,1,NoOp
exten => _.,n,NoOp
exten => _.,n,NoOp
exten => _.,n,NoOp
exten => _.,n,Set
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()

When extension 1 sends information to extension 2. The content is “no long to see”. The logs:
freepbx*CLI>
– Executing [2@messages:1] NoOp(“Message/ast_msg_queue”, “SMS receiving dialplan invoked”) in new stack
– Executing [2@messages:2] NoOp(“Message/ast_msg_queue”, “To pjsip:2@domain com”) in new stack
– Executing [2@messages:3] NoOp(“Message/ast_msg_queue”, “From “1” <sip:1@domain com>”) in new stack
– Executing [2@messages:4] NoOp(“Message/ast_msg_queue”, “Body no long to see”) in new stack
– Executing [2@messages:5] Set(“Message/ast_msg_queue”, “ACTUALTO=pjsip:2”) in new stack
– Executing [2@messages:6] MessageSend(“Message/ast_msg_queue”, “pjsip:2,“1” <sip:1@domain com>”) in new stack
[2022-03-23 10:04:13] WARNING[9837]: res_pjsip_messaging.c:719 update_to_uri: To address ‘2@domain com’ is not a valid SIP/SIPS URI
– Executing [2@messages:7] NoOp(“Message/ast_msg_queue”, “Send status is SUCCESS”) in new stack
– Executing [2@messages:8] GotoIf(“Message/ast_msg_queue”, “0?sendfailedmsg”) in new stack
– Executing [2@messages:9] Hangup(“Message/ast_msg_queue”, “”) in new stack
== Spawn extension (messages, 2, 9) exited non-zero on ‘Message/ast_msg_queue’

When the SMS message arrives, how to tranfer content to the extension 1 automatically
Thanks ALL!

I used chan_dongle to recvice sms message. How to transfer content to other extension

This is receive SMS profile:
vi /etc/asterisk/extensions_custom.conf
[from-trunk]
exten => s,n,goto(from-trunk,${DONGLEIMEI},1)
exten => sms,1,Verbose(Incoming SMS from ${CALLERID(num)} ${SMS})
exten => sms,n,Hangup()

When some message comes from +8613812345678. The content is “Hello world”. The logs:
freepbx*CLI>
[SIM] Got single SM from +8613812345678: ‘hello world’
[SIM] Got full SMS from +8613812345678: ‘hello world’
– Executing [sms@from-trunk:1] Verbose(“Local/sms@from-trunk-00000016;1”, “Incoming SMS from +8613812345678 hello world”) in new stack
Incoming SMS from +8613812345678 hello world
– Executing [sms@from-trunk:2] Hangup(“Local/sms@from-trunk-00000016;1”, “”) in new stack
== Spawn extension (from-trunk, sms, 2) exited non-zero on ‘Local/sms@from-trunk-00000016;1’
– Executing [h@from-trunk:1] Macro(“Local/sms@from-trunk-00000016;1”, “hangupcall,”) in new stack
– Executing [s@macro-hangupcall:1] GotoIf(“Local/sms@from-trunk-00000016;1”, “1?theend”) in new stack
– Goto (macro-hangupcall,s,3)
– Executing [s@macro-hangupcall:3] ExecIf(“Local/sms@from-trunk-00000016;1”, “0?Set(CDR(recordingfile)=)”) in new stack
– Executing [s@macro-hangupcall:4] Hangup(“Local/sms@from-trunk-00000016;1”, “”) in new stack
== Spawn extension (macro-hangupcall, s, 4) exited non-zero on ‘Local/sms@from-trunk-00000016;1’ in macro ‘hangupcall’
== Spawn extension (from-trunk, h, 1) exited non-zero on ‘Local/sms@from-trunk-00000016;1’

On the other hand, PJSIP Extension to PJSIP extension profile:
vi /etc/asterisk/extensions_custom.conf
[messages]
exten => _.,1,NoOp
exten => _.,n,NoOp
exten => _.,n,NoOp
exten => _.,n,NoOp
exten => _.,n,Set
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()

When extension 1 sends information to extension 2. The content is “no long to see”. The logs:
freepbxCLI>
– Executing [2@messages:1] NoOp(“Message/ast_msg_queue”, “SMS receiving dialplan invoked”) in new stack
– Executing [2@messages:2] NoOp(“Message/ast_msg_queue”, "To pjsip:2@192
168183") in new stack
– Executing [2@messages:3] NoOp(“Message/ast_msg_queue”, “From “1” sip:1@192*168*18*3”) in new stack
– Executing [2@messages:4] NoOp(“Message/ast_msg_queue”, “Body no long to see”) in new stack
– Executing [2@messages:5] Set(“Message/ast_msg_queue”, “ACTUALTO=pjsip:2”) in new stack
– Executing [2@messages:6] MessageSend(“Message/ast_msg_queue”, “pjsip:2,“1” sip:1@192*168*18*3”) in new stack
[2022-03-23 10:04:13] WARNING[9837]: res_pjsip_messaging.c:719 update_to_uri: To address ‘2@19216818*3’ is not a valid SIP/SIPS URI
– Executing [2@messages:7] NoOp(“Message/ast_msg_queue”, “Send status is SUCCESS”) in new stack
– Executing [2@messages:8] GotoIf(“Message/ast_msg_queue”, “0?sendfailedmsg”) in new stack
– Executing [2@messages:9] Hangup(“Message/ast_msg_queue”, “”) in new stack
== Spawn extension (messages, 2, 9) exited non-zero on ‘Message/ast_msg_queue’

When the SMS message arrives, how to tranfer content to the extension 1 automatically

please help please help please help

I misunderstood what you meant by ACTUALTO in the original example.

This is an Asterisk forum, and Asterisk does not use the term “extension” in the same way as FreePBX. By extension 1, I assume you really meant endpoint PJSIP/1.

It is difficult to read the logs as they have not been marked up as pre-formatted text, so the forum is interpreting parts of them as invalid markup and removing it. However, the From line appears to be malformed and the To line contains an undefined scheme, “pjsip”.

Also, for some reason, you have removed the parameters from the dialplan, which also make it difficult to understand what is being done.

If you actually want it to go to PSIP/1, you must either hard code the destination of MessageSend to be pjsip:1 (assuming that exists), or you must examine the metadata or data of the message and set the destination based on that. Currently you seem to be taking the, malformed, URI in the To metadata and using the bogus scheme and suer part to directly form the destination. As it starts pjsip:2@ … that means you send the message to endpoint PJSIP/2., which the log say was done successfully, in spite of the malformed From and To information.

Please note that any advice, from this forum, is likely to assume you have complete control of the dialplan, which is not generally the case for FreePBX.

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