Repository navigation
Asterisk and FreePBX SMS
HSMM edited this page Nov 5, 2026
·
1 revision
Warning. This recipe follows the Asterisk and chan_dongle documentation and has not yet been tried on a live PBX. Treat it as a starting point and watch the Asterisk console (asterisk -rvvv) while you test.
- chan_dongle starts a dialplan channel for an incoming SMS in the context named by
context=indongle.conf, extensionsms. The sender number is inCALLERID(num), the text in${SMS}. - The dialplan turns it into a SIP MESSAGE with
MessageSendto the PJSIP endpoint (the extension number). - Asterisk sends the MESSAGE to the Contact that the extension registered, the same path an INVITE takes. So it reaches MacroSIP while MacroSIP is registered as that extension.
- A reply from MacroSIP arrives at the PBX as a MESSAGE and lands in the endpoint's
message_context. There the dialplan either forwards it to another extension or sends it out through the modem withDongleSendSMS.
FreePBX has no GUI for this. Put the dialplan into /etc/asterisk/extensions_custom.conf and the endpoint option into /etc/asterisk/pjsip.endpoint_custom_post.conf, then run fwconsole reload.
; extensions_custom.conf
; incoming SMS from the modem -> extension 1001
[from-dongle-sms] ; the same name as context= in dongle.conf
exten => sms,1,NoOp(SMS from ${CALLERID(num)}: ${SMS})
same => n,Set(MESSAGE(body)=${SMS})
same => n,MessageSend(pjsip:1001,${CALLERID(num)})
same => n,Hangup()
; messages from MacroSIP: to other extensions, or out through the modem
[messages]
exten => _XXXX,1,MessageSend(pjsip:${EXTEN},${MESSAGE(from)})
same => n,Hangup()
exten => _+X.,1,DongleSendSMS(dongle0,${EXTEN},${MESSAGE(body)})
same => n,Hangup()
; pjsip.endpoint_custom_post.conf
[1001](+)
message_context=messages
Replace 1001, dongle0 and the number pattern with your own.
- The SMS appears as a message from the phone number. Messages must be on in Settings › General › Messages.
- A reply goes back through the same account.
- Sent means the PBX accepted the message; the modem and the carrier decide the rest.
- Without
message_context, a message sent from MacroSIP lands in the extension's normal context and is usually refused. MacroSIP then shows Not sent with the SIP code.
- If the extension is registered from two devices, which one receives the MESSAGE depends on the Asterisk version and the AOR settings. Test it.
- Messages are plain text only.
- Long SMS are not joined.
See also Messages and Troubleshooting.
User guide
- Installation
- Accounts
- Calls
- Incoming calls
- Contacts and call log
- Messages
- Directory
- Quick keys
- Audio
- Settings
- Menu bar
- Troubleshooting
For developers
Русский
中文