Change SMS FROM address depending on source extension

I’m using VoIP.MS to send and receive SMS messages. When I send a message from an extension, all outgoing messages have a FROM address of “5552221234.” The EXTENSION_FROM address is the extension of the sending phone (e.g. 1000). What is a good way to “rewrite” the FROM address based on the extension of the sending phone?

e.g. 1000 → 5552221234, 1001 → 5552226789, etc…

[voipms-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="5552221234" <sip:12345@newyork.voip.ms>) ; Replace VOIPMS_PHONE_NUMBER and VOIPMS_ACCOUNT and VOIPMS_SERVER_NAME with their corresponding values
exten => _.,n,Set(ACTUAL_TO=pjsip:voipms/sip:${NUMBER_TO}@newyork.voip.ms) ; 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()

Additionally, is there any strategy to be able to “reply” to an incoming text message where the source number is set to the destination number of the original message?

You could store that info in AstDB, something like that:
SMSFrom/1000 5552221234
SMSFrom/1001 5552226789

Then you will be available to use ${DB(SMSFrom/${EXTEN})} To set ACTUAL_FROM value.

Sorry for any syntax errors.

you can also try this

[voipms-sms-out]
exten => _.,1/1000,Set(ACTUAL_FROM="5552221234" <sip:12345@newyork.voip.ms>)
exten => _.,1/1001,Set(ACTUAL_FROM="5552226789" <sip:12345@newyork.voip.ms>)

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