SMS to Email or file

I need some help or advice on getting voip sms working.

We created business cards that show direct DID as cell numbers. These number forward directly to the employees cell number. Customers sometimes text these numbers and currently they go nowhere. I would like them to either go to email or a file that we can track.

We are currently using 1-VOIP as our sip trunking and they provide sms enabled numbers. Our current system is FreePBX with Asterisk 13.27.1. Just upgraded from FreePBX 13 yesterday which was a headache.

When I turn on sip debugging, I can see the sms message but am not sure how to retrieve it using agi or php and have it sent to an email or file. Below is a snippet of the sip trace.

I tried researching this all day today and could not find anything useful.

[2019-10-11 14:03:40] VERBOSE[2941] chan_sip.c:
<— SIP read from UDP:XX.XX.XXX.XX:5060 —>
MESSAGE sip:443XXXXXX@XX.XXX.XX.195:5060 SIP/2.0
Via: SIP/2.0/UDP 209.XXX.XXX.XX:5060;branch=z7hG4bK5beb3e52
Max-Forwards: 70
From: “443XXXXXX” sip:443XXXXXX@XXX.XXX.XXX.XX;tag=as2d6815bb
To: sip:443XXXXXX@XXX.XXX.XXX.XX:5060
Contact: sip:443XXXXXX@XXX.XXX.XXX.XX:5060
Call-ID: 76313b01505c60215831ed9c38bb5d22@XXX.XXX.XXX.XX:5060
User-Agent: VYLmedia-SBCDAL
Content-Type: text/plain;charset=UTF-8
Content-Length: 7

[2019-10-11 14:03:40] VERBOSE[2941] chan_sip.c: — (11 headers 1 lines) —
[2019-10-11 14:03:40] VERBOSE[2941] chan_sip.c: Sending to XXX.XXX.XXX.XX:5060 (NAT)
[2019-10-11 14:03:40] VERBOSE[2941] chan_sip.c: Receiving message!
[2019-10-11 14:03:40] VERBOSE[2941] chan_sip.c: Looking for 443XXXXXX in dpma_message_context (domain XXX.XXX.XXX.XX)
[2019-10-11 14:03:40] VERBOSE[2941] chan_sip.c:
<— Transmitting (NAT) to XXX.XXX.XXX.XX:5060 —>
SIP/2.0 404 Not Found
Via: SIP/2.0/UDP XXX.XXX.XXX.XX:5060;branch=z7hG4bK5beb3e52;received=XXX.XXX.XXX.XX;rport=5060
From: “443XXXXXX” sip:443XXXXXX@XXX.XXX.XXX.XX;tag=as2d6815bb
To: sip:443XXXXXX@XXX.XXX.XXX.XX:5060;tag=as243031a8
Call-ID: 76313b01505c60215831ed9c38bb5d22@XXX.XXX.XXX.XX:5060
Server: FPBX-
Supported: replaces, timer
Content-Length: 0

Any help would be appreciated.


Assuming you are using the, deprecated, chan_sip, the sample configuration contains:

;accept_outofcall_message = no ; Disable this option to reject all MESSAGE requests outside of a
; call. By default, this option is enabled. When enabled, MESSAGE
; requests are passed in to the dialplan.

;outofcall_message_context = messages ; Context all out of dialog msgs are sent to. When this
; option is not set, the context used during peer matching
; is used. This option can be defined at both the peer and
; global level.

is the function used to retrieve that message from the context.

Note that Asterisk sees these as SIP messages, not as SMS ones.

See also which would be the appropriate place to explain how to do this in FreePBX.


Thanks for replying so quickly.

I am using chan_sip and did not know it was deprecated. I am sorry if I am asking beginner questions but I know enough to be dangerous in programming in asterisk.

What would you use instead of chan_sip, pjsip? I read a lot of group messages that pjsip was not very stable but those messages were posted a couple of years ago.

Also, I looked at some of the example links you posted and read them before but did not understand them fully.

I guess what I am asking is there any examples on using MESSAGE() in the dialplan because I cannot figure out how to extrapolate the message from the sip?


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