See this for sending an SMS from a script; but I don't know how to trigger a script on an incoming message.