Hello,
I’ve been using SMS on VitalPBX lately and i noticed that the messages sent from certain phone brands (i.e. Fanvil) are not going through,
Looking at the logs i see that those brands will set the MESSAGE(to) header to pjsip:"1234" <sip:1234@pbx.example.com>
instead of pjsip:1234@pbx.example.com
, in result, the SMS_TO variable which is used to get the list of devices is set to "1234" <sip
instead of 1234
.
As a temporary solution i added a few lines to the messages context which filters that out, see below.
Current dialplan
exten => _[-+*#0-9a-zA-Z].,1,NoOp(Receiving SMS)
same => n,Answer()
same => n,NoOp(To: ${MESSAGE(to)})
same => n,NoOp(From: ${MESSAGE(from)})
same => n,NoOp(Body: ${MESSAGE(body)})
same => n,Set(SMS_TO=${CUT(MESSAGE(to),@,1)})
same => n,Set(DEST_SERVER=${CUT(MESSAGE(to),@,2)})
same => n,Set(FROM_TECHNOLOGY=${CUT(SMS_TO,:,1)})
same => n,Set(SMS_TO=${CUT(SMS_TO,:,2)})
same => n,Set(FROM=${CUT(MESSAGE(from),<,2)})
same => n,Set(ACTUALFROM=${CUT(FROM,@,1)})
same => n,Set(FROM_TECHNOLOGY=${TOUPPER(${FROM_TECHNOLOGY})})
same => n,Set(DEVICE=${CUT(ACTUALFROM,:,2)})
same => n,NoOp(devices/${FROM_TECHNOLOGY}/${DEVICE}/assigned_exten)
same => n,Set(EXTENSION=${DB(devices/${FROM_TECHNOLOGY}/${DEVICE}/assigned_exten)})
same => n,Set(TENANT=${DB(devices/${FROM_TECHNOLOGY}/${DEVICE}/tenant)})
same => n,Set(SMS_FROM=${MESSAGE(from)})
same => n,Set(SMS_FROM=${STRREPLACE(SMS_FROM,${DEVICE},${EXTENSION})})
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(failed),Goto(h,1)
New dialplan
exten => _[-+*#0-9a-zA-Z].,1,NoOp(Receiving SMS)
same => n,Answer()
same => n,NoOp(To: ${MESSAGE(to)})
same => n,NoOp(From: ${MESSAGE(from)})
same => n,NoOp(Body: ${MESSAGE(body)})
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=${CUT(MESSAGE(to),@,1)})
same => n,Set(DEST_SERVER=${CUT(MESSAGE(to),@,2)})
same => n,Set(FROM_TECHNOLOGY=${CUT(SMS_TO,:,1)})
same => n,Set(SMS_TO=${CUT(SMS_TO,:,2)})
same => n,Set(FROM=${CUT(MESSAGE(from),<,2)})
same => n,Set(ACTUALFROM=${CUT(FROM,@,1)})
same => n,Set(FROM_TECHNOLOGY=${TOUPPER(${FROM_TECHNOLOGY})})
same => n,Set(DEVICE=${CUT(ACTUALFROM,:,2)})
same => n,NoOp(devices/${FROM_TECHNOLOGY}/${DEVICE}/assigned_exten)
same => n,Set(EXTENSION=${DB(devices/${FROM_TECHNOLOGY}/${DEVICE}/assigned_exten)})
same => n,Set(TENANT=${DB(devices/${FROM_TECHNOLOGY}/${DEVICE}/tenant)})
same => n,Set(SMS_FROM=${MESSAGE(from)})
same => n,Set(SMS_FROM=${STRREPLACE(SMS_FROM,${DEVICE},${EXTENSION})})
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(failed),Goto(h,1)
If you can please fix this in future releases,
Thank you.