Catalina Messages app: run applescript on receive new message & when the message is read? 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
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