Skip to main content

Categorize and label incoming Gmail emails automatically with GPT-4o mini

Workflow preview

Workflow preview
100%
Categorize and label incoming Gmail emails automatically with GPT-4o mini preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Sort New Gmail messages by category with AI Who's it for This workflow is perfect for individuals or teams who receive a high volume of emails and want to automatically organize them into Gma...

Best for

  • Ticket Management automation workflows
  • AI Summarization automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.gmailtrigger, @n8n/n8n-nodes-langchain.lmchatopenai, @n8n/n8n-nodes-langchain.outputparserstructured, n8n-nodes-base.stickynote, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.filter, n8n-nodes-base.switch, n8n-nodes-base.gmail

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Arlin Perez.

Original n8n.io source

1.1 Workflow description

Title
Categorize and label incoming Gmail emails automatically with GPT-4o mini
Workflow name
Categorize and label incoming Gmail emails automatically with GPT-4o mini

Sort New Gmail messages by category with AI

πŸ‘₯ Who's it for

This workflow is perfect for individuals or teams who receive a high volume of emails πŸ“₯ and want to automatically organize them into Gmail labels 🏷️ using AI. No coding required!

For sorting existing emails messages in your gmail inbox, please use this free workflow: Categorize and Label Existing Gmail Emails Automatically with GPT-4o mini.

πŸ€– What it does

It automatically processes new Gmail emails, skips those that already have labels, sends the content to an AI Agent powered by GPT-4o mini 🧠, and applies a relevant label based on the content. All labels must exist in Gmail beforehand.

βš™οΈ How it works

  1. πŸ“¬ Gmail Trigger – Activates on new email received.
  2. 🚫 Filter – Skips emails that already have a label.
  3. 🧠 AI Agent (GPT-4o mini) – Analyzes the message and decides which label fits best.
  4. 🧾 Structured Output Parser – Formats the AI output into a clean JSON.
  5. πŸ”€ Switch Node – Routes each email to the correct label path based on the AI result.
  6. 🏷️ Gmail Nodes – Assign the Gmail label to the original email.

πŸ“‹ Requirements

  • Gmail account connected to n8n
  • Pre-created labels in Gmail matching the AI categories
  • OpenAI credentials with GPT-4o mini access
  • n8n's AI Agent & Structured Output Parser nodes

πŸ› οΈ How to set up

  1. Open the workflow and adjust the trigger interval (e.g., every minute, hours or Custom using Cron ⏱️)
  2. Check that the Filter skips emails with existing labels
  3. Define your categories in the AI Agent prompt and make sure they match the Gmail labels
  4. Configure the Switch Node conditions for each category
  5. Ensure each Gmail Label Node applies the correct label
  6. Save and activate the workflow βœ…

🎨 How to customize the workflow

  • Add or remove categories in the AI prompt & Switch Node
  • Fine-tune prompt instructions to match your specific use case

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Gmail Trigger

Type / Role
n8n-nodes-base.gmailTrigger - gmailTrigger
Config choices
Version 1.2

Block 2 - OpenAI Chat Model2

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 3 - Structured Output Parser1

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.2

Block 4 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Sticky Note11

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 6 - Sticky Note12

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - Sticky Note13

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 8 - Give a Label AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 1.8

Block 9 - Label Checker Filter

Type / Role
n8n-nodes-base.filter - filter
Config choices
Version 2.2

Block 10 - Switch

Type / Role
n8n-nodes-base.switch - switch
Config choices
Version 3.2

Block 11 - Work

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 12 - Personal

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 13 - Finance

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 14 - Shopping

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 15 - travel

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 16 - Newsletters

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

Block 17 - Others

Type / Role
n8n-nodes-base.gmail - gmail
Config choices
Version 2.1

3. Summary Table

Workflow Categorize and label incoming Gmail emails automatically with GPT-4o mini
Complexity advanced
Nodes 17
Categories Ticket Management, AI Summarization
Author Arlin Perez
Published 02 Jul 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/5595/5595.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Categorize and label incoming Gmail emails automatically with GPT-4o mini do?

Sort New Gmail messages by category with AI Who's it for This workflow is perfect for individuals or teams who receive a high volume of emails and want to automatically organize them into Gma...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Ticket Management, AI Summarization use case.