How can I retrieve SMS on Android phone?

I’ve written a sketch which processes a line of text. I want to be able to send my input via SMS. Then the program is alerted by incoming SMS and prosses the text in the SMS.
I’ve tried to google a solution without success.