SMS/MMS in VitXiWebRTC and Mobile apps

In my use case I will have to hard code it.
I assume I have a line for each number I have to hardcode?
same => n,Set(SMS_TO=${IF($[“${SMS_TO}”=“1234567890”]?101:102)})
is the 101 and 102 the extension?
Does this mean texts to “1234567890” translate to extension 101 and 102?

same => n,Set(SMS_CID=1234567${SMS_FROM}) ;Again if the last 4 of your DID matches the extension number. Note: this must be an 11 digit number and it must have SMS enabled in Skyetel

Hows does the outbound work for mapping extensions manually?

1 Like

Unfortunately yes

This means that if the DID is 1234567890 then it will send it to 101, otherwise it will send it to 202. (An if statement it will execute whatever is after the ? when true and after the : when false)

Set(SMS_CID=${IF($["${SMS_FROM}"="101"]?1234567890)})
1 Like

I think the last 2 questions before I can move foward is do I have to have the : false statement?
or will this work?

same => n,Set(SMS_TO=${IF($[“${SMS_TO}”=“1234567890”]?101)})

Is there a way to keep a record of all texts in case of an issue in the future for ediscovery purposes?

1 Like
  1. You don’t need the :
  2. You can see it in the asterisk logs /var/log/asterisk/full
2 Likes

This is exciting!
I appreciate your help with this. I’ll update you when I get it working!

1 Like

What does the setup on the skyetel number end up looking like for the url and post method?

1 Like

Forward = Callback URL
URL = Your PBX IP Port 8888 (Unless you changed the listening port in the script)
Method = Post

1 Like

I got an inbound message to come in to my hard phone, but it won’t send to the webrtc or the mobile endpoints

[2022-04-04 08:05:14] WARNING[10221] res_pjsip_messaging.c: Dest: '116_Vitxi' MSG SEND FAIL: Found endpoint '116_Vitxi' but didn't find an aor/contact for it
[2022-04-04 08:05:14] ERROR[10221] res_pjsip_messaging.c: PJSIP MESSAGE - Could not find endpoint '116_Vitxi' and no default outbound endpoint configured

Outbound messages are not working.

[2022-04-04 08:08:38] VERBOSE[1559][C-00000005] pbx.c: Executing [1XXXXXXXXXX@messages:1] NoOp("Message/ast_msg_queue", "SMS Sending") in new stack
[2022-04-04 08:08:38] VERBOSE[1559][C-00000005] pbx.c: Executing [1XXXXXXXXXX@messages:2] GotoIf("Message/ast_msg_queue", "1?noname") in new stack
[2022-04-04 08:08:38] VERBOSE[1559][C-00000005] pbx_builtins.c: Goto (messages,1XXXXXXXXXX,9)
[2022-04-04 08:08:38] VERBOSE[1559][C-00000005] pbx.c: Executing [1XXXXXXXXXX@messages:9] Set("Message/ast_msg_queue", "SMS_TO=1XXXXXXXXXX") in new stack
[2022-04-04 08:08:38] VERBOSE[1559][C-00000005] pbx.c: Executing [1XXXXXXXXXX@messages:10] GotoIf("Message/ast_msg_queue", "0?messages-internal,1XXXXXXXXXX,1") in new stack
[2022-04-04 08:08:38] VERBOSE[1559][C-00000005] pbx.c: Executing [1XXXXXXXXXX@messages:11] ExecIf("Message/ast_msg_queue", "0?Set(SMS_TO=11XXXXXXXXXX)") in new stack
[2022-04-04 08:08:38] VERBOSE[1559][C-00000005] pbx.c: Executing [1XXXXXXXXXX@messages:12] ExecIf("Message/ast_msg_queue", "0?Hangup()") in new stack
[2022-04-04 08:08:38] VERBOSE[1559][C-00000005] pbx.c: Executing [1XXXXXXXXXX@messages:13] Set("Message/ast_msg_queue", "FROM=sip:116@XXX>") in new stack
[2022-04-04 08:08:38] VERBOSE[1559][C-00000005] pbx.c: Executing [1XXXXXXXXXX@messages:14] Set("Message/ast_msg_queue", "ACTUALFROM=sip:116") in new stack
[2022-04-04 08:08:38] VERBOSE[1559][C-00000005] pbx.c: Executing [1XXXXXXXXXX@messages:15] ExecIf("Message/ast_msg_queue", "0?Set(ACTUALFROM=sip:116)") in new stack
[2022-04-04 08:08:38] VERBOSE[1559][C-00000005] pbx.c: Executing [1XXXXXXXXXX@messages:16] Set("Message/ast_msg_queue", "SMS_FROM=116") in new stack
[2022-04-04 08:08:38] VERBOSE[1559][C-00000005] pbx.c: Executing [1XXXXXXXXXX@messages:17] Set("Message/ast_msg_queue", "SMS_CID=1XXXXXXXXXX) same => n,Noop(To: 1XXXXXXXXXX") in new stack
[2022-04-04 08:08:38] VERBOSE[1559][C-00000005] pbx.c: Executing [1XXXXXXXXXX@messages:18] NoOp("Message/ast_msg_queue", "From: 116") in new stack
[2022-04-04 08:08:38] VERBOSE[1559][C-00000005] pbx.c: Executing [1XXXXXXXXXX@messages:19] Answer("Message/ast_msg_queue", "") in new stack
[2022-04-04 08:08:38] VERBOSE[1559][C-00000005] pbx.c: Executing [1XXXXXXXXXX@messages:20] Set("Message/ast_msg_queue", "SendSMS=") in new stack
[2022-04-04 08:08:38] VERBOSE[1559][C-00000005] pbx.c: Executing [1XXXXXXXXXX@messages:21] Hangup("Message/ast_msg_queue", "") in new stack
[2022-04-04 08:08:38] VERBOSE[1559][C-00000005] pbx.c: Spawn extension (messages, 1XXXXXXXXXX, 21) exited non-zero on 'Message/ast_msg_queue'

Edit: Adjusted formatting for better read - mod

1 Like

@mrizkowsky Please use preformatted text or pastebin.com when posting logs.

2 Likes

Interesting - If I have webrtc open, the message will deliver to it. But if its closed the message won’t deliver to webrtc

1 Like

Look at the SMS like a phone call. If the device is offline it won’t get the message.

You can technically have a retry in conjunction with the ${DEVICE_STATE} function. But then if you restart the server it’ll get lost as well.

1 Like

Is there a way to forward “sip_messages” to “vitxi_messages”?

1 Like

Looks like you SMS_CID is not set properly, that same => n,Noop(To: 1XXXXXXXXXX") should be on a separate line.

1 Like

That did the trick!
I can send and receive.
The only piece left is trying hoping for a way to make webrtc(vitxi) listen all the time like any other phone.

2 Likes

Maybe the developers can make the webrtc use(receive) push to enable this feature?
If a text is incoming you definitely want the webrtc to capture it whether the browser is open or not.

Or can the script be modified to add some sort of command to insert the incoming text into the vitxi database under the sip_messages table?
The challenges would be mapping the phone name, generating a sequential ID and choosing a conversation ID (or generating a new one) and timestamps

Ok new problem.
If I have multiple entries for mapping extensions to DID’s it doesn’t work.
That is for either direction.

[dummy-answer]
exten => s,1,Answer()
same => n,Wait(5)
same => n,Hangup()

[skyetel-sms]
exten => s,1,Answer()
same => n,Set(SMS_FROM=${FILTER(0-9,${from})})
same => n,Set(SMS_TO=${FILTER(0-9,${to})})
same => n,Set(MESSAGE(body)=${body})
same => n,Noop(From: ${SMS_FROM})
same => n,Noop(TO: ${SMS_TO})
same => n,Noop(Body: ${MESSAGE(body)})
same => n,Set(SMS_TO=${IF($[“${SMS_TO}”=“1XXXXXXXXXX”]?116:116)})
same => n,Set(TENANT=tenant)
same => n,Set(DIAL_STRING=${DB(${TENANT}/extensions/${SMS_TO}/dial)})
same => n,GotoIf($[“${DIAL_STRING}”=“”]?sendfailedmsg)
same => n,Set(COUNTER=1)
same => n,Set(CURRENT_DEVICE=${CUT(DIAL_STRING,&,${COUNTER})})
same => n,While($[${EXISTS(${CURRENT_DEVICE})}])
same => n,Set(TECHNOLOGY=${CUT(CURRENT_DEVICE,/,1)})
same => n,Set(USER=${CUT(CURRENT_DEVICE,/,2)})
same => n,GotoIf($[$[“${TECHNOLOGY}”=“IAX2”]|$[“${TECHNOLOGY}”=“DAHDI”]]?next)
same => n,MessageSend(${TOLOWER(${TECHNOLOGY})}:${USER},${SMS_FROM})
same => n,NoOp(SMS Status to ${CURRENT_DEVICE}: ${MESSAGE_SEND_STATUS})
same => n(next),Set(COUNTER=$[${COUNTER} + 1])
same => n,Set(CURRENT_DEVICE=${CUT(DIAL_STRING,&,${COUNTER})})
same => n,EndWhile()
same => n,Goto(h,1)
same => n(sendfailedmsg),Noop(The message to extension ${SMS_TO} has failed. Status: ${MESSAGE_SEND_STATUS})
same => n(failed),Hangup()

[messages]
exten => ZXXXXXX!,1,Noop(SMS Sending) ;Accepts 7 or more digits with the first digit being [1-9]
same => n,GotoIf($[“x${CUT(MESSAGE(to),<,2)}x”=“xx”]?noname)
same => n,Set(SMS_NUM=${CUT(MESSAGE(to),<,2)})
same => n,Set(SMS_NUM=${CUT(SMS_NUM,>,1)})
same => n,Set(SMS_TECH=${CUT(SMS_NUM,:,1)})
same => n,Set(SMS_REAL_TECH=${CUT(MESSAGE(to),:,1)})
same => n,GotoIf($[“${SMS_TECH}”=“${SMS_REAL_TECH}”]?noname)
same => n,Set(MESSAGE(to)=${STRREPLACE(SMS_NUM,${SMS_TECH},${SMS_REAL_TECH})})
same => n(noname),Set(SMS_TO=${FILTER(0-9,${CUT(MESSAGE(to),@,1)})})
same => n,GotoIf($[${LEN(${SMS_TO})} < 10]?messages-internal,${EXTEN},1)
same => n,ExecIf($[“${LEN(${SMS_TO})}”=“10”]?Set(SMS_TO=1${SMS_TO}))
same => n,ExecIf($[${LEN(${SMS_TO})} > 11]?Hangup())
same => n,Set(FROM=${CUT(MESSAGE(from),<,2)})
same => n,Set(ACTUALFROM=${CUT(FROM,@,1)})
same => n,ExecIf($[“${ACTUALFROM}”=~"
“]?Set(ACTUALFROM=${CUT(ACTUALFROM,_,1)}))
same => n,Set(SMS_FROM=${FILTER(0-9,${CUT(ACTUALFROM,:,2)})})
same => n,Set(SMS_CID=${IF($[”${SMS_FROM}"=“116”]?1XXXXXXXXXX)
same => n,Noop(To: ${SMS_TO})
same => n,Noop(From: ${SMS_FROM})
same => n,Answer()
same => n,Set(SendSMS=${SHELL(curl -X POST -v -H “Content-type: application/json” --user user:pass --data “{ "to": "${SMS_TO}", "text": "${MESSAGE(body)}" }” https://sms.skyetel.com/v1/out?from=${SMS_CID})})
same => n,Hangup()

is MMS supported with this?

Any update on adding SMS feature to Vitxi Web?

1 Like

I really wish that the VitalPBX crew would put some effort into the SMS/MMS support.
Unfortunately the script and method here didn’t end up working out for me for more than 1 manual number mapping.

2 Likes