Asterisk Project : SMS and extensions.conf

The following contexts are recommended.

; Mobile Terminated, RX. This is used when an incoming call from the SMS arrives
; with the queue (called number and sub address) in ${EXTEN} 
; Running an app after receipt of the text allows the app to find all messages 
; in the queue and handle them, e.g. email them. 
; The app may be something like smsq --process=somecommand --queue=${EXTEN} to
; run a command for each received message 
; See below for usage 
[smsmtrx]
exten = _X.,1,SMS(${EXTEN},a)
exten = _X.,2,System("someapptohandleincomingsms ${EXTEN}")
exten = _X.,3,Hangup
;
; Mobile originated, RX. This is receiving a message from a device, e.g. 
; a Magic Messenger on a sip extension 
; Running an app after receipt of the text allows the app to find all messages 
; in the queue and handle then, e.g. sending them to the public SMSC 
; The app may be something like smsq --process=somecommand --queue=${EXTEN} 
; to run a command for each received message 
; See below for example usage 
[smsmorx]
exten = _X.,1,SMS(${EXTEN},sa) 
exten = _X.,2,System("someapptohandlelocalsms ${EXTEN}") 
exten = _X.,3,Hangup

smsmtrx is normally accessed by an incoming call from the SMSC. In the UK this call is from a CLI of 080058752X0 where X is the sub address. As such a typical usage in the extensions.conf at the point of handling an incoming call is:

exten = _X./8005875290,1,Goto(smsmtrx,${EXTEN},1)
exten = _X./_80058752[0-8]0,1,Goto(smsmtrx,${EXTEN}-${CALLERID(num):8:1},1)

Alternatively, if you have the correct national prefix on incoming CLI, e.g. using dahdi_hfc, you might use:

exten = _X./08005875290,1,Goto(smsmtrx,${EXTEN},1)
exten = _X./_080058752[0-8]0,1,Goto(smsmtrx,${EXTEN}-${CALLERID(num):9:1},1)

smsmorx is normally accessed by a call from a local sip device connected to a Magic Messenger. It could however by that you are operating Asterisk as a message centre for calls from outside. Either way, you look at the called number and goto smsmorx. In the UK, the SMSC number that would be dialed is 1709400X where X is the caller sub address. As such typical usage in extension.config at the point of handling a call from a sip phone is:

exten = 17094009,1,Goto(smsmorx,${CALLERID(num)},1) 
exten = _1709400[0-8],1,Goto(smsmorx,${CALLERID(num)}-{EXTEN:7:1},1)