Skip to main content

Automatic Gmail message categorization with GPT-4 content analysis & labels

Workflow preview

Workflow preview
100%
Automatic Gmail message categorization with GPT-4 content analysis & labels preview
Open on n8n.io

Important notice

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

1. Workflow Overview

Who is this for? This workflow is ideal for Gmail users and teams who receive a high volume of emails and want to streamline inbox management. It suits professionals seeking to organize messages au...

Best for

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

Tools used

n8n-nodes-base.stickynote, n8n-nodes-base.gmailtrigger, n8n-nodes-base.gmail, @n8n/n8n-nodes-langchain.chainllm, @n8n/n8n-nodes-langchain.outputparserstructured, n8n-nodes-base.set, n8n-nodes-base.splitout, n8n-nodes-base.merge

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Automatic Gmail message categorization with GPT-4 content analysis & labels
Workflow name
Automatic Gmail message categorization with GPT-4 content analysis & labels

Who is this for?

This workflow is ideal for Gmail users and teams who receive a high volume of emails and want to streamline inbox management. It suits professionals seeking to organize messages automatically, including sales teams, project managers, support staff, and anyone who benefits from automated email categorization.

What problem is this workflow solving? / Use case

Manually labeling emails is time-consuming and can lead to inconsistent organization. This automated n8n workflow uses Gmail and OpenAI to analyze incoming messages and apply the appropriate labels, such as "Quotation", "Inquiry", "Project progress", and "Notification", based on content—improving productivity and ensuring important messages are prioritized.

What this workflow does

The workflow retrieves new Gmail messages, analyzes their content with OpenAI, and automatically assigns pre-defined Gmail labels that match the email’s intent. This ensures emails are sorted efficiently using AI-powered content analysis and Gmail’s labeling system.

Setup

  • Ensure Gmail labels (e.g., "Quotation", "Inquiry") are created in your Gmail account.
  • Connect your Gmail and OpenAI accounts as credentials in n8n.
  • Import the workflow into your n8n instance and update node configurations to match your Gmail label names.

How to customize this workflow to your needs

  • Edit or add Gmail labels both in your Gmail account and within the workflow logic.
  • Adjust the prompt or parameters sent to OpenAI to better match your categorization style.
  • Expand or refine the list of label categories to fit your team’s or business’s requirements.

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 Note6

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

Block 2 - Gmail trigger

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

Block 3 - Get message content

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

Block 4 - Assign labels for message

Type / Role
@n8n/n8n-nodes-langchain.chainLlm - chainLlm
Config choices
Version 1.5

Block 5 - JSON Parser

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

Block 6 - Set label values

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 7 - Get all labels

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

Block 8 - Split out assigned labels

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

Block 9 - Merge corresponding labels

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.1

Block 10 - Aggregate label IDs

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

Block 11 - Add labels to message

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

Block 12 - Sticky Note3

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

Block 13 - Sticky Note13

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

Block 14 - Sticky Note14

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

Block 15 - Sticky Note15

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

Block 16 - Sticky Note16

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

Block 17 - Sticky Note17

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

Block 18 - OpenAI GPT-4 Based

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

3. Summary Table

Workflow Automatic Gmail message categorization with GPT-4 content analysis & labels
Complexity advanced
Nodes 18
Categories Ticket Management, AI Summarization
Author Henry
Published 05 Jun 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/4680/4680.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 Automatic Gmail message categorization with GPT-4 content analysis & labels do?

Who is this for? This workflow is ideal for Gmail users and teams who receive a high volume of emails and want to streamline inbox management. It suits professionals seeking to organize messages au...

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.