Stepan Novotill
Member
- Joined
- Jul 6, 2013
- Messages
- 85
- Reaction score
- 31
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 =)
Overview: You are running IncrediblePBX2020 or similar and you recieve phone calls via VoIP.ms trunks for which you have SMS over SIP enabled. The phone calls you receive are routed to your various extensions and you run Zoiper-for-Android or some other endpoint which supports SIP Text Messaging. This script will allow multiple text enabled DIDs to forward text messages to multiple extensions concurrently. It will also allow different extensions to send SMS out on whichever outbound trunk you assign to that extension.
Reference material:
SMS Overview: https://wiki.voip.ms/article/SMS
SMS via command promp: http://nerdvittles.com/?p=24058#app18
SMS via your extensions: https://wiki.voip.ms/article/SIP/SMS_with_FreePBX
Instructions:
Read through the material above, then implement SMS via command prompt per the second link above so that you can test your setup, noting that the scripts are already pre-installed in IncrediblePBX2020 so you only need to configure them. Then follow the instructions in the 3rd link above but replace their sample code with the modified code below, and fill in the values per the in-line comments below. There is no magic here, all I've really done is performed the local-extension to DID-number mapping and outbound SMS number to DID mapping which the VoIP.ms article says you'll need to figure out for yourself. That's all!
Of course if you only have one SMS enabled phone number (trunk), then the above becomes much simpler like this. SMS messages will forward to 3 different extensions and all outbound messages go out on the same trunk:
And of course you have to enable your trunks for SMS, and also your extensions in pjsip.endpoint_custom_post.conf like this:
Don't forget to restart asterisk when done and if you made a mistake then of course see here:
$ less /var/log/asterisk/full
Special thanks to Ward Mundy for making stuff like this possible for me through his publishings etc!
Overview: You are running IncrediblePBX2020 or similar and you recieve phone calls via VoIP.ms trunks for which you have SMS over SIP enabled. The phone calls you receive are routed to your various extensions and you run Zoiper-for-Android or some other endpoint which supports SIP Text Messaging. This script will allow multiple text enabled DIDs to forward text messages to multiple extensions concurrently. It will also allow different extensions to send SMS out on whichever outbound trunk you assign to that extension.
Reference material:
SMS Overview: https://wiki.voip.ms/article/SMS
SMS via command promp: http://nerdvittles.com/?p=24058#app18
SMS via your extensions: https://wiki.voip.ms/article/SIP/SMS_with_FreePBX
Instructions:
Read through the material above, then implement SMS via command prompt per the second link above so that you can test your setup, noting that the scripts are already pre-installed in IncrediblePBX2020 so you only need to configure them. Then follow the instructions in the 3rd link above but replace their sample code with the modified code below, and fill in the values per the in-line comments below. There is no magic here, all I've really done is performed the local-extension to DID-number mapping and outbound SMS number to DID mapping which the VoIP.ms article says you'll need to figure out for yourself. That's all!
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 6005550100 route to the the extensions listed below. Replace all instances of the SMS phone number below with yours.
exten => T_6005550100,1,MessageSend(pjsip:701@${HOST_TO},${ACTUAL_FROM}) ; Replace the extension number with yours.
exten => T_6005550100,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => T_6005550100,n,MessageSend(pjsip:702@${HOST_TO},${ACTUAL_FROM}) ; Replace the example extension number with yours.
exten => T_6005550100,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => T_6005550100,n,MessageSend(pjsip:703@${HOST_TO},${ACTUAL_FROM}) ; Replace the example extension number with yours.
exten => T_6005550100,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => T_6005550100,n,MessageSend(pjsip:704@${HOST_TO},${ACTUAL_FROM}) ; Replace the example extension number with yours.
exten => T_6005550100,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => T_6005550100,n,MessageSend(pjsip:705@${HOST_TO},${ACTUAL_FROM}) ; Replace the example extension number with yours.
exten => T_6005550100,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => T_6005550100,n,Return()
; Messages for 6005550101 route to the the extensions listed below. Replace all instances of the SMS phone number below with yours.
exten => T_6005550101,1,MessageSend(pjsip:701@${HOST_TO},${ACTUAL_FROM}) ; Replace the example extension number with yours.
exten => T_6005550101,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => T_6005550101,n,MessageSend(pjsip:703@${HOST_TO},${ACTUAL_FROM}) ; Replace the example extension number with yours.
exten => T_6005550101,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => T_6005550101,n,Return()
; Messages for 6005550102 route to the the extensions listed below. Replace all instances of the SMS phone number below with yours.
exten => T_6005550102,1,MessageSend(pjsip:702@${HOST_TO},${ACTUAL_FROM}) ; Replace the example extension number with yours.
exten => T_6005550102,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => T_6005550102,n,MessageSend(pjsip:704@${HOST_TO},${ACTUAL_FROM}) ; Replace the example extension number with yours.
exten => T_6005550102,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => T_6005550102,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_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(CASE_704=6005550102) ; Messages from extension 704 are to originate from 6005550102
exten => _.,n,Set(CASE_705=6005550100) ; Messages from extension 705 are to originate from 6005550100
exten => _.,n,Set(NUMBER_FROM=${CASE_${EXTENSION_FROM}})
exten => _.,n,Gosub(sms-out,F_${NUMBER_FROM},1)
exten => _.,n,Hangup()
; Messages from 6005550100 are sent via their corresponding trunk below. Replace all instances of the trunk phone number below with yours.
exten => F_6005550100,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_6005550100,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_6005550100,n,MessageSend(${ACTUAL_TO},${ACTUAL_FROM})
exten => F_6005550100,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => F_6005550100,n,Return()
; Messages from 6005550101 are sent via their corresponding trunk below. Replace all instances of the trunk phone number below with yours.
exten => F_6005550101,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_6005550101,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_6005550101,n,MessageSend(${ACTUAL_TO},${ACTUAL_FROM})
exten => F_6005550101,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => F_6005550101,n,Return()
; Messages from 6005550102 are sent via the corresponding trunk below. Replace all instances of the trunk phone number below with yours.
exten => F_6005550102,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_6005550102,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_6005550102,n,MessageSend(${ACTUAL_TO},${ACTUAL_FROM})
exten => F_6005550102,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => F_6005550102,n,Return()
; If you have more text enabled trunks then add sections below as needed.
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,MessageSend(pjsip:701@${HOST_TO},${ACTUAL_FROM}) ; Replace the example extension with yours.
exten => _.,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => _.,n,MessageSend(pjsip:702@${HOST_TO},${ACTUAL_FROM}) ; Replace the example extension with yours.
exten => _.,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => _.,n,MessageSend(pjsip:703@${HOST_TO},${ACTUAL_FROM}) ; Replace the example extension with yours.
exten => _.,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => _.,n,Hangup()
[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)})
exten => _.,n,Set(ACTUAL_FROM="VOIPMS_PHONE_NUMBER" <sip:VOIPMS_ACCOUNT@VOIPMS_SERVER_NAME>) ; Replace VOIPMS_PHONE_NUMBER and VOIPMS_ACCOUNT and VOIPMS_SERVER_NAME with their corresponding values
exten => _.,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 => _.,n,MessageSend(${ACTUAL_TO},${ACTUAL_FROM})
exten => _.,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => _.,n,Hangup()
Code:
[701](+) ; Replace NNN with the corresponding PJSIP extension name
message_context=sms-out
[702](+) ; Replace NNN with the corresponding PJSIP extension name
message_context=sms-out
[703](+) ; Replace NNN with the corresponding PJSIP extension name
message_context=sms-out
Don't forget to restart asterisk when done and if you made a mistake then of course see here:
$ less /var/log/asterisk/full
Special thanks to Ward Mundy for making stuff like this possible for me through his publishings etc!
Last edited by a moderator: