Skip to main content

Automate Gmail email categorization with GPT-4o AI and reasoning

Workflow preview

Workflow preview
100%
Automate Gmail email categorization with GPT-4o AI and reasoning preview
Open on n8n.io

Important notice

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

1. Workflow Overview

An AI inbox labelling manager that has reasoning attached to the ChatGPT inbox manager within n8n. Super simple yet highly effective automation. How it works: • Monitors Gmail inbox → triggers work...

Best for

  • Support Chatbot automation workflows
  • AI Summarization automation workflows
  • intermediate n8n builders looking for reusable templates

Tools used

n8n-nodes-base.gmail, n8n-nodes-base.gmailtrigger, @n8n/n8n-nodes-langchain.toolthink, @n8n/n8n-nodes-langchain.openai, n8n-nodes-base.stickynote

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Automate Gmail email categorization with GPT-4o AI and reasoning
Workflow name
Automate Gmail email categorization with GPT-4o AI and reasoning

An AI inbox labelling manager that has reasoning attached to the ChatGPT inbox manager within n8n. Super simple yet highly effective automation.

How it works:

• Monitors Gmail inbox → triggers workflow when a new unread email is received.

• Fetches email details including subject, body, and sender information.

• Sends email content to OpenAI → uses AI to determine the most relevant label based on predefined rules.

• AI uses a think tool → justifies why it selected that specific label.

• Retrieves Gmail label IDs → matches AI’s choice to correct Gmail label for that email.

• Adds the chosen label (e.g., Positive reply, priority email, etc) to the email automatically → optionally marks it as read/starred.

• Continues monitoring → every new email is processed automatically, keeping the inbox organized.

Set Up Steps

• Connect Gmail account to the Gmail Node

• Create OpenAI account & API key → go to OpenAI and sign up or log in. Once logged in, click Dashboard in the top menu. On the left sidebar, find API Keys and click Create new key. Copy this key — you’ll need it for n8n.

Check your account balance → in the top-right, click your profile icon → Your Profile → Billing. Make sure your account has funds (e.g., $5 USD is enough for testing) so the API requests can run.

Do these steps through this link: https://platform.openai.com/

• Retrieve Gmail label IDs → use the Gmail “get labels” node to fetch IDs for all labels you want the AI to use.

• Use OpenAI (ChatGPT) node → set up system and user prompts with rules describing each label, and include the label IDs (Important).

• Test the workflow → send example emails, check labeling, and refine AI prompt or label rules if needed.

• Tip: Pin trigger data for testing (Gmail node "Watch Incoming Emails") → re-use the same email record to speed up testing without sending multiple emails.

About this automation

Handles multiple labels → adding new labels only requires updating the AI prompt (no extra nodes).

Scales easily → works for any number of Gmail labels without cluttering the workflow.

For a complete rundown on how to set this up watch my YouTube tutorial linked below

See full video tutorial here:

https://www.youtube.com/watch?v=7nda4drHcWw

My LinkedIn: https://www.linkedin.com/in/seb-gardner-5b439a260/

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 - Get Label Id's

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

Block 2 - Watch Incoming Emails

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

Block 3 - Mark Email As Read

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

Block 4 - Justify/Reason the Label AI has chosen

Type / Role
@n8n/n8n-nodes-langchain.toolThink - toolThink
Config choices
Version 1

Block 5 - Select most appropriate Label

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

Block 6 - Add Label

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

Block 7 - Sticky Note

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

Block 8 - Sticky Note1

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

Block 9 - Sticky Note2

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

Block 10 - Sticky Note3

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

Block 11 - Sticky Note4

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

Block 12 - Sticky Note5

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

Block 13 - Sticky Note7

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

3. Summary Table

Workflow Automate Gmail email categorization with GPT-4o AI and reasoning
Complexity intermediate
Nodes 13
Categories Support Chatbot, AI Summarization
Author Seb
Published 13 Oct 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/9583/9583.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 Automate Gmail email categorization with GPT-4o AI and reasoning do?

An AI inbox labelling manager that has reasoning attached to the ChatGPT inbox manager within n8n. Super simple yet highly effective automation. How it works: • Monitors Gmail inbox → triggers work...

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 Support Chatbot, AI Summarization use case.