This workflow corresponds to n8n.io template #7599 — we link there as the canonical source.
This workflow follows the Gmail → Gmail Trigger 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 →
{
"id": "GW8BgSXuDRHwmSI6",
"meta": {
"templateCredsSetupCompleted": true
},
"name": "Simple emails classifier",
"tags": [],
"nodes": [
{
"id": "a06f8baa-e67e-49ed-b471-74fc05fc6b38",
"name": "Gmail Trigger",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
-560,
192
],
"parameters": {
"filters": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 1.3
},
{
"id": "fc3e3e26-d404-412c-8d2d-03988214773c",
"name": "Text Classifier",
"type": "@n8n/n8n-nodes-langchain.textClassifier",
"position": [
-352,
160
],
"parameters": {
"options": {},
"inputText": "=subject: {{ $json.Subject }}\nMessage: {{ $json.snippet }}",
"categories": {
"categories": [
{
"category": "Business",
"description": "Anything from friends or co-workers related to work"
},
{
"category": "Sales",
"description": "Anything sounds like a cold email or someone trying to sell you something soft or hard way"
},
{
"category": "Meetings",
"description": "anything mentioning a meeting or a schedule or maybe a reminder"
},
{
"category": "Random",
"description": "Anything that doesn't fall into our 3 categories"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "8eb5fcae-9d32-445f-88a1-4203585be43a",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-352,
384
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "1a4ea43d-2cc5-4931-bd5f-8adeebe20334",
"name": "No Operation, do nothing",
"type": "n8n-nodes-base.noOp",
"position": [
0,
368
],
"parameters": {},
"typeVersion": 1
},
{
"id": "190c147b-d1e0-4aa0-ad3f-eadc012ff546",
"name": "Business",
"type": "n8n-nodes-base.gmail",
"position": [
0,
0
],
"parameters": {
"labelIds": [
"IMPORTANT"
],
"resource": "thread",
"threadId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "780c4ca1-a6c6-404b-8643-498a4badb9bf",
"name": "Cold Emails",
"type": "n8n-nodes-base.gmail",
"position": [
192,
96
],
"parameters": {
"resource": "thread",
"threadId": "={{ $json.id }}",
"operation": "delete"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "6ca3d75f-410b-49a1-a685-7bbbad760074",
"name": "Meetings",
"type": "n8n-nodes-base.gmail",
"position": [
192,
256
],
"parameters": {
"labelIds": [
"YELLOW_STAR"
],
"resource": "thread",
"threadId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "4befbb3e-c00c-443d-b216-90f61cf5ac64",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-928,
128
],
"parameters": {
"color": 6,
"width": 272,
"height": 240,
"content": "## Guide\n\nSetup your openai credentials: https://platform.openai.com/settings/organization/api-keys\n\nSetup your gmail credentials\nand you are ready to go: https://console.cloud.google.com/"
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "72a6698f-fc14-4c0a-8838-3f08023a5220",
"connections": {
"Gmail Trigger": {
"main": [
[
{
"node": "Text Classifier",
"type": "main",
"index": 0
}
]
]
},
"Text Classifier": {
"main": [
[
{
"node": "Business",
"type": "main",
"index": 0
}
],
[
{
"node": "Cold Emails",
"type": "main",
"index": 0
}
],
[
{
"node": "Meetings",
"type": "main",
"index": 0
}
],
[
{
"node": "No Operation, do nothing",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Text Classifier",
"type": "ai_languageModel",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
gmailOAuth2openAiApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Intelligent AI-powered email classification system that automatically sorts incoming Gmail messages into Business, Meetings, Cold Emails, and other categories using OpenAI. Import this workflow into your n8n instance Setup your OpenAI credentials at: OpenAI api key Configure…
Source: https://n8n.io/workflows/7599/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
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.
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
Detects new unread Gmail messages Extracts sender name for personalized replies Classifies the email into one of four categories Applies the correct Gmail label and either sends an auto-reply, creates
Email Automation AI-Powered Operations Internal Productivity Tools
This workflow is designed for busy professionals, productivity enthusiasts, and teams drowning in email overload. Whether you're a startup founder, operations manager, executive assistant, or team lea