Skip to main content

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

Workflow preview

Workflow preview
100%
Categorize and label existing 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

Categorize and Label Existing Gmail Emails Automatically with GPT 4o mini Who's it for This workflow is perfect for individuals or teams who want to sort and label existing emails in their Gm...

Best for

  • Personal Productivity automation workflows
  • AI Summarization automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

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

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 existing Gmail emails automatically with GPT-4o mini
Workflow name
Categorize and label existing Gmail emails automatically with GPT-4o mini

πŸ“¨ Categorize and Label Existing Gmail Emails Automatically with GPT-4o mini

πŸ‘₯ Who's it for

This workflow is perfect for individuals or teams who want to sort and label existing emails in their Gmail inbox πŸ—ƒοΈ using AI. Ideal for cleaning up unlabeled emails in bulk β€” no coding required!

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

πŸ€– What it does

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

βš™οΈ How it works

▢️ Manual Trigger – The workflow starts manually when you click "Execute Workflow".

πŸ“₯ Gmail Get Many Messages – Pulls a batch of existing inbox emails (default: 50).

🚫 Filter – Skips emails that already have one or more labels.

🧠 AI Agent (GPT-4o mini) – Analyzes the content and assigns a category.

🧾 Structured Output Parser – Converts the AI output into structured JSON.

πŸ”€ Switch Node – Routes each email to the right label based on the AI result.

🏷️ Gmail Nodes – Apply the correct Gmail label to the email.

πŸ“‹ Requirements

Gmail account connected to n8n

Gmail labels must be manually created in your inbox beforehand

Labels must exactly match the category names defined in the AI prompt

OpenAI credentials with GPT-4o mini access

n8n's AI Agent & Structured Output Parser nodes

πŸ› οΈ How to set up

In your Gmail account, create all the labels you want to use for categorizing emails

Open the workflow and adjust the email fetch limit in the Gmail node (e.g., 50, 100)

Confirm that the Filter skips emails that already have labels

Define your categories in the AI Agent prompt β€” these must match the Gmail labels exactly

In the Switch Node, create a condition for each label/category

Ensure each Gmail Label Node applies the correct existing label

Save the workflow and run it manually whenever you want to organize your inbox βœ…

🎨 How to customize the workflow

Add or remove categories in the AI prompt & Switch Node

Adjust the batch size of emails to process more or fewer per run

Fine-tune the AI prompt to suit your inbox type (e.g., work, personal, client support)

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 - Sticky Note3

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

Block 2 - Sticky Note11

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

Block 3 - Sticky Note12

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

Block 4 - Sticky Note13

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

Block 5 - Give a Label AI Agent

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

Block 6 - Label Checker Filter

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

Block 7 - Switch

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

Block 8 - Work

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

Block 9 - Personal

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

Block 10 - Finance

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

Block 11 - Shopping

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

Block 12 - travel

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

Block 13 - Newsletters

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

Block 14 - Others

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

Block 15 - When clicking β€˜Execute workflow’

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

Block 16 - Get many messages

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

Block 17 - Structured Output Parser

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

Block 18 - OpenAI Chat Model

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

3. Summary Table

Workflow Categorize and label existing Gmail emails automatically with GPT-4o mini
Complexity advanced
Nodes 18
Categories Personal Productivity, AI Summarization
Author Arlin Perez
Published 15 Jul 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/6031/6031.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 existing Gmail emails automatically with GPT-4o mini do?

Categorize and Label Existing Gmail Emails Automatically with GPT 4o mini Who's it for This workflow is perfect for individuals or teams who want to sort and label existing emails in their Gm...

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 Personal Productivity, AI Summarization use case.