Reading iMessages


I’m trying to write a script that will go through all the chats in the Messages app - my goal is to find all messages I haven’t replied to and send me an reminder.

But I’m stuck at square one - I can see how many message I have:

tell application "Messages" to log (count of chats)

But I can’t get even simple properties out of a chat; for example:

tell application "Messages" to set x to started of first chat

gives the error: Can’t get started of chat 1." number -1728 from started of chat 1

Any ideas where I’m going wrong…?

Many thanks.


I’ve decided to give up on this and go directly to the database with a shell script.

If it helps anyone, I think this will do the job: