MacroSIP
EnglishРусский中文

Asterisk and FreePBX: SMS through chan_dongle

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.

How it works

  1. chan_dongle starts a dialplan channel for an incoming SMS in the context named by context= in dongle.conf, extension sms. The sender number is in CALLERID(num), the text in ${SMS}.
  2. The dialplan turns it into a SIP MESSAGE with MessageSend to the PJSIP endpoint (the extension number).
  3. 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.
  4. 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 with DongleSendSMS.

FreePBX

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.

Configuration

; 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.

What to expect in MacroSIP

Known limits

See also Messages and Troubleshooting.