How to hang event handlers on the JXA (JavaScript for Automation) in macOS?

Hi!
I want to hang up the handler for incoming message app Messages. From the documentation, to me personally, nothing is clear. Written only a few words about the parameters, and what to hang and how - no. Online information on handlers is almost there, and if there is something not working. Perhaps there are knowledgeable?
June 7th 19 at 14:41
1 answer
June 7th 19 at 14:43
A good collection of recipes: JavaScript for Automation Cookbook.

To listen to events through Messages - Preferences - AppleScript handler.
screen
5a99ad479551f265405967.png


On stackoverflow dismantled.

Find more questions by tags JavaScriptmacOS