Auto-classify Gmail emails with AI and apply labels for inbox organization

Go to Workflow
1,732 views
Built by Alex Dunlop Alex Dunlop
Created on June 06, 2026

Description

Who is this for?
Professionals and individuals who receive high volumes of emails, those who want to automatically organize their Gmail inbox using AI classification.

What problem is this workflow solving?

Manual email sorting is time-consuming and inconsistent. This workflow automatically categorizes incoming emails into 8 predefined labels (To respond, FYI, Comment, Notification, Meeting update, Awaiting reply, Actioned, Marketing) to help maintain inbox zero and prioritize responses.

What this workflow does

Monitors Gmail for new incoming emails
Uses AI to analyze email content and classify into appropriate categories
Automatically applies the corresponding Gmail label
Runs on a schedule to process emails consistently

Setup

Prerequisites

n8n instance (cloud or self-hosted)
Gmail account with API access enabled
Access to an LLM provider (OpenAI, Anthropic Claude, or similar)

Step-by-Step

Configure Gmail Credentials
Create Gmail Labels
Configure LLM Chain
Set Email Polling Schedule
Test the Workflow

Create Gmail Labels
Before running the workflow, create these 8 labels in your Gmail account:

To respond
FYI
Comment
Notification
Meeting update
Awaiting reply
Actioned
Marketing

How to customize this workflow to your needs

Modify Classification Categories


To change the email categories, update two places:

In the AI prompt (Basic LLM Chain node):

Your new category - Description of what emails fit here
Another category - Description
[... continue with your categories]

In Gmail labels:
Create corresponding labels in your Gmail account with the exact same names and numbering.

Adjust Classification Rules

The AI prompt contains specific rules for each category. To modify:

Edit the "Key classification rules" section in the LLM prompt
Add examples of emails that should go into each category
Specify edge cases and how they should be handled

Change Email Sources

Currently monitors all incoming emails. To filter specific emails:

In the Gmail Trigger node, add filters such as:

from:[email protected]
subject:contains-keyword
-label:already-processed

You can also change this use Outlook

Modify Polling Frequency

More frequent**: Add multiple poll times (e.g., 9 AM, 12 PM, 6 PM)
Less frequent**: Change to once daily or weekly
Real-time**: Switch to webhook-based triggering (requires Gmail API setup)

I choose daily for cost.

Nodes Used (4)

Basic LLM Chain
@n8n/n8n-nodes-langchain.chainLlm
Code
n8n-nodes-base.code
Gmail
n8n-nodes-base.gmail
OpenRouter Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenRouter