Process Drafts in INBOX Action

Hi,
I made an action which for me is one of the most useful ones in the last days.
I store pretty much everything text related in drafts.
To quickly sort it out i have a few actions (in different action groups) I normally run on them).
To speed this up I created an action which loops through the drafts in my INBOX workspace and asks me for each of them what to do. I can select actions from a prompt and they will be enqueued and run after processing all drafts in the INBOX.
You can customize it easily by simply adapting the name of your INBOX workspace and inserting the names of your actions you run on the most drafts. I use different „display names“ in the prompt, than the name of the action itself which is defined at the beginning of the action.
If you find it useful or have any questions just comment below.
Download the action from the Action Directory

5 Likes

Great action and great documentation.

I will definitely find that useful.

The idea of an Inbox workspace is really neat

thanks :slight_smile:

actually the “Inbox workspace” was a TIP in the forum here

I am getting an error in Line 29:

And this is the scrip, all I did is edit the actions labels and names, deleted 2 of them

// created by @FlohGro

// process drafts from INBOX
// ----------------------------------------------------
// START OF USER DEFINITIONS

// define the name of your inbox workspace
let inboxWorkspaceName = “INBOX”;

// declare “display names” (for the prompt) and “action names” (from your Actions) in an array:
// the last pair does not need a “,” after the brackets!s
let actionArray = [
[‘skip’, ‘’],
[‘:white_check_mark: iAwriter’, ‘INBOX line’s’],
[‘:link: Notes’, ‘Create note in Notes’],
[‘:card_index_dividers: DEVONthink’, ‘Send to DEVONthink’],
[‘:wastebasket: trash’, ‘trash’]
// [‘’, ‘’],
// [‘’, ‘’],
// [‘’, ‘’],
];

// END OF USER DEFINITIONS
// ----------------------------------------------------

let actionMap = new Map(actionArray);
// - get drafts from INBOX Workspace
let inboxWorkspace = Workspace.find(inboxWorkspaceName);
let inboxDrafts = inboxWorkspace.query(“all”);

// loop through every draft (show title and prompt for action on it)

for (inboxDraft of inboxDrafts) {
let actionPrompt = new Prompt();
actionPrompt.title = “process draft”
actionPrompt.message = "draft: " + inboxDraft.displayTitle;

// add button for all elements in the actionMap

actionMap.forEach(function(value, key) {
actionPrompt.addButton(key, value);
})
actionPrompt.isCancellable = false;
actionPrompt.show();

let selectedAction = actionPrompt.buttonPressed;

if (selectedAction == ‘’) {
// no action for the given name
} else {
let action = Action.find(selectedAction);
app.queueAction(action, inboxDraft);
}

}

Can you confirm that you have a workspace called “INBOX” as specified by the first jon-comment line?

Also, it helps to put your code between triple back ticks to avoid the forum converting some of the characters (e.g. smart quotes) and destroying the formatting.

```
//Put your code here
alert("hello world");
```

Then becomes

//Put your code here
alert("hello world");

Instead of

//Put your code here
alert(“hello world”);

1 Like

Your code in the thread is full of wrong characters for ‘ Could you repost it?

This is an awesome action. I have taken the liberty and made some modifications to work with my own situation:

  1. added a dialog to let the user choose a workspace before executing this action
  2. only process the actual “inbox” items in the chosen workspace, so if you ever need to run this action again in the same workspace, no drafts in the archive/trash will be processed.

I have shared it in the directory: process Drafts in workspace | Drafts Directory

and you can see the code at: GitHub - HybridRbt/process-drafts-in-inbox-modified: a customized version of the Drafts action by @FlohGro: https://actions.getdrafts.com/a/1ch

1 Like

Is there any way to add a ‘cancel’ option for this action? I ran into a situation where I was testing the action and realized I couldn’t bail without tapping ‘skip’ multiple times.

updated the action in the directory with a CANCEL button at the top:

1 Like

Thank you for the quick addition! I’m trying to see if this script or your “on my mind” is a better fit for how I work.

Sure glad to help!

I‘m mostly using the On My Mind now since I often have just quick thoughts which I add to the on my mind draft and then process them later. I don’t see the inbox count for the On My Mind draft which is better for me and I can use the inbox count more precisely:)

Just look what fits for you

1 Like