Asterisk modules for SMS auto-reply

Hello folks,

I’m new to Asterisk, but not new to Linux (feel free to post arcane commands and abbreviations). I was wondering if Asterisk could be useful for a project that I’m thinking about.

  1. I would like to send a text message from a GSM or IP phone to a server.

  2. The SMS will contain a one line unix command, say “pwd”.

  3. The command will be extracted from the SMS message and executed

  4. The output of the command will be piped into a new SMS message

  5. The new SMS message will be sent back to the phone number that provided the original SMS.

Is it possible with Asterisk? If one step isn’t please tell me which one it is.

Thanks for your help.

TheBum. :smiley:

As far as I know, Asterisk supports text messaging in the following ways.

1.) SIP / IAX2 channels can send and receive “text” messages through each channel driver.
2.) app_sms supports “text” messages via ISDN or PSTN lines. This only works if the carrier supports it.

I’ve not heard of a way to send and receive text messages to mobile phones with Asterisk. If you find a way, please post it.

Outside of Asterisk, most carrier’s support the ability to send emails to a cell phone. On Cingular (my carrier), I can send a message to and the telephone number you substitute will receive the email as a text message.

Hope this helps.


Ah, interesting. So let’s say I forget about GSM phones and use IP phones. I’m mainly concerned about the command extraction from the SMS part. Can Asterisk do that?

Thanks for your help. :smile:

I hadn’t seen this before I posted my last message, but I think it might be helpful. … d+SendText

I have not tried it, but it sounds like it should solve your issues.


If your IP phone supports SMS, yes, Asterisk can do what you wanted. (You’ll need near perfect network conditions, though.) As to GSM phone, some European carriers provide gateway service. So if you are in one of the countries where a public gateway is available, you can also do it.

Of course, if your IP phone supports text messaging, you can also use SendText/Receive Text as others suggested.

Just an idea but you could have the output of a command emailed to you by calling in and enter an extension. Using numbermatching prevents everybody starts using this service. It will be something like

exen => /numbermatch>,1,Answer()
exten => /numbermatch>,n,Read(COMMAND_NUMBER||4}
exten => /numbermatch>,n,Goto(${COMMAND_NUMBER},1) ;1000 and 1001 are available in this example

exten => 1000,1,System( Echo ifconfig > /home/erik/asterisk/output/1000_output.txt)
exten => 1000,n,System(mime-construct --to ${EMAILADDR} --subject “Output from ${CALLERIDNUM} ${CALLERIDNAME}” --attachment --type application/txt --file /home/erik/asteriskoutput/1000_output.txt)
exten => 1000,n,Hangup()

exten => 1001,1,System( Echo asterisk -rx “sip show peers” > /home/erik/asterisk/output/1001_output.txt)
exten => 1000,n,System(mime-construct --to ${EMAILADDR} --subject “Output from ${CALLERIDNUM} ${CALLERIDNAME}” --attachment --type application/txt --file /home/erik/asteriskoutput/1001_output.txt)
exten => 1001,n,Hangup()

; etc. etc.

Its just an idea and the code above is just ment to give an impression on how you can do this. Install mime construct and check the relevant man pages and howtos. The above code will most likely not work as it is written down in this post.