Feature Request: IMAP Enhanced Trigger Node with Custom Flag/Keyword Support

It would help if there was a node for:

An enhanced Email Trigger (IMAP) node that supports filtering by IMAP keywords (custom flags) — not just UNSEEN.

Currently the Email Trigger node (emailReadImap) can only filter by read/unread status. There is no UI option to filter by custom IMAP keywords like $Label1, $Processed, or n8n_done. This makes it impossible to build robust deduplication into email processing workflows without relying solely on read status or folder moves.

Proposed additions:

  • Has Keyword filter: Only trigger on emails that have a specific IMAP keyword

  • Does Not Have Keyword filter: Only trigger on emails that do NOT have a keyword (maps to IMAP UNKEYWORD)

  • Standard flag filters in the UI: Seen, Flagged, Answered, Deleted, Draft (currently only available via hidden customEmailConfig JSON)

My use case:

I run an automated email classification workflow on a Zimbra mail server:

Email Trigger (INBOX/n8n) → AI Classification → Set Custom Flag → Move to Folder

After processing, I set a custom IMAP keyword (e.g. n8n_done) on each email to mark it as handled. I need the trigger to skip emails that already have this keyword so they don’t get re-processed.

Currently there’s a workaround via “Custom Email Config” option:

[["UNSEEN"], ["!KEYWORD", "n8n_done"]]

But this requires knowledge of raw IMAP search syntax and the node-imap library’s array format — it’s not discoverable through the UI and most users wouldn’t know it exists.

A proper UI for keyword filtering would make email automation workflows significantly more reliable and accessible.

Any resources to support this?

  • RFC 3501 Section 2.3.2 — IMAP keywords are defined as user-settable flags (atoms without \ prefix)

  • RFC 3501 Section 6.4.4 — SEARCH command supports KEYWORD and UNKEYWORD criteria

  • n8n-nodes-imap community node (50k+ installs) — has partial custom flag support in its action node (v2.15.0, PR #104) but no trigger node

  • IMAP keywords are supported by all major mail servers: Dovecot, Cyrus, Gmail, Exchange, Zimbra (with limitations)

Are you willing to work on this?

I’m not a TypeScript developer myself, but I can provide detailed testing with Zimbra IMAP servers and help validate any implementation. I’ve already analyzed the current EmailReadImapV2.node.ts source and the underlying node-imap library — the SEARCH criteria support is already there, it just needs UI exposure.

Some more background — explained simply

(Kept simple on purpose, so technically only ~95% accurate)

What are mail tags?

Most email servers allow you to categorize emails in some way:

Different names, same concept: metadata you can attach to an email to classify it.

Back to email workflows

In n8n, the IMAP Trigger is the standard way to automatically kick off a workflow whenever a new email arrives in a mailbox — it monitors the server for unread messages in real time.

Currently, the main criteria you can filter on are:

  • New emails

  • Unread emails

The consequence: in most cases, all emails in the inbox end up being processed by the workflow — whether they’re relevant or not.

What this feature request enables

With custom flag/keyword support directly in the IMAP trigger, you gain precise control over which emails enter your workflow and which ones get skipped.

Examples:

  • :white_check_mark: After an email has been checked and should stay in the inbox, set the tag n8n_done. On the next trigger run, all emails tagged n8n_done are simply ignored.

  • :counterclockwise_arrows_button: When a workflow starts processing an email, set the tag n8n_inprogress — so that any concurrent or subsequent execution of this (or another) workflow skips emails with that tag. Remove the tag once the workflow finishes.

I could go on with examples endlessly.

Why this matters

  • Emails can be processed much more selectively — irrelevant emails never even enter the workflow

  • Enables significantly more complex workflows with proper state management directly at the trigger level

  • Prevents duplicate processing across multiple workflows watching the same mailbox

That would be a really great feature that could also be very useful. I would also be very happy to see it implemented.

Best regards, Markus

1 Like

I’ve seen that there are many other IMAP feature requests, so I’ve summarized them for you here!

Delete IMAP Mails in Mailboxes

extend IMAP Trigger with inject/move capabilities

Delete IMAP Mails in Mailboxes

Multiple Mailbox Support

IMAP Node after Trigger like n8n-nodes-imap

Suggestion to support IMAP email reading in workflows

add scheduling options to IMAP Trigger

built‐in Error Trigger for IMAP-Email

IMAP Node after Trigger like n8n-nodes-imap - to set “mark mail as read” on the end of workflow

Mail move like like n8n-nodes-imap

Add the headers “In-Reply-To” and “References”

This would be really useful for some workflows I’m building. For example processing customer feedback with AI and marking emails as processed so they don’t get handled again.

1 Like

Out of curiousity, would you be open to move away from IMAP to achieve this? There’s already inbound email processing nodes out there for n8n, which give you much of the requirements mentioned here. E.g. processable content (JSON), filtering, full headers. It would require pointing a sub domain’s MX to that service and potentially setting up aliases on the TLD to point to those. Or at least, that’s how I’ve set up my support@ mailbox.