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 →
{
"name": "AI Email Categorizer",
"nodes": [
{
"parameters": {
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
},
"filters": {
"readStatus": "unread"
},
"options": {}
},
"id": "b1b2c3d4-2001-4000-8000-000000000001",
"name": "Gmail Trigger",
"type": "n8n-nodes-base.gmailTrigger",
"typeVersion": 1.1,
"position": [
250,
300
]
},
{
"parameters": {
"resource": "chat",
"model": "gpt-4",
"messages": {
"values": [
{
"content": "Categorize the following email into exactly one of these categories: URGENT, SALES, SUPPORT, BILLING, NEWSLETTER, SPAM, PERSONAL, OTHER.\n\nAlso provide a priority level: HIGH, MEDIUM, LOW.\n\nFrom: {{ $json.from }}\nSubject: {{ $json.subject }}\nBody: {{ $json.snippet }}\n\nReturn JSON with keys: category, priority, reason (brief explanation)"
}
]
},
"options": {
"temperature": 0.3,
"maxTokens": 300
}
},
"id": "b1b2c3d4-2001-4000-8000-000000000002",
"name": "OpenAI Categorize",
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.3,
"position": [
500,
300
]
},
{
"parameters": {
"jsCode": "const response = JSON.parse($input.first().json.message.content);\nconst emailData = $('Gmail Trigger').first().json;\nreturn [{\n json: {\n messageId: emailData.id,\n from: emailData.from,\n subject: emailData.subject,\n category: response.category,\n priority: response.priority,\n reason: response.reason\n }\n}];"
},
"id": "b1b2c3d4-2001-4000-8000-000000000003",
"name": "Parse Category",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
750,
300
]
},
{
"parameters": {
"resource": "message",
"operation": "addLabels",
"messageId": "={{ $json.messageId }}",
"labelIds": [
"={{ $json.category }}"
]
},
"id": "b1b2c3d4-2001-4000-8000-000000000004",
"name": "Apply Gmail Label",
"type": "n8n-nodes-base.gmail",
"typeVersion": 2.1,
"position": [
1000,
300
]
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.priority }}",
"value2": "HIGH"
}
]
}
},
"id": "b1b2c3d4-2001-4000-8000-000000000005",
"name": "Is High Priority?",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
1250,
300
]
},
{
"parameters": {
"channel": "#urgent-emails",
"text": ":rotating_light: *High Priority Email*\n*From:* {{ $('Parse Category').first().json.from }}\n*Subject:* {{ $('Parse Category').first().json.subject }}\n*Category:* {{ $('Parse Category').first().json.category }}\n*Reason:* {{ $('Parse Category').first().json.reason }}",
"otherOptions": {}
},
"id": "b1b2c3d4-2001-4000-8000-000000000006",
"name": "Slack Alert",
"type": "n8n-nodes-base.slack",
"typeVersion": 2.1,
"position": [
1500,
200
]
}
],
"connections": {
"Gmail Trigger": {
"main": [
[
{
"node": "OpenAI Categorize",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Categorize": {
"main": [
[
{
"node": "Parse Category",
"type": "main",
"index": 0
}
]
]
},
"Parse Category": {
"main": [
[
{
"node": "Apply Gmail Label",
"type": "main",
"index": 0
}
]
]
},
"Apply Gmail Label": {
"main": [
[
{
"node": "Is High Priority?",
"type": "main",
"index": 0
}
]
]
},
"Is High Priority?": {
"main": [
[
{
"node": "Slack Alert",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
}
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
AI Email Categorizer. Uses gmailTrigger, openAi, gmail, slack. Event-driven trigger; 6 nodes.
Source: https://github.com/mlnjsh/n8n-workflows-mega/blob/main/workflows/ai-email/01-email-categorizer.json — 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.
n8n Recruitment. Uses gmailTrigger, openAi, googleSheets, gmail. Event-driven trigger; 20 nodes.
AI Smart Reply Generator. Uses gmailTrigger, openAi, gmail, slack. Event-driven trigger; 6 nodes.
This n8n template automatically processes inbound form leads, researches their company via their website, and uses AI to write and send a highly personalized "speed to lead" email instantly. It also t
Send A Chatgpt Email Reply And Save Responses To Google Sheets. Uses openAi, gmailTrigger, stickyNote, gmail. Event-driven trigger; 49 nodes.
Code. Uses openAi, gmailTrigger, stickyNote, gmail. Event-driven trigger; 49 nodes.