AutomationFlowsAI & RAG › Auto-label Gmail Messages with Custom Categories Using Gpt-4o-mini

Auto-label Gmail Messages with Custom Categories Using Gpt-4o-mini

ByAshish Kumar Swain @phoenix on n8n.io

Why settle for Gmail’s default tabs when AI can sort your inbox your way?

Cron / scheduled trigger★★★☆☆ complexityAI-powered8 nodesOpenAI ChatGmailText Classifier
AI & RAG Trigger: Cron / scheduled Nodes: 8 Complexity: ★★★☆☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #7477 — we link there as the canonical source.

This workflow follows the Gmail → OpenAI Chat recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "MkRETKpIFPWYCRiM",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Smart Gmail Classifier: Classify & Label with openAI",
  "tags": [],
  "nodes": [
    {
      "id": "9038f706-1cf8-4156-9858-969a7bde62e3",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -848,
        576
      ],
      "parameters": {},
      "typeVersion": 1.2
    },
    {
      "id": "0ee542ce-85bc-405a-ba04-7a257e8d6f4f",
      "name": "Job Opportunity",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -544,
        0
      ],
      "parameters": {},
      "typeVersion": 2.1
    },
    {
      "id": "ee69125c-46ae-439d-b0b7-c016af1b5df6",
      "name": "Application Status",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -544,
        192
      ],
      "parameters": {},
      "typeVersion": 2.1
    },
    {
      "id": "37f396b6-7327-43db-b4e5-e34756b82a34",
      "name": "Others",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -544,
        384
      ],
      "parameters": {},
      "typeVersion": 2.1
    },
    {
      "id": "d937e43b-7f05-4eda-bf9e-409a325f6999",
      "name": "Enquiries",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -544,
        576
      ],
      "parameters": {},
      "typeVersion": 2.1
    },
    {
      "id": "eb4f2bf6-4535-4b96-a215-5c99f3f0bb04",
      "name": "Email Classifier",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        -944,
        288
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "1e886235-18c7-4f6e-a744-7a177807e00a",
      "name": "Daily Email Check",
      "type": "n8n-nodes-base.cron",
      "position": [
        -1392,
        288
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "07c859f1-82ff-4268-bd99-087608931420",
      "name": "Fetch New Emails",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -1168,
        288
      ],
      "parameters": {},
      "typeVersion": 2
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "7aa60bda-b007-4b69-b22a-aac8d578e193",
  "connections": {
    "Email Classifier": {
      "main": [
        [
          {
            "node": "Job Opportunity",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Application Status",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Others",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Enquiries",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch New Emails": {
      "main": [
        [
          {
            "node": "Email Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Email Check": {
      "main": [
        [
          {
            "node": "Fetch New Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Email Classifier",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Why settle for Gmail’s default tabs when AI can sort your inbox your way?

Source: https://n8n.io/workflows/7477/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

gmail label and notify. Uses lmChatOpenAi, textClassifier, gmail, openAi. Scheduled trigger; 16 nodes.

OpenAI Chat, Text Classifier, Gmail +2
AI & RAG

This workflow automatically organizes your Gmail inbox by fetching recent emails, analyzing their content with AI, and applying the appropriate Gmail labels based on the results.

OpenAI Chat, Gmail, Text Classifier
AI & RAG

🧾 Description:

OpenAI Chat, Gmail, Text Classifier
AI & RAG

This template can be used to automatically label your incoming Gmail messages with AI and to build a knowledge graph from the emails tagged with a specific label to brainstorm new ideas based on them.

Gmail Trigger, OpenAI Chat, Gmail +4
AI & RAG

This n8n template uses AI to automatically classify incoming Gmail messages into five categories and route them to the right people or departments. It can also reply automatically and send WhatsApp al

Gmail Trigger, OpenAI Chat, Gmail +3