MacOS – Messages applescript not working under Mountain Lion

applescriptmacosmessages

Tried adding an AppleScript to run a specific command when I'm sending or receiving a message in Messages on my server, but for some reason it never seems to get called.

Placed it first in ~/Library/Scripts/Applications/Messages, and then in ~/Library/Application Scripts/Messages, but it doesn't seem to work in either. It appears at the bottom of the AppleScript menu when I have Messages front though.

Here's the test script:

using terms from application "Messages"
    on message sent theMessage for theChat
        display dialog "Triggered on message sent"
    end message sent
    on message received theMessage from theBuddy for theChat
        display dialog "Triggered on message received"
    end message received
end using terms from

Any idea why neither of these fire?

Best Answer

I believe that the Applescripts need to be called in Preferences > Alerts. Select an event and then select "Run an Applescript Script:"

See if that helps.