This workflow corresponds to n8n.io template #7753 — 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 →
{
"nodes": [
{
"id": "cd71d5f3-b50b-426d-840d-da6eea33a217",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-16,
448
],
"parameters": {
"color": 2,
"width": 336,
"height": 956,
"content": "# \u2699\ufe0f INITIAL SETUP GUIDE\n\n## STEP 1: Create Gmail Labels\nGo to Gmail and create these 4 labels:\n- `Urgent + Important`\n- `Not Urgent + Important`\n- `Urgent + Not Important`\n- `Not Urgent + Not Important`\n\n## STEP 2: Get Your Label IDs\n1. Create temporary Gmail node\n2. Set operation to **Get All Labels**\n3. Execute to see your label IDs\n4. Copy each label ID\n5. Replace IDs in Gmail nodes\n\n## STEP 3: Add Credentials\n**Gmail OAuth2:**\n- Click any Gmail node\n- Create new credential\n- Follow OAuth2 flow\n\n**OpenAI API:**\n- Get key from platform.openai.com\n- Add to OpenAI node\n\n## STEP 4: Test First\n- Use Manual Trigger\n- Process 5-10 emails\n- Verify accuracy\n- Then activate"
},
"typeVersion": 1
},
{
"id": "5a5a84e6-bf32-4ef0-bc87-160d5fb5a610",
"name": "Gmail Trigger",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
816,
608
],
"parameters": {
"simple": false,
"filters": {},
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 1.3
},
{
"id": "6da49556-8b27-49bc-ac4a-7bd31dd371c7",
"name": "AI Email Classifier",
"type": "@n8n/n8n-nodes-langchain.textClassifier",
"position": [
1088,
736
],
"parameters": {
"options": {
"systemPromptTemplate": "You are an expert email prioritization assistant. Classify the email based on the Eisenhower Matrix principles. Consider sender importance, content urgency, business impact, and deadline implications. Output only the category in JSON format without explanation."
},
"inputText": "={{ $json.text }}",
"categories": {
"categories": [
{
"category": "Urgent + Important",
"description": "Emails requiring immediate action due to high impact. Not addressing them could have serious consequences. Includes legal matters, critical financial issues, investor communications, regulatory compliance, or user problems blocking service usage."
},
{
"category": "Not Urgent + Important",
"description": "Messages with high strategic value but no immediate deadline. Includes partnership opportunities, negotiations, relevant invitations, and key coordination that can be scheduled thoughtfully."
},
{
"category": "Urgent + Not Important",
"description": "Emails needing quick attention but not requiring your direct involvement. Operational or technical matters that can be delegated to another person or team without affecting strategic objectives."
},
{
"category": "Not Urgent + Not Important",
"description": "Emails with no immediate or strategic value. Includes promotions, spam, and generic messages that distract and can be ignored, deleted, or batch-reviewed later."
}
]
}
},
"typeVersion": 1.1
},
{
"id": "cc962116-3299-428f-9a88-06cfff08501b",
"name": "OpenAI GPT-4",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1160,
1024
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini",
"cachedResultName": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "034c4031-95dc-4593-89f1-9cf0903591d7",
"name": "Label: Not Urgent + Important",
"type": "n8n-nodes-base.gmail",
"position": [
1440,
640
],
"parameters": {
"labelIds": [
"Label_108825101456559558"
],
"messageId": "={{ $json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "683a55c5-8738-4503-b721-42c5ba6fcbb2",
"name": "Label: Urgent + Important",
"type": "n8n-nodes-base.gmail",
"position": [
1440,
448
],
"parameters": {
"labelIds": [
"Label_4335697733647997523"
],
"messageId": "={{ $json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "17983317-e9ca-4d3f-bf7c-b8cf07955972",
"name": "Label: Urgent + Not Important",
"type": "n8n-nodes-base.gmail",
"position": [
1440,
832
],
"parameters": {
"labelIds": [
"Label_3686091807609025659"
],
"messageId": "={{ $json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "90f85ac6-a960-443c-9b26-9da29fde9a59",
"name": "Label: Not Urgent + Not Important",
"type": "n8n-nodes-base.gmail",
"position": [
1440,
1024
],
"parameters": {
"labelIds": [
"Label_4+12345678905"
],
"messageId": "={{ $json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "2ce3c21f-59ed-45bc-9606-72f74f792dc0",
"name": "Archive Email",
"type": "n8n-nodes-base.gmail",
"position": [
1664,
1024
],
"parameters": {
"labelIds": [
"INBOX",
"CATEGORY_PERSONAL",
"CATEGORY_FORUMS",
"CATEGORY_PROMOTIONS",
"CATEGORY_SOCIAL",
"CATEGORY_UPDATES"
],
"messageId": "={{ $json.id }}",
"operation": "removeLabels"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "0ba5af91-5501-4146-b43e-d9ac4c681a66",
"name": "Manual Test Trigger",
"type": "n8n-nodes-base.manualTrigger",
"position": [
256,
1488
],
"parameters": {},
"typeVersion": 1
},
{
"id": "b57271f1-5747-4547-96f1-1a4cc13fddde",
"name": "Batch Process Emails",
"type": "n8n-nodes-base.gmail",
"position": [
448,
1488
],
"parameters": {
"limit": 5,
"simple": false,
"filters": {
"labelIds": [
"INBOX"
],
"readStatus": "unread"
},
"options": {},
"operation": "getAll"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.1
},
{
"id": "6737dc62-1849-4fdf-8ad7-03002c81312b",
"name": "Filter Valid Emails",
"type": "n8n-nodes-base.filter",
"position": [
640,
1488
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "af426b69-affb-4fe6-a375-f5a711f553d3",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.text }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "fb3982b8-2085-43a0-a281-661b520eb3ca",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
400,
592
],
"parameters": {
"width": 352,
"height": 480,
"content": "# \ud83d\udce5 AUTOMATIC EMAIL DETECTION\n\nGmail Trigger checks inbox every minute.\n\n## Current Settings:\n- **Polling**: Every 60 seconds\n- **Looks for**: New unread emails\n- **Processes**: One at a time\n\n## Optimization Tips:\n- **High volume**: Keep 1 minute\n- **Medium (20-50/day)**: 5 minutes\n- **Low (<20/day)**: 15 minutes\n\n\ud83d\udca1 **Note**: Each execution uses API calls."
},
"typeVersion": 1
},
{
"id": "d3e65c11-555b-435d-b4f3-2aa83c2cabc6",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
400,
-64
],
"parameters": {
"width": 880,
"height": 592,
"content": "# \ud83d\udce7 EISENHOWER MATRIX EMAIL AUTOMATION\n\nThis workflow automatically categorizes your Gmail emails using the Eisenhower Matrix productivity framework.\n\n## THE FOUR QUADRANTS:\n- **\ud83d\udd34 Urgent + Important (DO NOW)**: Crisis, deadlines, emergencies\n- **\ud83d\udfe2 Not Urgent + Important (SCHEDULE)**: Planning, relationships, growth\n- **\ud83d\udfe1 Urgent + Not Important (DELEGATE)**: Interruptions, some emails\n- **\u26ab Not Urgent + Not Important (DELETE)**: Spam, time wasters\n\n## HOW IT WORKS:\n1. New emails trigger the workflow\n2. AI analyzes content and context\n3. Emails get labeled automatically\n4. Low-priority emails are archived\n\n## REQUIREMENTS:\n- Gmail account with OAuth2\n- OpenAI API key (GPT-4)\n- Four Gmail labels created"
},
"typeVersion": 1
},
{
"id": "1e5e4e33-579f-4cd1-8aff-f1cf46db7269",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
976,
1184
],
"parameters": {
"width": 416,
"height": 944,
"content": "# \ud83e\udd16 AI CLASSIFICATION ENGINE\n\n## Analyzes:\n- Email content\n- Sender importance\n- Urgency keywords\n- Business impact\n- Deadlines\n\n## EXAMPLES:\n\n### \ud83d\udd34 Urgent + Important:\n- Legal notice requiring response\n- Server down affecting customers\n- Investor meeting tomorrow\n- Compliance audit deadline\n\n### \ud83d\udfe2 Not Urgent + Important:\n- Q2 strategic planning\n- Partnership opportunity\n- Team development program\n- Annual review prep\n\n### \ud83d\udfe1 Urgent + Not Important:\n- Approve expense report\n- Meeting rescheduled\n- Update password reminder\n- Office supplies order\n\n### \u26ab Not Urgent + Not Important:\n- Newsletters\n- Promotions\n- Social notifications\n- Marketing emails"
},
"typeVersion": 1
},
{
"id": "428158f8-3354-49a2-a558-dc95f529e330",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
1680,
208
],
"parameters": {
"width": 624,
"height": 752,
"content": "# \ud83c\udff7\ufe0f GMAIL LABELING SYSTEM\n\n\u26a0\ufe0f **IMPORTANT: Replace Label IDs!**\nEach Gmail has unique IDs.\nYou MUST update them.\n\n## How Categories Are Handled:\n\n### \ud83d\udd34 Urgent + Important:\n- Gets red label\n- Stays in inbox\n- Consider notifications\n\n### \ud83d\udfe2 Not Urgent + Important:\n- Gets green label\n- Stays in inbox\n- Review in planning time\n\n### \ud83d\udfe1 Urgent + Not Important:\n- Gets yellow label\n- Stays in inbox\n- Delegate or quick reply\n\n### \u26ab Not Urgent + Not Important:\n- Gets gray label\n- Auto-archived\n- Bulk review later\n\n**Pro Tip**: Create Gmail filters to show labels in sidebar."
},
"typeVersion": 1
},
{
"id": "53971ed2-e8f7-45a5-a708-b07d663daf4f",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
1648,
1200
],
"parameters": {
"width": 560,
"height": 496,
"content": "# \ud83d\uddc4\ufe0f AUTO-ARCHIVE FEATURE\n\nOnly **Not Urgent + Not Important** emails get archived!\n\n## What Archiving Does:\n\u2705 Removes from inbox\n\u2705 Keeps classification label\n\u2705 Email remains searchable\n\u2705 Can access anytime\n\n## Labels Being Removed:\n- INBOX (archives it)\n- All category labels\n- Keeps custom label\n\n## Why This Matters:\n**Reduces inbox noise by 40-60%**\nLets you focus on what matters."
},
"typeVersion": 1
},
{
"id": "9ccd31b9-f706-443e-8074-ab86ee691ebc",
"name": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"position": [
256,
1664
],
"parameters": {
"width": 512,
"height": 720,
"content": "# \ud83e\uddea MANUAL BATCH PROCESSING\n\n## When to Use:\n- Initial setup testing\n- After vacation catch-up\n- Processing backlog\n- Testing accuracy\n\n## How It Works:\n1. Click **Execute Workflow**\n2. Fetches 100 unread emails\n3. Filters valid emails\n4. Processes through AI\n5. Applies labels at once\n\n## \u26a0\ufe0f START SMALL!\n- **First test**: Set limit to 10\n- Check classifications\n- Adjust if needed\n- Then increase to 100\n\n## \ud83d\udcb0 Cost Note:\n100 emails = $0.10-0.30\ndepending on length."
},
"typeVersion": 1
}
],
"connections": {
"OpenAI GPT-4": {
"ai_languageModel": [
[
{
"node": "AI Email Classifier",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Gmail Trigger": {
"main": [
[
{
"node": "AI Email Classifier",
"type": "main",
"index": 0
}
]
]
},
"AI Email Classifier": {
"main": [
[
{
"node": "Label: Urgent + Important",
"type": "main",
"index": 0
}
],
[
{
"node": "Label: Not Urgent + Important",
"type": "main",
"index": 0
}
],
[
{
"node": "Label: Urgent + Not Important",
"type": "main",
"index": 0
}
],
[
{
"node": "Label: Not Urgent + Not Important",
"type": "main",
"index": 0
}
]
]
},
"Filter Valid Emails": {
"main": [
[
{
"node": "AI Email Classifier",
"type": "main",
"index": 0
}
]
]
},
"Manual Test Trigger": {
"main": [
[
{
"node": "Batch Process Emails",
"type": "main",
"index": 0
}
]
]
},
"Batch Process Emails": {
"main": [
[
{
"node": "Filter Valid Emails",
"type": "main",
"index": 0
}
]
]
},
"Label: Not Urgent + Not Important": {
"main": [
[
{
"node": "Archive Email",
"type": "main",
"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
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 lead, this solution helps you bring structure and clarity to your inbox. If you…
Source: https://n8n.io/workflows/7753/ — 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 n8n template demonstrates how to automate email classification, labeling, draft generation, and logging using Gmail, OpenAI, and Google Sheets. Use cases include customer support management, sale
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