FreePBX SIP Messaging

To enable SIP messaging with FreePBX, first create a new dialplan inside of extensions_custom.conf. You can modify the file within the FreePBX GUI by going to Admin > Config Edit. Edit the file with the following content:


[astsms] ; astsms is the name of the dialplan and can be changed to whatever you want

exten => _.,1,NoOp(SMS receiving dialplan invoked)

exten => _.,n,NoOp(To ${MESSAGE(to)})

exten => _.,n,NoOp(From ${MESSAGE(from)})

exten => _.,n,NoOp(Body ${MESSAGE(body)})

exten => _.,n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})

exten => _.,n,MessageSend(${ACTUALTO},${MESSAGE(from)})

exten => _.,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})

exten => _.,n,GotoIf($["${MESSAGE_SEND_STATUS}" != "SUCCESS"]?sendfailedmsg)

exten => _.,n,Hangup()

;

; Handle failed messaging

exten => _.,n(sendfailedmsg),Set(MESSAGE(body)="[${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} has failed. Retry later.")

exten => _.,n,Set(ME_1=${CUT(MESSAGE(from),<,2)})

exten => _.,n,Set(ACTUALFROM=${CUT(ME_1,@,1)})

exten => _.,n,MessageSend(${ACTUALFROM},ServiceCenter) ; ServiceCenter is just a name for the sender of the message

exten => _.,n,Hangup()

exten => _.,n,Hangup()

Finally, you must set each extension with the proper messaging context. In the extension, click on the Advanced tab, then enter the name of the dialplan in the Messaging Context field.