Storage Of SIP Messages Going To Extension

I think I have SIP messaging working with our soft phones thanks to https://community.freepbx.org/t/sip-messaging-with-freepbx/70621. While each phone is registered to the PBX, I can send/receive messages from each phone.

I assumed that if a phone was not registered at the time a message was sent to it from another phone, the PBX would store the message until the next time the target phone registered, but that it not what I am finding. When the phone later registers, the message seems to be lost.

Do I have more work to do in order for the messages to be stored until the extension registers? Or is that the way it is under the most recent FreePBX release?

Thanks.

These messages are SIP messages. Normally, the SIP server would try sending the messages and give up after a couple of failed delivery attempts.

The dialplan you use does not check if the device is online, nor does it use a storage solution to retry once the device comes online.

Thanks for your reply, @PitzKey. Makes sense.

Hi @urbnsr

The way I am handling this is if a phone is unregistered, I send the text by e-mail to the user.

It’s not as elegant a solution as queuing up the messages but in reality phones don’t go unregistered that often.

[messages-in]
; Deliver to local 4-digit extension
exten => _XXXX,1,Set(FROMUSER=${CUT(MESSAGE(from),<,2)})
same => n,Set(FROMUSER=${CUT(FROMUSER,@,1)})
same => n,Set(FROMUSER=${CUT(FROMUSER,:,2)})
same => n,Set(DIALSTRING=${DB(DEVICE/${EXTEN}/dial)})
same => n,Set(TODEVICE=${TOLOWER(${STRREPLACE(DIALSTRING,"/",":")})})
same => n,MessageSend(${TODEVICE},${FROMUSER})
same => n,GotoIf($["${DEVICE_STATE(${DIALSTRING})}" == "UNAVAILABLE"]?messages-in,mail-${EXTEN},1)
same => n,GotoIf($["${MESSAGE_SEND_STATUS}" != "SUCCESS"]?messages-in,mail-${EXTEN},1)
same => n,Hangup()

exten => _mail-X.,1,NoOp(Sending mail to user if vm box exists, else send to catchall)
same => n,Set(MAILADDR=${VM_INFO(${EXTEN:5},email)})
same => n,ExecIf($["${MAILADDR}" == ""]?Set([email protected]))
same => n,System(echo "Text message from ${MESSAGE(from)} to ${EXTEN:5} - ${MESSAGE(body)}" | mail -s "New text received while offline" ${MAILADDR})
same => n,Hangup()

This does two checks to see whether the message was sent. The DEVICE_STATE test checks whether Asterisk knows the device is unregistered. The MESSAGE_SEND_STATUS test checks whether the send failed for any other reason. Oddly, MESSAGE_SEND_STATUS is “SUCCESS” even if I try to send a message to a nonexistant PJSIP contact. So that’s why it has to check twice.

Nothing wrong with this, I lately started using the IF function a lot.

same => n,Set(MAILADDR=${IF($["empty${VM_INFO(${EXTEN:5},email)}" != "empty"]?${VM_INFO(${EXTEN:5},email)}:[email protected])})

Great! Thanks for the options. I can learn from this. Thanks.

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