Messages.app AppleScript handler Override 10 second script timeout
Unfortunately Apple hasn't made this easy on us. They have provided no way to change this timeout and sometimes it's the script itself taking too long to run (because Messages.app is terrible at running scripts). I run a rather extensive applescript handler myself, and I interact with Messages.app through AppleScripts run by other processes. Sometimes things freak out and I'm not around to fix it. The workaround I've come up with is to check for a window with the "Wait" button and to click it. Sometimes though, my scripts run right after another and I end up with possibly dozens of windows like the screenshot you pasted. In my case, it is easier to force Messages to quit and then re-open it. I wrote a small AppleScript that does exactly this. You can compile it as an application with "stay open after run handler" selected and it will always make sure Messages is working and open without error windows. You can find it here: https://github.com/davidnewhall/IndigoAppleScripts/blob/master/Restart_Messages.applescript

The other option you could (easily) develop is to run your script in the background and respond once the data is available; that's probably a better approach. You can run osascript from the command line (or a script) to run an AppleScript. There are plenty of examples in my github repo of how to send messages externally.

Good luck!