TIPS VoIP.ms SIP Messaging based SMS tutorial

So I attempted this again using @wardmundy's new Nerdvittle article, with the same result. Inbound works, outbound doesn't. I must be stupid to not be able to see what I am doing wrong.
Sigh. So I tried this again with my new Debian 2021 version, same results. Inbound works, outbound doesn't. LoL
 
Hello forum, I just got SMS via SIP working on my IncrediblePBX2020 and so I share my config with those of you who would like to use it. Oops: tuturial? how about tutorial =)
I got inbound and outbound both working with two voip.ms DIDs on the Centos 7 2020 version. I initially had the same problem with either inbound only or outbound only working. Once I fixed the dialplan typos, messages starting flowing back and forth.

I was able to make this work using Sipnetic, ReachMe and Linphone on Android. Two-way text conversations on ReachMe seems to work the best. With Sipnetic and Linphone, I had to enter the phone number separately to reply as if I were starting a whole new conversation.
 
Code:
[sms-in]

exten => _.,1,NoOp(Inbound SMS dialplan invoked)

exten => _.,n,NoOp(To ${MESSAGE(to)})

exten => _.,n,NoOp(From ${MESSAGE(from)})

exten => _.,n,NoOp(Body ${MESSAGE(body)})

exten => _.,n,Set(ACTUAL_FROM=${MESSAGE(from)})

exten => _.,n,Set(HOST_TO=${CUT(MESSAGE(to),@,2)})

exten => _.,n,Set(NUMBER_TO=${MESSAGE_DATA(X-SMS-To)})

exten => _.,n,Gosub(sms-in,T_${NUMBER_TO},1)

exten => _.,n,Hangup()

; Message for NXXNXXXXXX route to the the extensions listed below. Replace all instances of the SMS phone number below with yours.

exten => T_NXXNXXXXXX,1,MessageSend(pjsip:1234@${HOST_TO},${ACTUAL_FROM}) ; Replace the extension number with yours.

exten => T_NXXNXXXXXX,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})

exten => T_NXXNXXXXXX,n,Return()

; If you have more text enabled phone numbers then add sections below as needed.


[sms-out]

exten => _.,1,NoOp(Outbound Message dialplan invoked)

exten => _.,n,NoOp(To ${MESSAGE(to)})

exten => _.,n,NoOp(From ${MESSAGE(from)})

exten => _.,n,NoOp(Body ${MESSAGE(body)})

exten => _.,n,Set(NUMBER_TO=${CUT(CUT(MESSAGE(to),@,1),:,2)})

exten => _.,n,Set(EXTENSION_FROM=${CUT(CUT(MESSAGE(from),@,1),:,2)})

; Here we map the sending EXTENSION_FROM to a corresponding sending NUMBER_FROM before sending it.

exten => _.,n,Set(CASE_1234=NXXNXXXXXX) ; Messages from extension 1234 are to originate from NXXNXXXXXX

exten => _.,n,Set(NUMBER_FROM=${CASE_${EXTENSION_FROM}})

exten => _.,n,Gosub(sms-out,F_${NUMBER_FROM},1)

exten => _.,n,Hangup()

; Messages from NXXNXXXXXX are sent via their corresponding trunk below. Replace all instances of the trunk phone number below with yours.

exten => F_NXXNXXXXXX,1,Set(ACTUAL_FROM="${NUMBER_FROM} <sip:VOIPMS_ACCOUNT@VOIPMS_SERVER_NAME>) ; Replace VOIPMS_ACCOUNT and VOIPMS_SERVER_NAME with their corresponding values

exten => F_NXXNXXXXXX,n,Set(ACTUAL_TO=pjsip:TRUNK_NAME/sip:${NUMBER_TO}@VOIPMS_SERVER_NAME) ; Replace TRUNK_NAME and VOIPMS_SERVER_NAME with their corresponding values

exten => F_NXXNXXXXXX,n,MessageSend(${ACTUAL_TO},${ACTUAL_FROM})

exten => F_NXXNXXXXXX,n,NoOp(Outbound status is ${MESSAGE_SEND_STATUS})

exten => F_NXXNXXXXXX,n,Return()

; If you have more text enabled trunks then add sections below as needed.
 
Last edited:
Ok, so I have outbound working but no inbound.

I have the asterisk console running, verbose set at 9. I text the DID at Voip.ms which is pointed to my registered SIP endpoint and I get.... nothing.

Not a single log item.

Which makes me think:

1) Voip.ms isn't actually sending the SMSs (I doubt this since I can get SMSs on my mobile SIP apps this way)
2) There is a firewall rule blocking it (working on checking that)
3) some configuration settings at Voip.ms?

I assume if something were configured wrong on IPBX, i'd see something in the console logs.
 
Ok, so I have outbound working but no inbound.

I have the asterisk console running, verbose set at 9. I text the DID at Voip.ms which is pointed to my registered SIP endpoint and I get.... nothing.

Not a single log item.

Which makes me think:

1) Voip.ms isn't actually sending the SMSs (I doubt this since I can get SMSs on my mobile SIP apps this way)
2) There is a firewall rule blocking it (working on checking that)
3) some configuration settings at Voip.ms?

I assume if something were configured wrong on IPBX, i'd see something in the console logs.

1)If you don't see incoming texts at the voip.ms SMS messaging center, then check your voip.ms SMS settings. For me, that was two settings on the DID: enable SMS and SMS SIP account.

2)This uses the same ports as voice calls, so if you can make inbound/outbound calls, it's not a firewall issue.

3) See #1.

For me it came down to inbound/outbound context settings and dialplan settings. Once I cleaned all that up, e.g., addressed typos in dialplan, everything worked.
 
FYI: There was a very-difficult-to-spot > typo in all of the lines that look like this:
Code:
Set(ACTUAL_TO=pjsip:TRUNK_NAME/sip:${NUMBER_TO}@VOIPMS_SERVER_NAME>)
They should actually be as follows to keep outbound messages from failing:
Code:
Set(ACTUAL_TO=pjsip:TRUNK_NAME/sip:${NUMBER_TO}@VOIPMS_SERVER_NAME)

GOOD NEWS: Once fixed, the code now works with Grandstream GXV33XX phones with latest firmware to send and receive SMS messages.
 
Last edited:
Read through first post for important steps. Then here's what worked for us in extensions_custom.conf:

Code:
[sms-out]
exten => _.,1,NoOp(Outbound Message dialplan invoked)
exten => _.,n,NoOp(To ${MESSAGE(to)})
exten => _.,n,NoOp(From ${MESSAGE(from)})
exten => _.,n,NoOp(Body ${MESSAGE(body)})
;
; add your VoIPms info in the next 3 lines
exten => _.,n,Set(VOIPMS_ACCOUNT="123456_subacct")
exten => _.,n,Set(VOIPMS_POP="atlanta.voip.ms")
exten => _.,n,Set(VOIPMS_TRUNK="VoIPms-PJsip") ; actual name of your VoIP.ms trunk in FreePBX
;
exten => _.,n,Set(NUMBER_TO=${CUT(CUT(MESSAGE(to),@,1),:,2)})
exten => _.,n,Set(EXTENSION_FROM=${CUT(CUT(MESSAGE(from),@,1),:,2)})
;
; Now map your sending extensions EXTENSION_FROM to corresponding DIDs NUMBER_FROM before continuing.
exten => _.,n,Set(CASE_701=6005550101) ; Messages from extension 701 are to originate from 6005550101
exten => _.,n,Set(CASE_702=6005550102) ; Messages from extension 702 are to originate from 6005550102
exten => _.,n,Set(CASE_703=6005550101) ; Messages from extension 703 are to originate from 6005550101
;
exten => _.,n,Set(NUMBER_FROM=${CASE_${EXTENSION_FROM}})
exten => _.,n,Set(ACTUAL_FROM="${NUMBER_FROM}" <sip:${VOIPMS_ACCOUNT}@${VOIPMS_POP}>)
exten => _.,n,Set(ACTUAL_TO=pjsip:${VOIPMS_TRUNK}/sip:${NUMBER_TO}@${VOIPMS_POP})
exten => _.,n,MessageSend(${ACTUAL_TO},${ACTUAL_FROM})
exten => _.,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => _.,n,Hangup()

Code:
[sms-in]
exten => _.,1,NoOp(Inbound SMS dialplan invoked)
exten => _.,n,NoOp(To ${MESSAGE(to)})
exten => _.,n,NoOp(From ${MESSAGE(from)})
exten => _.,n,NoOp(Body ${MESSAGE(body)})
;
; enter your default incoming SMS extension below
; if you want SMS messages delivered to multiple extensions,
; then clone additional MessageSend lines below with the extension numbers
exten => _.,n,Set(EXTENSION=701)
;
exten => _.,n,Set(ACTUAL_FROM=${MESSAGE(from)})
exten => _.,n,Set(HOST_TO=${CUT(MESSAGE(to),@,2)})
exten => _.,n,Set(NUMBER_TO=${MESSAGE_DATA(X-SMS-To)})
exten => _.,n,MessageSend(pjsip:${EXTENSION}@${HOST_TO},${ACTUAL_FROM})
exten => _.,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => _.,n,Hangup()
 
Last edited:
What if one wanted to send messages out via your carrier for external numbers are you've got here, but also send the message to internal for internal extensions?
 
With this setup, I think you'd have to send them all out to external numbers and use the DIDs associated with the various extensions for delivery back to internal numbers. So you'd just clone the following lines with each external number:
Code:
exten => _.,n,Set(NUMBER_TO=6005550102)
exten => _.,n,Set(ACTUAL_TO=pjsip:${VOIPMS_TRUNK}/sip:${NUMBER_TO}@${VOIPMS_POP})
exten => _.,n,MessageSend(${ACTUAL_TO},${ACTUAL_FROM})
 
FYI: There was a very-difficult-to-spot > typo in all of the lines that look like this:
Code:
Set(ACTUAL_TO=pjsip:TRUNK_NAME/sip:${NUMBER_TO}@VOIPMS_SERVER_NAME>)
They should actually be as follows to keep outbound messages from failing:
Code:
Set(ACTUAL_TO=pjsip:TRUNK_NAME/sip:${NUMBER_TO}@VOIPMS_SERVER_NAME)

GOOD NEWS: Once fixed, the code now works with Grandstream GXV33XX phones with latest firmware to send and receive SMS messages.
I'm FINALLY able to make it work on Groundwire!
 
The VoIP.ms SMS article on Nerd Vittles has undergone substantial revisions to simplify the SMS installation process. Worth a second look for old-timers and a must-read for newbies.

If you're just getting started with VoIP.ms and SMS, this Grandstream GXV3240 refurb is a steal for under $100 including power adapter. Also is WiFi enabled so you can put it anywhere.



 
Last edited:
Hi,
I am having a little issue. Both incoming and outgoing SMS's are working, however the recipient is seeing every message displayed like this:

DELAYED DELIVERY [2023.05.14 20:09:04]
Test message
NOW:
Test message <again>

I am also seeing this in the log:
5 [2023-05-14 20:09:03] VERBOSE[1990][C-00000044] pbx.c: Executing [XXXXXXXXXX@sms-out:4] NoOp(“Message/ast_msg_queue”, "Body DELAYED DELIVERY [2023.05.14 20:09:04]:

The SMS is delivered instantly with no delay so I can't work out why this is happening.
Thank you for looking

Please let me know what further info you need to help solve this.

H.
 
[2023-05-14 20:09:03] VERBOSE[1990][C-00000044] pbx.c: Executing [XXXXXXXXXX@sms-out:4] NoOp(“Message/ast_msg_queue”, "Body DELAYED DELIVERY [2023.05.14 20:09:04]:
This is displaying the message body as it is when hitting Asterisk. So it is receiving that as part of the message. What kind of phones are these?
 
Hi,
I am sending from MizuDroid SIP client to a standard cellphone. Do you think that it could be MizuDroid sending the DELAYED DELIVERY...?

Thanks for the prompting, I just checked the MizuDroid setting and disabled offline chat and set method to IM.
It now works as I hoped.
 
Last edited:
Has anyone gotten this to work with Anveo Direct? I know you could with Anveo, but not Anveo direct for a long time. When I log in to anveo direct it implies it is possible, but the directions SEEM to be for just Anveo. (I am using PBX in a flash, Incredible PBX 13.0.192.19, on a raspberry pi)
Their post below:


Configure Asterisk to send and receive SMS over SIP

Anveo supports SMS over SIP. Asterisk can be configured to send and receive messages through Anveo.
Below is a sample configuration only. You must modify it according to your needs and security standards.

sip.conf

Append the following to the end of sip.conf

[anveo]

type=peer
host=sip.anveo.com
port=5010
username=ACCOUNT_NUMBER
secret=password
insecure=port,invite
disallow=all
allow=ulaw
allow=alaw
allow=g729
dtmfmode=rfc2833
context=from-anveo

Locate [general] secion and add the following
register => ACCOUNT_NUMBER:[email protected]:5010

**** the "register => ACCOUNT_NUMBER:[email protected]:5010" statement should be the first thing under [general]

extensions.conf

Append the following dial plans to the end of extension.conf and customize them according to your needs.

[from-anveo]

exten => s,1,Verbose(Incoming SMS from ${CALLERID(num)})
exten => s,n,Answer
exten => s,n,Set(SMSINRAW=${MESSAGE(body)})
exten => s,n,Set(SMSIN=${URIENCODE(${SMSINRAW})})
exten => s,n,NoOp(Saving SMS message to a file)
exten => s,n,Set(FILE(/var/spool/asterisk/sms/${STRFTIME(${EPOCH},,%F-%T)}-${CALLERID(num)}-${EXTEN}.txt,a)=${MESSAGE(body)})
exten => s,n,Hangup

[smsdial]
exten => 1,1,NoOp(Sending a Message)
exten => 1,n,Set(MESSAGE(body)=Hello)
exten => 1,n,MessageSend(sip:<[email protected]:5010>,<ACCOUNT_NUMBER_ONLY>)
 
Ok, if anyone is interested, I do now have a working way to receive and send SMS messages with AnveoDirect... with a separate app... desktop only so far, but will look to make an Android app.

If any one is interested a copy, let me know... I would have to modify it for other users...
 
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Back
Top