Gmail Inbox Organization with Smart Rule-based Categorization - n8n Workflow

Automate your Gmail inbox organization using this powerful n8n workflow. Categorize incoming emails (Work, Shopping, Newsletter), apply labels, and set priority automatically using a specialized n8n node setup.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Professionals who spend too much time manually sorting incoming messages.
Users looking for advanced, custom email filtering beyond standard Gmail rules.
Anyone needing an automated system to prioritize critical work communications instantly.
Automation enthusiasts seeking high-utility n8n templates for email management.

Overview

Managing a high-volume inbox can be a major drain on productivity. This specialized n8n workflow eliminates the need for manual sorting by providing an intelligent, rule-based categorization system that runs in real-time. By utilizing the flexibility of an n8n node (the Switch node) to analyze email subject lines and sender addresses, the system can instantly classify emails into categories like 'Work,' 'Shopping,' and 'Newsletter.' Not only does the workflow apply the correct label using a dedicated Gmail n8n node, but it also takes context-specific actions—marking critical work communication as important and automatically archiving low-priority newsletters. This seamless automation ensures your inbox stays clean, organized, and focused on what matters most. Setting up this n8n workflow is the ultimate step toward inbox zero.

How it Works

This comprehensive n8n workflow is initiated by a specialized n8n trigger and executes three main phases:


  1. Initiation (New Email Received): The workflow starts with the Gmail Trigger n8n node, which polls your configured Gmail inbox every minute for new emails, providing immediate processing.

  2. Categorization (Switch Logic): The data is passed to the Categorize Email by Content Switch n8n node. This core logic component inspects the email's sender ($json.from) and subject ($json.subject). It has three defined outputs based on keyword matches:

Work Emails: Matches company domains (@company.com) or keywords like 'meeting' or 'project'.
Shopping Orders: Matches known e-commerce senders or keywords like 'order' or 'receipt'.
Newsletters: Matches generic senders (noreply) or keywords like 'unsubscribe' or 'newsletter'.

  1. Automated Actions (Gmail Nodes): Based on the category determined by the Switch n8n node, the workflow executes specific actions:

If Work Email: It first uses the Apply Work Label Gmail n8n node to tag the message, and then continues to the Mark Work Email as Important n8n node to ensure high visibility.
If Shopping Order: It uses the Apply Shopping Label Gmail n8n node to quickly tag the order confirmation.
If Newsletter: It uses the Apply Newsletter Label Gmail n8n node, followed immediately by the Archive Newsletter Email n8n node, which keeps these less crucial communications out of your primary view.

Installation Guide

To deploy this powerful n8n workflow and start organizing your Gmail automatically, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON data and paste it into your n8n instance using the 'Import Workflow' function.

  2. Set Up Credentials: Locate the 'New Email Received' (Gmail Trigger) and all subsequent Gmail n8n nodes. You must connect your Gmail account via OAuth2 authentication. This step allows the n8n template to interact with your inbox.

  3. Create Gmail Labels: Ensure you have the following labels created in your Gmail account: Work, Shopping, and Newsletter. The workflow relies on these exact names to function correctly.

  4. Customize Keywords (Optional): Review the conditions within the Categorize Email by Content Switch n8n node. Adjust sender addresses (e.g., your specific company domain) or subject keywords to better match your specific email traffic.

  5. Activate the n8n Trigger: Save the n8n workflow and toggle the 'Active' switch to enable the Gmail trigger. The workflow will now start checking for new emails every minute.

Node Details

This n8n workflow utilizes several key nodes to achieve its intelligent automation:

New Email Received (Gmail Trigger n8n node):
Function: Serves as the starting n8n trigger, initiating the automation upon detection of a new email in Gmail.
Key Configuration: Configured to poll the inbox every minute (everyMinute).
Categorize Email by Content (Switch n8n node):
Function: The central logic engine. It analyzes email headers (From) and content (Subject) using complex 'OR' conditions to route the item to the correct processing path.
Key Configuration: Defines three outputs: 'Work Emails', 'Shopping Orders', and 'Newsletters', each with specific string containment checks.
Apply Work Label (Gmail n8n node):
Function: Adds the specified label ('Work') to the message ID provided by the n8n trigger.
Key Configuration: Operation set to addLabels; Label ID set to Work; Message ID sourced dynamically via expression ={{ $json.id }}.
Mark Work Email as Important (Gmail n8n node):
Function: Executes a secondary, high-priority action on classified work emails.
Key Configuration: Operation set to markAsImportant.
Archive Newsletter Email (Gmail n8n node):
Function: Moves categorized newsletters out of the primary inbox view.
* Key Configuration: Operation set to addLabels; Label ID set to ARCHIVE (the system label for archiving).

Together, these n8n nodes form a cohesive and effective email management solution.

Related n8n Workflows

Free

Nodes: 4 Nodes
Updated: December 26 2025
View all
Created by

Featured*