Thanks for your reply, Richard. It offers some hints, but I'm running python3 and using interpolated strings (so I think the script invocation is different, although I am not that great at python). Also for the triggers I've registered through the UI the "Invoke Script Function" action shows up in the exported JSON as "iTermRPCTrigger" instead of as "ScriptTrigger" o I wonder if that Action type is expecting a different set of params.
Based on that additional information, though, I've been able to get to a parameter that looks like "script.py(msg:matches[0])" which gets me to a different place, at least - now I get a message telling me that there's "No function registered for invocation "script.py()"". script.py shows up in my Scripts menu, so I guess I'm missing a different piece of the puzzle about registering functions.
My loaded script looks like this
<snip>
#!/usr/bin/env python3.7
import iterm2
import os
async def main(connection, msg):
# do some os.systems calls with the passed-in "msg"
iterm2.run_until_complete(main)
</snip>