This two pages are (most of) what you need:
About chat messages:
http://www.wowwiki.com/Hooking_chat_messages
References on the events:
http://www.wowwiki.com/Events_(API)
You'll basically create a function that is applied to a chat message (which basically tests if it matches what you want, and if it does, executes your main function). You will create a frame (which will not be a graphical frame, just an object used to link chat events to your function). You will then register the CHAT_MESSAGE_WHISPER on this frame, and you will use something like MyFrame:SetScript("OnEvent",myfunction). This will basically call "myfunction" whenever the event CHAT_MESSAGE_WHISPER is fired.