Tinderbox Forum

Can an Agent Execute an Applescript

Is it possible for an Agent action to be execution of an Applescript?

This would be useful for setting SMS/Email alerts/reminders as well as integration with other apps.

1 Like

For example, I’d love to find a way to Tweet from Tinderbox. I’ve been toying with https://oysttyer.github.io/ and the run command (but have not been able to get this to work yet), but AppleScript and a compatible app may be simpler.

Use the command line osascript command.

runCommand("osascript ....")

If you search this forum for “osascript” you’ll find a number of examples of readers using the feature.

Be aware: osascript can be very destructive. Test extensively and consider all edge cases before using this technique on your beloved data. Unless you build some feedback in your scripts, for example with display dialog... or the JXA equivalent, you’ll get no indicators of failure.

Thank you @PaulWalters - very helpful

How do I pass along the current Tinderbox note as a parameter to Applescript?

The answer depends on what you are scripting. See the general syntax of runCommand.

See also @pat’s canonical example of using scripting:

2 Likes

You can’t precisely pass a note as a parameter to a script, because you can only pass things that will fit on a command line. But you can pass the $Path as a parameter, and from the path your script can get the text and other attributes. Or, you can pass the attribute value(s) you need.

1 Like

Note that none of this applies exclusively to AppleScript. You can run any executable with runCommand, so you can write the commands in Javascript, Python, Ruby, or whatever you like.