New Note using Drafts Fails

Thanks for this. I didn’t know about “Hook To New” until now - and I’m an avid Drafts user. So I think I’m going to try it.

I tag every permanent draft - and that drives the draft into a workspace - so I’ll be keen to see what tagging support (if any) there is.

(I keep the Drafts main window open all the time.)

That’s a good lead. Thanks for posting @martinewski. Hoping this integration can be resolved, though, as it’s frustrating to break flow to ensure the Drafts window is open before invoking Hook.

I really like the idea of all my Hook notes being tagged so that I can see them in a Drafts workspace, @MartinPacker. That’s a great idea. Do you tag them manually? And if so, might there be a way to modify the Hook script, @LucB, so that that Draft notes could be tagged as part of the integration?

2 Likes

My “daily writing” is automatically tagged - as I use a Drafts action that ropes in calendar and Omnifocus stuff, via Shortcuts. (I’d like to slacken that to avoid round trips to Shortcuts but never mind.) This action does the tagging.

My blog entries I’m writing I manually tag with “blog” when I start them.

My other drafts get manually tagged as well.

My scenario here (for Hook) is to create a bunch of files in folders and also create hookable Drafts. The folders - via my mdpre and md2pptx tools (sorry to advertise) :slight_smile: contain Markdown etc to make into client workshop presentations. The drafts would be my analysis notes - that would contribute to the Markdown I build my presentations from.

Right now I don’t think I can create these Hookable drafts.

If anyone is interested in a temporary solution, I added the highlighted text to the script so it opens Drafts main window before trying the rest of the script. It’ll work as long as Drafts is running in background.

Screen Shot 2020-12-18 at 4.05.29 PM

1 Like

we provided an alternative script for OmniFocus a while ago to add a tag to hooked OmniFocus tasks , which illustrates the concept: Configurable Tags.

So if the Drafts AppleScript dictionary allows it, it would be trivial to add.

Personally, I think this should be the default for all apps that support tagging, but I know not everyone agrees.

I’ll ask someone here to have a look. meanwhile we have some volunteer liaisons for Obsidian, and hope to have one for each major app, like Drafts, who would check for things like this, and interact with the other dev’s community if needed.

1 Like

Unfortunately, that doesn’t work for me, @martinewski. I still get “Error linking new document, No address returned” errors with macOS 11.1 and Drafts 24.2.10.

All is fine, however, if the Drafts window is actually open somewhere on my computer. The trouble, of course, is that it’s natural and almost automatic for me to take a note and then dismiss the Drafts window.

FYI: we’ve found some API of theirs we think we can use to make Hook to New work with Drafts. I’ll try to update this topic by end of evening. Meanwhile, it’s not worth customers fiddling with this.

1 Like

You know, it seems to me that if we can hook up to Omni apps and Obsidian via a JavaScript style of interface, that we should have access to Drafts’ full suite of JavaScripting powers…so maybe this is already doable, possibly without AppleScript? Alternately, at one point, I did successfully hook up Hook with Drafts’ AppleScript to create a new draft, but I could never figure out how to grab its URL for linkage.

1 Like

we’re having another look at their x-callback-url

Ah yes, perhaps this new feature in 24.2 will help? CleanShot 2020-12-18 at 12.23.54@2x

1 Like

And now Greg’s just released 25.0 it’s even more reasonable for you to expect customers to be at at least 24.2.

2 Likes

the new scripts we will publish fixes this.

Exciting! Thank you for the update, @LucB.

After having Hook for some time, I’m really enjoying delving into it in depth. Sorry to be such a “squeaky wheel.” Very much appreciate your support.

1 Like

We super appreciate your input! It’s very helpful to have advocates for each app. that helps us keep abreast of what’s happening with apps.

We are developing a software framework (and web content) to streamline intra-app and inter-app linking. That’s what Hook is all about.

1 Like

Hook integration scripts v.142 now available — Updated Apple Notes, Drafts and Bookends integration - Releases - Hook Productivity Forum.

This should solve the Hook to New > Drafts issue because it uses Draft’s automation. As noted in the release notes, we still need to update Hook’s get address (if possible) to use Draft’s API rather than UI scripting.

The great part is that it’s now much easier to customize the resulting new draft. I quickly edited the script to add a Markdown header and some new lines.

1 Like

Incidentally, we’d like to enhance the Hook to New > Drafts to add a linkback in the new doc itself to the source, like we do for Apple Notes per Hook integration scripts v.142 now available — Updated Apple Notes, Drafts and Bookends integration - Releases - Hook Productivity Forum.

There’s Linking Drafts - Drafts User Guide. We’re looking into whether it’s possible to add those links through automation. Anyone here use Drafts automation?

and the answer comes from one of our own here, it can be done such as:

tell application "Drafts"
        activate

        set obj to make new draft with properties
{content:"[[url:bookends://sonnysoftware.com/8253]]", tags:{"hook"}}
        set rec to obj as record
        return "drafts5://open?uuid=" & «class seld» of rec

end tell

In case anyone wants to try it, here’s a new version of Hook to New > Drafts

tell application "Drafts"
        activate

        set obj to make new draft with properties {content:"[$title]($link)", tags:{"hook"}}
        set rec to obj as record
        return "drafts5://open?uuid=" & «class seld» of rec

end tell

Instead of the new note having a vanilla title , it is a link back to the source. That means on iPad and iPhone you can use the links to get back to the source.

2 Likes