Automation of actions using Drafts

I have a question. Perhaps the answer has already appeared on the forum. Years ago I used Simplenote. When I exported a note from the program, the file landed in Tinderbox in an inbox. I then selected a category and the note automatically landed in the selected location. Now I use Drafts. Notes land in inbox. Unfortunately, after specifying the category, they do not move further. Can I ask for help.

Sure! What you want to do, I suspect, is to add a rule to the inbox container for your watched files – one something like this:

if(....the note has category "Pets"....) {$Container="/Pets"}

You could do this with an agent, of course, and that might be more idiomatic for Tinderbox.

Query: (....the note has category "Pets"....)
1 Like

BTW, there is a nice Apple Script for sending your Drafts notes to a Tinderbox file, see Tinderbox and Drafts (getdrafts.com) - #5 by midas0441. I was thinking of doing a video on this. Would that be of interest?

5 Likes

Yes, please!!!

1 Like

Of course! Please. I have just used this script. I was referring to the next stage. Placing the note in the right place, e.g. with an index to the “Zettelkasten” category / prototype (it can also be person or other). I would like to take this opportunity to thank you for your previous videos. I watch them with great attention.

Thank you for your quick reply. I will check the working today.

Yes, @satikusala, that would be great.

1 Like

Yes, I will definitely watch this video!

Thx for all that you do.

Doug

1 Like

I just try to use the AppleScript for Drafts and I can not seem to get it to work. Has Tbx9 changed that much?

No; the Tinderbox 9 scripting language is a superset of Tinderbox 8’s.

In your target Tinderbox file do you have a container called “Inbox”? If not, add one and try again.

I tried @midas0441 nice script using the detailed step-by-step instructions posted by @satikusala (thanks for those!). Like @jwilkins I had a little trouble getting it to work as is, I think mainly because of errors in file path names and failure to have the required container. I decided to simplify a little and have the script create the container if it does not already exist.

Here’s what now works here:


-- The action must be initiated from Drafts.app
-- midas0441 original script at https://forum.eastgate.com/t/tinderbox-and-drafts-getdrafts-com/2892/5
-- satikusala installation instructions at https://forum.eastgate.com/t/tinderbox-and-drafts-getdrafts-com/2892/11
-- Needs two Drafts actions. The first pushes selected text to the clipboard.

on execute (draft)
	set theTitle to the clipboard
	set theBody to the content of the draft
	set theCreateDate to ("" & createdAt of the draft)
	set theModifyDate to ("" & modifiedAt of the draft)
	set theTags to (tags of the draft)
	set theListOfTags to convertListToString(theTags, "; ")
	
	tell application "Tinderbox 9"
		tell front document
			if not (exists note "Inbox") then make new note with properties {name:"Inbox"}
			set theContainer to note "inbox"
			set myNote to make new note with properties {name:theTitle} at theContainer
			tell myNote
				set value of attribute "Text" to theBody
				set value of attribute "Created" to theCreateDate
				set value of attribute "Modified" to theModifyDate
				set value of attribute "Tags" to theListOfTags
				set value of attribute "DisplayedAttributes" to "Created;Modified;Tags"
			end tell
		end tell
	end tell
end execute

on convertListToString(theList, theDelimiter)
	set AppleScript's text item delimiters to theDelimiter
	set theString to theList as string
	set AppleScript's text item delimiters to ""
	return theString
end convertListToString

It is important to change the default [[draft]] in the first action to [[selection]] so it looks like this.

Could you point me to the additions to the scripting language in Tinderbox 9? Tried to find them in release notes, AppleScript dictionary.

See the backstage release note for

  • b475, b474, b473, b472,b471 (8.8.0)

Thanks. I don’t know about “backstage” release notes. But I found the release notes for 8.8.0, which refer to previous welcome changes, implemented in Tinderbox 8.

I can’t find anything on further changes in Tinderbox 9. Maybe you meant Tinderbox 9.0 scripting language is a superset of that in early Tinderbox 8?

In any case the Tinderbox scripting language is not the issue in this thread. It works fine within a Drafts action.

@sumnerg You are a gift. :pray: This new script is awesome!!!

Yes, and I also had to change the tell statement from Tinderbox 8 to 9. It’s working now. Thanks.

1 Like

Ah, yes! Unlike other scriptable apps Tinderbox expects a new app name when the version changes.

To keep scripts from breaking when the version number changes one could use …

tell application id "Cere"

instead of …

tell application "Tinderbox 9"

Why “Cere”? Only our designer knows for sure. :grinning:

You can get the id for any application with something like this:

get file creator of (info for (path to application "Tinderbox 9"))

The code name for the Tinderbox project, prior to release of Tinderbox 1.0, was “Ceres”.

Interesting! Long history. AppleScript thinks its “Cere,” related to wax, not “Ceres,” related to grain and nourishment and a dwarf planet.