If you're curious about how we did it, take a look at https://github.com/46Bit/irepl. Messages Beta for Mac still has AppleScript bindings from iChat. We're (ab)using them to pass the iMessages to Heist and then reply.
When apple unveiled FaceTime, Jobs said it would be an open standard. Sadly it never came to be. I wonder why - that could easily be a competitive advantage over Skype or countless other competitors... Maybe a stupid patent (that Apple has licensed to use, but has no right to let others use it too) is the reason?