Action to open random draft

Do you know how to make an action to randomly open drafts from inbox space?

1 Like

So there’s galtenberg’s “Open Random Draft by Tag” in the Directory. I use a siri shortcut for this that’s currently configured specific to me. If you’re interested, though, I’d be glad to rework it to make it universal.

1 Like

Wow, that would be awesome. I’ve seen this action, but with tag input :frowning:

1 Like

It’s actually a lot simpler than my original hehe. Here’s what I came up with. I’m going to assume you’ve got less than 999 drafts in your library.

Random Draft Shortcut

1 Like

if you want to do it in a script action step inside drafts you can reduce the linked script to this:

// query all drafts with any tag (filter out the current open draft) 
const allDrafts = Draft.query("", "all",[]).filter(d => d.uuid != draft.uuid)
// get a random draft from the allDrafts array by creating a random number between 0 and the count of drafts in allDrafts
const randomDraft = allDrafts[Math.floor(Math.random() * allDrafts.length)]
// load the random draft into the editor
 editor.load(randomDraft)
2 Likes

This is just what I was looking for! Thank you so much.

1 Like

I guess this could be extended to kind of a random reflection action - depends on the setup but I can imagine that optional filtering for exclude / include tags would be helpful to e.g. prevent templates from showing up.

It would be relatively easy to limit the drafts that can show up to a workspace

1 Like

I’m actually using a version of the random draft by tag action that I hacked. It gives you a text prompt for an tag, but after that doesn’t prompt you for an hour or so. It’s sort of an unholy mix between random Draft and @mattgemmells Find next action,. There’s also an action to always bring up the prompt, of course if you need something else before the timeout.

I just wrote it, so I still haven’t decided if I need better filters e.g. exclude, include, multiple tags, workspaces etc.

My question. How to limit the draw to only a specific worspace? I wanted to exclude archived ones.

Keep in mind the archive is a folder available in all work spaces. Is it that you want to restrict to the inbox folder for a particular workspace?

Mainly inbox from any space in the archive exclusion.

Like @sylumer asked it does matter if you want to find a draft from any workspace or just from a configurable workspace.

If you want to use just one workspace I modified @galtenberg 's action to open a random draft from a workspace: Open Random Draft from Workspace | Drafts Directory
You can configure the workspace and the “search scope” (if the action e.g. shall look in the inbox only or all drafts).

If you really want to open any draft from the inbox you need to modify the second line of my shared snippet. the “all” parameter defines the filter where drafts shall look for the draft. if you change this to “inbox” only drafts in the inbox will be returned:

const allDrafts = Draft.query("", "inbox",[]).filter(d => d.uuid != draft.uuid)
1 Like

Thank you for this script!

I am using this to perform the resurfacing function of Readwise.io which allows me to avoid a new subscription.

1 Like

Not exactly what you’re looking for, but maybe you/others will find it of some use. I wrote an action called Make Work Fun that selects a random word from the current draft, then displays any other flagged drafts containing the same word. Useful for clearing out flagged drafts without getting bored. I included template tags that let you define the minimum word length and a list of words you want to exclude.