I am writing an action that requires AppleScript and Javascript. What is the best way to combine them in Drafts?
The action pulls a threaded conversation from Apple Mail (which requires AppleScript) and uses an AI API to process it (which requires Javascript to store the credentials in Drafts).
Do you have any suggestions for how to combine the two?
I wrote the original action in AppleScript and haven’t had any luck embedding the javascript in it.
Any suggestions for best practices? Can I separate the two parts in the Drafts Action and pass the email thread text between the two?
I would.look at embedding the AppleScript in JavaScript. Drafts includes an AppleScript class to do this within a (JavaScript) script step in an action.
I would put as much of the logic as I could into JavaScript and use AppleScript only to interrogate the Apple Mail app for the data to be used.
Just in case, other options could be using a Shell Script alternative and utilisong osascript (I’ve opted for that on a few occasions), or calling out to Apple Shortcutsif there’s something that gives you access to that makes your life easierin developing your solution.