FreePBX - SMS and MMS Configuration

It still seems to be sending to a s@ extension, where is the actual dialplan for this?

is not consistent with the corresponding position in the dialplan provided by voip.ms:

exten => _.,n,Set(ACTUAL_TO=pjsip:${NUMBER_TO}@${HOST_TO})

and, in fact there are no GoSub’s at all, in their code.

Also their ACTUAL_FROM line is in a different place, although that doesn’t affect the overall effect of the code.

also does not match with:

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

Even their original code doesn’t make a lot of sense to me, as I’d expect ACTUAL_TO to contain the IP address of the phone, which probably involves a lookup on the value provided in the NUMBER_TO, which will, effectively, be the DID, here. Maybe they are trying to turn their request, with the To and request URI unusable, and loop it back as though it had the correct final destination in the first place, but that still requires you to handle the looped back message.

Please provide the actual sms-in context you are using and the document from which you obtained it.

Generally, I think you really need to try to understand what their dialplan is trying to do.

If you are referring to the dial plan used in the outbound route, it’s this:

If that’s not what you are referring to, please let me know where I can retrieve the information you seek.

Issue the CLI command “dialplan show smis-in”.

However, the only way that could have got there is if you added it as custom dialplan, so you really should know what it is. You edited sms-out to remove the >, so you must have know were that part of the dialplan is.

It’s what you should have got from https://wiki.voip.ms/article/SIP/SMS_with_FreePBX#Filling_in_the_inbound_messaging_context

If you’re referring to the inbound messaging context, then I can provide that.

I deviated from the tutorial provided by VoIP.ms after we got outbound SMS working (but not inbound SMS), since there is a high likelihood that I will need to add more extensions in the future. I would also be porting over another DID if we get SMS inbound and outbound working. I can change back to the [sms-in] provided by VoIP.ms and grab the logs for that configuration if you prefer.

I retrieved the current config from here. After reviewing your last two replies, I compared the [sms-in] from VoIP.ms and voip-info.org. I then reordered the lines to match that of VoIP.ms. The current configuration is missing a line for:

exten => _.,n,Set(ACTUAL_TO=pjsip:${NUMBER_TO}@${HOST_TO})

ACTUAL_TO field doesn’t appear to have been set, but my assumption is probably premature at best.

Here is my current [sms-in]:

[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(NUMBER_TO=${MESSAGE_DATA(X-SMS-To)})
exten => _.,n,Set(HOST_TO=${CUT(MESSAGE(to),@,2)})
exten => _.,n,Set(ACTUAL_FROM=${MESSAGE(from)})
exten => _.,n,Gosub(sms-in,T_${NUMBER_TO},1)
exten => _.,n,Hangup()

; Messages for 4438407730<U+202C> route to the the extensions listed below. Replace all instances of the SMS phone number below with yours.
exten => T_4438407730<U+202C>,1,MessageSend(pjsip:0001@${HOST_TO},${ACTUAL_FROM}) ; Replace the extension number with yours.
exten => T_4438407730<U+202C>,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
; Repeat the two lines above for every extension that should receive SMS sent to DID 4438407730
exten => T_4438407730,n,Return()

; Messages for 4438407417 route to the the extensions listed below. Replace all instances of the SMS phone number below with yours.
exten => T_4438407417,1,MessageSend(pjsip:0001@${HOST_TO},${ACTUAL_FROM}) ; Replace the extension number with yours.
exten => T_4438407417,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
; Repeat the two lines above for every extension that should receive SMS sent to DID 4438407417.
exten => T_4438407417,n,Return()

; If you have more SMS enabled DID numbers then add sections above as needed.

There are bogus Unicode Pop Directional Formatting characters on the first two priorities of your subroutine, so it executes the wild card lines, instead. The Return line doesn’t have this error, so executes normally.

It is possible that I’m only seeing these because the browser I’m using is highlighting them as a Unicode error (nothing to pop). You might not be seeing them.

image

1 Like

One extra point to note is that, as currently written, I believe an unknown destination will result in a runaway recursion. I don’t think GoSub has a formal limit on recursion depth, so it might go on until Asterisk runs out of memory.

You should probably match s, rather than use “_.”. This might also have made the error more obvious, as the GoSub would have failed, with a non-existent destination.

I just saw that weird Unicode thing as well. I think it came from a browser extension that I’m using. I’ve disabled it for the time being, and am re-checking my config now.

Should the resulting line in the config look like this:

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

I’m not very familiar with writing these contexts yet.

EDIT: After reading through that config a few times, I think I’ve found all instances of that accursed Unicode char that appeared. It didn’t even show up in Notepad++, and I have that setup to mark invisible chars like newlines, tabs, spaces, etc.

After removing the strange chars from the config, I have the following results:

https://drive.google.com/drive/folders/1prB0N6SVD2sjxrBRhsXdx5qZK2bGSt4o?usp=sharing

Once this is resolved, I may need to go through the thread and purge all mentions of my DID (in my own replies).

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