How are you interacting w/ iMessage? They have an API now?
Another approach and mechanism can be seen in this repo https://github.com/ZekeSnider/Jared, where you can interact with the iMessage database directly and script a device to handle inbound and outbound messages.