Are applescripts for Messages still saved in /Library/Application Scripts/com.apple.iChat? That seems like an odd location, but I didn't find a folder for com.apple.messages

I tried saving this in the com.apple.iChat folder, but nothing happened:

using terms from application "Messages"
    on message received
        display dialog "testing"
    end message received
end using terms from
  • AppleScript handler support was removed from Messages in macOS High Sierra 10.13.4. – user3439894 Jan 4 at 6:51
  • Does that mean there's no way to have a script run when a message is received? I suppose I could try using a watched folder to keep track of when the chat.db-wal file gets opened. It seems to get opened whenever Messages receives a new message and when the message is read. – 2oh1 Jan 4 at 7:22
  • Watching the file/folder will only let you know the state of it has changed, not what the change was. I'd assume it's possible to determine through an sqlite3 query what actually changed in the database and what the change was. – user3439894 Jan 4 at 15:32
  • You're right. I mistakenly assumed there would be a way to have an applescript check if unread messages exist. Apparently not. – 2oh1 Jan 4 at 22:48
  • You might find this question stackoverflow.com/questions/48086287/… interesting. – user3439894 Jan 4 at 23:12

You could try Jared, which is an iMessage Chat Bot: https://github.com/ZekeSnider/Jared

There's a sample plugin in the repository, yet this requires some Xcode knowledge.

It seems Apple removed the handler because they launched iMessage for Business https://developer.apple.com/business-chat/. If you look into the API, there‘s a „Message received“ handler, so it may be possible using that service, but probably not a good idea for personal stuff.

Edit2: Back to the SQL solution, this article dives pretty deep in explaining: https://stmorse.github.io/journal/iMessage.html

Edit3: I found the following repositories based on nodejs : https://github.com/CamHenlin/imessageclient https://github.com/CamHenlin/imessagebot

|improve this answer|||||
  • +1 Great answer! Business chat is actually a server (cloud) technology similar to Alexa, Watson, and Cortana (being pushed back from consumer to business) – Allan Jan 17 at 14:33
  • Also, messages are stored in a sqlite database...maybe you could monitor that database for changes and respond accordingly? Though that's getting into a software development question. – Allan Jan 17 at 14:36
  • Check my updated answer, this is pretty useful: stmorse.github.io/journal/iMessage.html – form.follows.function Jan 17 at 19:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .