Access X-SMS-To: header in SIP MESSAGE

Hello,
I wans to receive SMS messages via a provider (voip.ms) that sends them via the SIP MESSAGE transaction, however the only place where they send destination DID is in a custom X-SMS-To: header as shown below. SIP_HEADERS() does not show it as it polls header from INVITE messages only, and I am short of ideas how to understand to which DID the SMS is sent.

Here is what they send:
<— SIP read from UDP:192.175.96.74:5060 —>
MESSAGE sip:s@67.212.64.197:5060 SIP/2.0
Via: SIP/2.0/UDP 192.175.96.74:5060;branch=z9hG4bK0ff6ddb8;rport
Max-Forwards: 70
From: “5142086375” sip:5142086375@montreal2.voip.ms;tag=as057b6b3f
To: sip:s@67.212.64.197:5060
Contact: sip:5142086375@192.175.96.74:5060
Call-ID: 056f9a0d131acc5f7593bee874ce3ed0@192.175.96.74:5060
CSeq: 102 MESSAGE
User-Agent: voip.ms
X-SMS-To: 5145320870
Content-Type: text/plain;charset=UTF-8
Content-Length: 12

Test-message
<------------->
— (12 headers 1 lines) —
Sending to 192.175.96.74:5060 (no NAT)
Receiving message!
Found peer ‘VOIPMS-SMS’ for ‘5142086375’ from 192.175.96.74:5060
Looking for s in SMS-IN (domain 67.212.64.197)

<— Transmitting (no NAT) to 192.175.96.74:5060 —>
SIP/2.0 202 Accepted
v: SIP/2.0/UDP 192.175.96.74:5060;branch=z9hG4bK0ff6ddb8;received=192.175.96.74;rport=5060
f: “5142086375” sip:5142086375@montreal2.voip.ms;tag=as057b6b3f
t: sip:s@67.212.64.197:5060;tag=as7e2c8ce7
i: 056f9a0d131acc5f7593bee874ce3ed0@192.175.96.74:5060
CSeq: 102 MESSAGE
Server: Asterisk PBX 16.2.1~dfsg-1+deb10u1
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
k: replaces, timer
l: 0

<------------>

Does someone have an idea of tow to fetch the DID where the SMS goes - 5145320870 in this case?

Thanks, George.

The MESSAGE_DATA dialplan function[1] can be used to retrieve message data, such as SIP headers. I think for chan_sip it would be MESSAGE_DATA(SMS-To) but I haven’t tested it.

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+17+Function_MESSAGE_DATA

Hello jcolp,
Thanks for the suggestion - works as you point it out. MSGTO=${MESSAGE_DATA(X-SMS-To)}; gets exactly what I need. Thansk, again, George.

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