There’s no direct way to do this but there is a tricky workaround. Take a look at this post:
The use case its describing is out of date since you no longer need to do this to create persistent notifications from alerts. But you can make any service call this way, just replace persistent_notification/create
with script/your_script_name
at the end of the URL