FreePBX - SMS and MMS Configuration

After spending almost a month getting basic inbound and outbound calls to work, I’m moving to the next major task - enabling SMS and MMS. From what little I’ve red online, FreePBX supports SMS if you’re using SIPStation (SIP trunk) and Zulu. My current SIP trunk is through VoIP.ms, and I followed this documentation:

However, I now have more questions than answers. After performing the configuration changes, I am still in a position where I can only send/receive text messages through VoIP.ms’s web interface. I can’t do so via my current softphone. I feel like an idiot who’s missed something obvious, and even VoIP.ms’s online customer service wasn’t quite able to demystify this for me. I was hoping to port my Google Voice number over, but I can’t do so if I lose this functionality. I also saw this post:

I was unable to replicate their success. During my online search, I ran into a few projects for self-hosted SMS gateways. They all look cool, but I don’t know if those will be of much use to me. Isn’t VoIP.ms acting as my SMS gateway in this scenario?

How can I send/receive SMS and MMS, without using VoIP.ms’s web interface?

Have you reviewed your logs to see what is happening when you attempt to send a SMS?

1 Like

I will pull those up as soon as I have free time today, and post them as a Google Drive share link. Stay tuned.

Please share via pastebin. (pastebin.freepbx.org)

2 Likes

I’ve created a few unlisted pastebins, which is good until 365 days from now, that can be viewed here:

I own/use all phone numbers listed in the logs. I placed one test call to myself, to make sure my trunk and outbound route works.

EDIT: Just minutes after posting those pastebin links, I received 2 calls from one of my DIDs that I don’t remember placing. I may need to remove these pastebin links once we’ve figured this out.

Can you please explain what happened in these logs?

It looks to me like a misconfigured using from-internal instead of from-pstn and then something is setting the context to ast_msg_queue. So if I am reading this right, it looks like you are receiving an SMS to the from-internal context which tries to place an outgoing call.

Follow the VoIP.ms wiki and it should work fine, if it doesn’t report back with logs.

I will address each of your points:

  1. I cannot fully explain what happened in these logs. That is part of the reason I asked for help.
  2. Your explanation indicates that you know more about this than I do. I will use this info later today, when reviewing my FreePBX config.
  3. I linked 2 articles from the VoIP.ms Wiki, in the OP. I used those to get to where I am now.

This step doesn’t seem to have worked:

The initial context should be sms-out (not any of the others listed above). Are you actually using chan_pjsip on the incomng side?

1 Like

Here is a screenshot of the config I used:

If something looks off, let me know. I’ve tested it with both extension name and DID number, to no avail.

I think so. That’s the only option I’ve been using during my setup (SIP trunk, outbound/inbound rules, etc.) thus far. I’ve heard of chan_sip, but I think that’s legacy/deprecated (not viable for use).

You need to set here the extension number from where you send SMS from

1 Like

And repeat that for every extension that can send SMS.

FreePBX, a normally used, expects endpoint names to be the same as extension numbers, as you would dial them, and, unlike Asterisk, uses extension to refer to both of them.

1 Like

Glad that I kept it simple and have only added one extension so far (0001). The instructions from VoIP.ms made it sound like they wanted either a DID number or the Extension’s alphanumeric Name/ID. Testing that change now:

Still didn’t go through :slightly_frowning_face: I know that SMS/MMS is enabled for my DID. It looks like Google Voice and VoIP.ms are fine. Still not sure about FreePBX config. Here’s what I’ve got so far…

Shows up in Google Voice:

Shows up in VoIP.ms:

Not showing up in MicroSIP (softphone):

Asterisk Log Files:

Raw text from log:

449	[2022-10-07 11:16:09] VERBOSE[2723][C-00000001] pbx.c: Executing [4438407417@sms-out:1] NoOp("Message/ast_msg_queue", "Outbound Message dialplan invoked") in new stack	
450	[2022-10-07 11:16:09] VERBOSE[2723][C-00000001] pbx.c: Executing [4438407417@sms-out:2] NoOp("Message/ast_msg_queue", "To pjsip:[email protected]") in new stack	
451	[2022-10-07 11:16:09] VERBOSE[2723][C-00000001] pbx.c: Executing [4438407417@sms-out:3] NoOp("Message/ast_msg_queue", "From "TopHatProductions115" <sip:[email protected]>") in new stack	
452	[2022-10-07 11:16:09] VERBOSE[2723][C-00000001] pbx.c: Executing [4438407417@sms-out:4] NoOp("Message/ast_msg_queue", "Body Testing, testing, 1 2 3. Can anyone see this?") in new stack	
453	[2022-10-07 11:16:09] VERBOSE[2723][C-00000001] pbx.c: Executing [4438407417@sms-out:5] Set("Message/ast_msg_queue", "NUMBER_FROM=0001") in new stack	
454	[2022-10-07 11:16:09] VERBOSE[2723][C-00000001] pbx.c: Executing [4438407417@sms-out:6] Set("Message/ast_msg_queue", "NUMBER_TO=4438407417") in new stack	
455	[2022-10-07 11:16:09] VERBOSE[2723][C-00000001] pbx.c: Executing [4438407417@sms-out:7] Set("Message/ast_msg_queue", "ACTUAL_FROM="0001" <sip:[email protected]>") in new stack	
456	[2022-10-07 11:16:09] VERBOSE[2723][C-00000001] pbx.c: Executing [4438407417@sms-out:8] Set("Message/ast_msg_queue", "ACTUAL_TO=pjsip:VoIP.ms/sip:[email protected]>") in new stack	
457	[2022-10-07 11:16:09] VERBOSE[2723][C-00000001] pbx.c: Executing [4438407417@sms-out:9] MessageSend("Message/ast_msg_queue", "pjsip:VoIP.ms/sip:[email protected]>,"0001" <sip:[email protected]>") in new stack	
458	[2022-10-07 11:16:09] ERROR[4744] res_pjsip.c: Unable to create outbound MESSAGE request to endpoint VoIP.ms as URI 'sip:[email protected]>' is not valid	
459	[2022-10-07 11:16:09] WARNING[4744] res_pjsip_messaging.c: PJSIP MESSAGE - Could not create request	
460	[2022-10-07 11:16:09] VERBOSE[2723][C-00000001] pbx.c: Executing [4438407417@sms-out:10] NoOp("Message/ast_msg_queue", "Send status is FAILURE") in new stack	
461	[2022-10-07 11:16:09] VERBOSE[2723][C-00000001] pbx.c: Executing [4438407417@sms-out:11] Hangup("Message/ast_msg_queue", "") in new stack	
462	[2022-10-07 11:16:09] VERBOSE[2723][C-00000001] pbx.c: Spawn extension (sms-out, 4438407417, 11) exited non-zero on 'Message/ast_msg_queue'

I think it looks way shorter than the previous attempts, but I don’t know if that’s a good thing or not.

EDIT: Just found this link. Have you seen this info before?

“>” is not a valid character in a URI.

This appears to be an error in the instructions from voip.ms. They may have used <…> to indicate a meta name, then thought that might confuse, but missed the closing >, when removing the brackets. Most people would have corrected the error themselves.

1 Like

I apologise for not seeing that until now. I will try removing that, and let you know how it goes.

After removing the syntax error, outbound SMS (from MicroSIP, through FreePBX) now works. But inbound SMS does not. Halfway there :smiley:

Can you please share an inbound trace?

I’m not sure if this counts exactly as an inbound trace. I sent an SMS to my DID, from my Google Voice number, and grabbed the resulting Asterisk log lines.

34	[2022-10-08 14:54:37] VERBOSE[2839][C-00000001] pbx.c: Executing [s@sms-in:1] NoOp("Message/ast_msg_queue", "Inbound SMS dialplan invoked") in new stack	
35	[2022-10-08 14:54:37] VERBOSE[2839][C-00000001] pbx.c: Executing [s@sms-in:2] NoOp("Message/ast_msg_queue", "To pjsip:[email protected];line=exkkpfi") in new stack	
36	[2022-10-08 14:54:37] VERBOSE[2839][C-00000001] pbx.c: Executing [s@sms-in:3] NoOp("Message/ast_msg_queue", "From "4438407417" <sip:[email protected]>") in new stack	
37	[2022-10-08 14:54:37] VERBOSE[2839][C-00000001] pbx.c: Executing [s@sms-in:4] NoOp("Message/ast_msg_queue", "Body Testing inbound SMS, can you see me?") in new stack	
38	[2022-10-08 14:54:37] VERBOSE[2839][C-00000001] pbx.c: Executing [s@sms-in:5] Set("Message/ast_msg_queue", "ACTUAL_FROM="4438407417" <sip:[email protected]>") in new stack	
39	[2022-10-08 14:54:37] VERBOSE[2839][C-00000001] pbx.c: Executing [s@sms-in:6] Set("Message/ast_msg_queue", "HOST_TO=108.3.168.21;line=exkkpfi") in new stack	
40	[2022-10-08 14:54:37] VERBOSE[2839][C-00000001] pbx.c: Executing [s@sms-in:7] Set("Message/ast_msg_queue", "NUMBER_TO=4438407730") in new stack	
41	[2022-10-08 14:54:37] VERBOSE[2839][C-00000001] pbx.c: Executing [s@sms-in:8] Gosub("Message/ast_msg_queue", "sms-in,T_4438407730,1") in new stack	
42	[2022-10-08 14:54:37] VERBOSE[2839][C-00000001] pbx.c: Executing [T_4438407730@sms-in:1] NoOp("Message/ast_msg_queue", "Inbound SMS dialplan invoked") in new stack	
43	[2022-10-08 14:54:37] VERBOSE[2839][C-00000001] pbx.c: Executing [T_4438407730@sms-in:2] NoOp("Message/ast_msg_queue", "To pjsip:[email protected];line=exkkpfi") in new stack	
44	[2022-10-08 14:54:37] VERBOSE[2839][C-00000001] pbx.c: Executing [T_4438407730@sms-in:3] Return("Message/ast_msg_queue", "") in new stack	
45	[2022-10-08 14:54:37] VERBOSE[2839][C-00000001] pbx.c: Executing [s@sms-in:9] Hangup("Message/ast_msg_queue", "") in new stack	
46	[2022-10-08 14:54:37] VERBOSE[2839][C-00000001] pbx.c: Spawn extension (sms-in, s, 9) exited non-zero on 'Message/ast_msg_queue'

I’ll be reviewing this, to see if I can figure out where I tripped up.

Turning on pjsip logger and re-sending test SMS, to see if I can get more log info…

EDIT: Here are the log results:

521	[2022-10-08 15:04:55] VERBOSE[2883] res_pjsip_logger.c: <--- Received SIP request (538 bytes) from UDP:208.100.60.66:5060 --->	
522	MESSAGE sip:[email protected]:5060;line=exkkpfi SIP/2.0	
523	Via: SIP/2.0/UDP 208.100.60.66:5060;branch=z9hG4bK4d895534;rport	
524	Max-Forwards: 70	
525	From: "4438407417" <sip:[email protected]>;tag=as211ac180	
526	To: <sip:[email protected]:5060;line=exkkpfi>	
527	Contact: <sip:[email protected]:5060>	
528	Call-ID: [email protected]:5060	
529	CSeq: 102 MESSAGE	
530	User-Agent: voip.ms	
531	X-SMS-To: 4438407730	
532	Content-Type: text/plain;charset=UTF-8	
533	Content-Length: 55	
534		
535	Sending another inbound SMS test. Are you getting this?	
536	[2022-10-08 15:04:55] VERBOSE[17681] res_pjsip_logger.c: <--- Transmitting SIP response (381 bytes) to UDP:208.100.60.66:5060 --->	
537	SIP/2.0 202 Accepted	
538	Via: SIP/2.0/UDP 208.100.60.66:5060;rport=5060;received=208.100.60.66;branch=z9hG4bK4d895534	
539	Call-ID: [email protected]:5060	
540	From: "4438407417" <sip:[email protected]>;tag=as211ac180	
541	To: <sip:[email protected];line=exkkpfi>;tag=z9hG4bK4d895534	
542	CSeq: 102 MESSAGE	
543	Server: FPBX-16.0.21.18(18.14.0)	
544	Content-Length: 0	
545		
546		
547	[2022-10-08 15:04:55] VERBOSE[2839][C-00000001] pbx.c: Executing [s@sms-in:1] NoOp("Message/ast_msg_queue", "Inbound SMS dialplan invoked") in new stack	
548	[2022-10-08 15:04:55] VERBOSE[2839][C-00000001] pbx.c: Executing [s@sms-in:2] NoOp("Message/ast_msg_queue", "To pjsip:[email protected];line=exkkpfi") in new stack	
549	[2022-10-08 15:04:55] VERBOSE[2839][C-00000001] pbx.c: Executing [s@sms-in:3] NoOp("Message/ast_msg_queue", "From "4438407417" <sip:[email protected]>") in new stack	
550	[2022-10-08 15:04:55] VERBOSE[2839][C-00000001] pbx.c: Executing [s@sms-in:4] NoOp("Message/ast_msg_queue", "Body Sending another inbound SMS test. Are you getting this?") in new stack	
551	[2022-10-08 15:04:55] VERBOSE[2839][C-00000001] pbx.c: Executing [s@sms-in:5] Set("Message/ast_msg_queue", "ACTUAL_FROM="4438407417" <sip:[email protected]>") in new stack	
552	[2022-10-08 15:04:55] VERBOSE[2839][C-00000001] pbx.c: Executing [s@sms-in:6] Set("Message/ast_msg_queue", "HOST_TO=108.3.168.21;line=exkkpfi") in new stack	
553	[2022-10-08 15:04:55] VERBOSE[2839][C-00000001] pbx.c: Executing [s@sms-in:7] Set("Message/ast_msg_queue", "NUMBER_TO=4438407730") in new stack	
554	[2022-10-08 15:04:55] VERBOSE[2839][C-00000001] pbx.c: Executing [s@sms-in:8] Gosub("Message/ast_msg_queue", "sms-in,T_4438407730,1") in new stack	
555	[2022-10-08 15:04:55] VERBOSE[2839][C-00000001] pbx.c: Executing [T_4438407730@sms-in:1] NoOp("Message/ast_msg_queue", "Inbound SMS dialplan invoked") in new stack	
556	[2022-10-08 15:04:55] VERBOSE[2839][C-00000001] pbx.c: Executing [T_4438407730@sms-in:2] NoOp("Message/ast_msg_queue", "To pjsip:[email protected];line=exkkpfi") in new stack	
557	[2022-10-08 15:04:55] VERBOSE[2839][C-00000001] pbx.c: Executing [T_4438407730@sms-in:3] Return("Message/ast_msg_queue", "") in new stack	
558	[2022-10-08 15:04:55] VERBOSE[2839][C-00000001] pbx.c: Executing [s@sms-in:9] Hangup("Message/ast_msg_queue", "") in new stack	
559	[2022-10-08 15:04:55] VERBOSE[2839][C-00000001] pbx.c: Spawn extension (sms-in, s, 9) exited non-zero on 'Message/ast_msg_queue'	
560	[2022-10-08 15:05:03] VERBOSE[17681] res_pjsip_logger.c: <--- Transmitting SIP request (475 bytes) to UDP:208.100.60.66:5060 --->	
561	OPTIONS sip:[email protected]:5060 SIP/2.0	
562	Via: SIP/2.0/UDP 108.3.168.21:5060;rport;branch=z9hG4bKPj01094728-fe54-4c98-86e3-775b3823f8ca	
563	From: <sip:[email protected]>;tag=e8866d84-9370-4f78-ac1d-9f86ab1c94d9	
564	To: <sip:[email protected]>	
565	Contact: <sip:[email protected]:5060>	
566	Call-ID: c5d3c536-b328-4a43-8f5c-98c8f08d15d8	
567	CSeq: 14506 OPTIONS	
568	Max-Forwards: 70	
569	User-Agent: FPBX-16.0.21.18(18.14.0)	
570	Content-Length: 0