Intelligenter Gmail-E-Mail-Auto-Organizer (mit Google Sheets-Regeln)
Dies ist ein Ticket Management, Miscellaneous, Multimodal AI-Bereich Automatisierungsworkflow mit 17 Nodes. Hauptsächlich werden If, Code, Gmail, Merge, Slack und andere Nodes verwendet. Gmail-E-Mail-Automatischer Sortierer mit Google Sheets-Regeln
- •Google-Konto + Gmail API-Anmeldedaten
- •Slack Bot Token oder Webhook URL
- •Google Sheets API-Anmeldedaten
Verwendete Nodes (17)
{
"id": "z6QF6JvVLiEdA4Ij",
"meta": {
"instanceId": "50631c03cbd88440965b74e5a58aada5437cbc43e90372b516e36154908ad374",
"templateCredsSetupCompleted": true
},
"name": "Intelligent Gmail Email Auto Organizer with Google Sheets Rules",
"tags": [],
"nodes": [
{
"id": "a06719ac-b0f9-4f5d-927c-a7acfa2a1752",
"name": "Zeitplan-Trigger",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-2416,
520
],
"parameters": {
"rule": {
"interval": [
{
"field": "minutes"
}
]
}
},
"typeVersion": 1.2
},
{
"id": "fb2532f6-d850-4a11-b741-33b8d0a4503d",
"name": "Mehrere Nachrichten abrufen",
"type": "n8n-nodes-base.gmail",
"position": [
-2192,
400
],
"webhookId": "5d249991-7269-4e17-ae54-61d62f19a962",
"parameters": {
"filters": {
"labelIds": [
"INBOX"
]
},
"operation": "getAll"
},
"credentials": {
"gmailOAuth2": {
"id": "DCeq34r6AVUWvTDF",
"name": "Gmail account (omerfayyaz.engr@gmail.com)"
}
},
"typeVersion": 2.1
},
{
"id": "f2773ff3-af21-4a57-bf87-c58a8fb9272a",
"name": "Über Elemente iterieren",
"type": "n8n-nodes-base.splitInBatches",
"position": [
-1744,
400
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "e9f96ccc-a1cc-497f-aceb-b3867dd39dd3",
"name": "Ist Marketing-/automatisierte E-Mail?",
"type": "n8n-nodes-base.if",
"position": [
-1520,
-16
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "loose"
},
"combinator": "or",
"conditions": [
{
"id": "d31b4425-e112-4c3d-8ed4-cba2fa7bb6db",
"operator": {
"type": "boolean",
"operation": "true",
"singleValue": true
},
"leftValue": "={{\n(() => {\n const fromRaw = ($json[\"From\"] || \"\").toString().toLowerCase();\n const fromEmail = (fromRaw.match(/<([^>]+)>/)?.[1] || fromRaw).trim();\n const patterns = [\n // delete immediately\n \"ivan@mail.notion.so\", \"notifications@discord.com\",\n // promotions\n \"newsletter@\", \"mailer@\", \"bounce@\",\n \"@linkedin.com\", \"@e.linkedin.com\", \"@facebookmail.com\",\n \"@mail.instagram.com\", \"@slack.com\", \"@mailchimp.com\",\n \"info@e.atlassian.com\",\n \"x.com\",\n \"navicosoft.com\"\n ];\n return patterns.some(p => fromEmail.includes(p));\n})()\n}}",
"rightValue": ""
}
]
},
"looseTypeValidation": true
},
"typeVersion": 2.2
},
{
"id": "81a86b7e-0a23-45d4-9491-200fc7487156",
"name": "Werbung",
"type": "n8n-nodes-base.gmail",
"position": [
48,
-32
],
"webhookId": "6aaa1ffe-41a1-460c-8b60-86e9e1dd5be4",
"parameters": {
"labelIds": [
"CATEGORY_PROMOTIONS"
],
"messageId": "={{ $json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "DCeq34r6AVUWvTDF",
"name": "Gmail account (omerfayyaz.engr@gmail.com)"
}
},
"typeVersion": 2.1
},
{
"id": "f6d6425d-0474-49c2-b54b-e7c848fbb200",
"name": "Aus Posteingang entfernen",
"type": "n8n-nodes-base.gmail",
"position": [
272,
88
],
"webhookId": "4e7585b2-5803-48d8-b15e-0dd6df58b892",
"parameters": {
"labelIds": [
"INBOX"
],
"messageId": "={{ $json.id }}",
"operation": "removeLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "DCeq34r6AVUWvTDF",
"name": "Gmail account (omerfayyaz.engr@gmail.com)"
}
},
"typeVersion": 2.1
},
{
"id": "7694b09a-a5f6-479e-9008-5b97e6693d6e",
"name": "Als gelesen markieren",
"type": "n8n-nodes-base.gmail",
"position": [
496,
160
],
"webhookId": "786d065e-a1fc-4747-8ec1-85e98b732cce",
"parameters": {
"messageId": "={{ $json.id }}",
"operation": "markAsRead"
},
"credentials": {
"gmailOAuth2": {
"id": "DCeq34r6AVUWvTDF",
"name": "Gmail account (omerfayyaz.engr@gmail.com)"
}
},
"typeVersion": 2.1
},
{
"id": "a571c442-ae22-4f4d-b5d9-7b50b9b3a880",
"name": "Label hinzufügen",
"type": "n8n-nodes-base.gmail",
"position": [
48,
184
],
"webhookId": "c5151d08-b9f8-470e-a578-3614e2a1f841",
"parameters": {
"labelIds": "={{ [$json.labelId].filter(Boolean) }}",
"messageId": "={{ $json.id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "DCeq34r6AVUWvTDF",
"name": "Gmail account (omerfayyaz.engr@gmail.com)"
}
},
"typeVersion": 2.1
},
{
"id": "a4d6f349-4fdf-4f00-b708-96b805f06f14",
"name": "Gmail Labels",
"type": "n8n-nodes-base.gmail",
"position": [
-848,
512
],
"webhookId": "a80079f4-f9c3-4e25-a70c-99ced1d6ca36",
"parameters": {
"resource": "label",
"returnAll": true
},
"credentials": {
"gmailOAuth2": {
"id": "DCeq34r6AVUWvTDF",
"name": "Gmail account (omerfayyaz.engr@gmail.com)"
}
},
"typeVersion": 2.1
},
{
"id": "33b24f3b-3e2a-4a37-8cf6-73d2bbf41f65",
"name": "Existiert Label?",
"type": "n8n-nodes-base.if",
"position": [
-176,
184
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "or",
"conditions": [
{
"id": "d31b4425-e112-4c3d-8ed4-cba2fa7bb6db",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
},
"leftValue": "={{ $json.labelId }}",
"rightValue": "extra"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "9848ff9b-22bc-4c6f-a023-3b379680f2f5",
"name": "Zusammenführen",
"type": "n8n-nodes-base.merge",
"position": [
-624,
184
],
"parameters": {},
"typeVersion": 3.2
},
{
"id": "0fa625ab-3ebf-4568-a508-324bf1371b72",
"name": "Sheet Rules",
"type": "n8n-nodes-base.googleSheets",
"position": [
-1360,
160
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/11eTXs7UN8H0aqXxOvUvCEO_zDRyArBnibUYet0MhKrE/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "11eTXs7UN8H0aqXxOvUvCEO_zDRyArBnibUYet0MhKrE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/11eTXs7UN8H0aqXxOvUvCEO_zDRyArBnibUYet0MhKrE/edit?usp=drivesdk",
"cachedResultName": "Email Rules"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "m7KJWht6snJWUiJc",
"name": "Google Sheets account"
}
},
"typeVersion": 4.7
},
{
"id": "2b4ef6c6-535e-47f1-8834-d5b9544ff690",
"name": "Zusammenführen1",
"type": "n8n-nodes-base.merge",
"position": [
-1072,
184
],
"parameters": {
"mode": "chooseBranch"
},
"typeVersion": 3.2
},
{
"id": "f500be31-f1b5-46a4-bb49-1db7910ef748",
"name": "Absender-E-Mail parsen",
"type": "n8n-nodes-base.code",
"position": [
-1968,
400
],
"parameters": {
"jsCode": "return items.map(it => {\n const raw = String(it.json.From || \"\");\n const email = (raw.toLowerCase().match(/<([^>]+)>/)?.[1] || raw.toLowerCase()).trim();\n it.json._fromEmail = email;\n return it;\n});\n"
},
"typeVersion": 2
},
{
"id": "a12ff76d-5b4c-4f2e-8388-615a7ac24484",
"name": "Sheet Rules anwenden",
"type": "n8n-nodes-base.code",
"position": [
-848,
184
],
"parameters": {
"jsCode": "// Use pre-parsed email\nconst fromEmail = (s) => String(s || '').toLowerCase();\n\n// Build rules from Google Sheet\nconst rows = $items('Sheet Rules', 0).map(i => i.json);\nconst rules = rows\n .filter(r => r.Pattern && r.Action)\n .map(r => ({\n pattern: String(r.Pattern).toLowerCase().trim(),\n action: String(r.Action).toUpperCase().trim(), // DELETE | PROMO | LABEL\n labelName: String(r.LabelName || '').trim(),\n labelId: r.LabelId ? String(r.LabelId).trim() : null,\n removeInbox: String(r.RemoveFromInbox || '').toUpperCase() === 'TRUE',\n }));\n\nreturn items.map(it => {\n const sender = fromEmail(it.json._fromEmail || it.json.From);\n const hit = rules.find(r => sender.includes(r.pattern));\n\n it.json.__rule = hit || null;\n\n // For downstream switches:\n if (!hit) {\n it.json.switchLable = 'extra';\n } else if (hit.action === 'LABEL') {\n it.json.switchLable = hit.labelName || 'extra';\n it.json.labelId = hit.labelId || null; // if provided in sheet\n } else if (hit.action === 'PROMO') {\n it.json.switchLable = 'PROMO';\n } else if (hit.action === 'DELETE') {\n it.json.switchLable = 'DELETE';\n }\n\n return it;\n});\n"
},
"typeVersion": 2
},
{
"id": "09790520-8c41-49d9-a818-1cc3e658b30c",
"name": "Label-Name zuordnen",
"type": "n8n-nodes-base.code",
"position": [
-400,
184
],
"parameters": {
"jsCode": "// Build name → id map from Gmail Labels node\nconst labels = $items('Gmail Labels', 0).map(i => i.json);\nconst map = Object.fromEntries(\n labels.filter(l => l && l.name && l.id)\n .map(l => [String(l.name).trim(), l.id])\n);\n\nreturn items.map(item => {\n const key = String(item.json.switchLable || '').trim();\n\n // Only look up when we don't already have an id and key is a real label name\n if (!item.json.labelId && key && key !== 'PROMO' && key !== 'DELETE' && key !== 'extra') {\n item.json.labelId = map[key] || null;\n }\n return item;\n});\n"
},
"typeVersion": 2
},
{
"id": "189627a3-e7c6-4835-ab1a-801a68fb74e1",
"name": "Abschlussbenachrichtigung",
"type": "n8n-nodes-base.slack",
"position": [
-1376,
416
],
"webhookId": "0a1c0309-0a0b-4e37-972d-b229684c2d52",
"parameters": {
"text": "=✅ Email Organization completed",
"select": "channel",
"channelId": {
"__rl": true,
"mode": "id",
"value": "C099YS0V3M2"
},
"otherOptions": {}
},
"credentials": {
"slackApi": {
"id": "VI4wP9VPIS3KDiow",
"name": "Slack account"
}
},
"executeOnce": true,
"typeVersion": 2.2
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "fd2cbb63-08c6-4841-aa0d-ee5c085b40a6",
"connections": {
"9848ff9b-22bc-4c6f-a023-3b379680f2f5": {
"main": [
[
{
"node": "09790520-8c41-49d9-a818-1cc3e658b30c",
"type": "main",
"index": 0
}
]
]
},
"2b4ef6c6-535e-47f1-8834-d5b9544ff690": {
"main": [
[
{
"node": "a12ff76d-5b4c-4f2e-8388-615a7ac24484",
"type": "main",
"index": 0
}
]
]
},
"a571c442-ae22-4f4d-b5d9-7b50b9b3a880": {
"main": [
[
{
"node": "f6d6425d-0474-49c2-b54b-e7c848fbb200",
"type": "main",
"index": 0
}
]
]
},
"81a86b7e-0a23-45d4-9491-200fc7487156": {
"main": [
[
{
"node": "f6d6425d-0474-49c2-b54b-e7c848fbb200",
"type": "main",
"index": 0
}
]
]
},
"0fa625ab-3ebf-4568-a508-324bf1371b72": {
"main": [
[
{
"node": "2b4ef6c6-535e-47f1-8834-d5b9544ff690",
"type": "main",
"index": 1
}
]
]
},
"a4d6f349-4fdf-4f00-b708-96b805f06f14": {
"main": [
[
{
"node": "9848ff9b-22bc-4c6f-a023-3b379680f2f5",
"type": "main",
"index": 1
}
]
]
},
"7694b09a-a5f6-479e-9008-5b97e6693d6e": {
"main": [
[
{
"node": "f2773ff3-af21-4a57-bf87-c58a8fb9272a",
"type": "main",
"index": 0
}
]
]
},
"09790520-8c41-49d9-a818-1cc3e658b30c": {
"main": [
[
{
"node": "33b24f3b-3e2a-4a37-8cf6-73d2bbf41f65",
"type": "main",
"index": 0
}
]
]
},
"f2773ff3-af21-4a57-bf87-c58a8fb9272a": {
"main": [
[
{
"node": "189627a3-e7c6-4835-ab1a-801a68fb74e1",
"type": "main",
"index": 0
}
],
[
{
"node": "e9f96ccc-a1cc-497f-aceb-b3867dd39dd3",
"type": "main",
"index": 0
}
]
]
},
"33b24f3b-3e2a-4a37-8cf6-73d2bbf41f65": {
"main": [
[
{
"node": "a571c442-ae22-4f4d-b5d9-7b50b9b3a880",
"type": "main",
"index": 0
}
],
[
{
"node": "f2773ff3-af21-4a57-bf87-c58a8fb9272a",
"type": "main",
"index": 0
}
]
]
},
"a06719ac-b0f9-4f5d-927c-a7acfa2a1752": {
"main": [
[
{
"node": "fb2532f6-d850-4a11-b741-33b8d0a4503d",
"type": "main",
"index": 0
},
{
"node": "a4d6f349-4fdf-4f00-b708-96b805f06f14",
"type": "main",
"index": 0
}
]
]
},
"a12ff76d-5b4c-4f2e-8388-615a7ac24484": {
"main": [
[
{
"node": "9848ff9b-22bc-4c6f-a023-3b379680f2f5",
"type": "main",
"index": 0
}
]
]
},
"fb2532f6-d850-4a11-b741-33b8d0a4503d": {
"main": [
[
{
"node": "f500be31-f1b5-46a4-bb49-1db7910ef748",
"type": "main",
"index": 0
}
]
]
},
"f6d6425d-0474-49c2-b54b-e7c848fbb200": {
"main": [
[
{
"node": "7694b09a-a5f6-479e-9008-5b97e6693d6e",
"type": "main",
"index": 0
}
]
]
},
"f500be31-f1b5-46a4-bb49-1db7910ef748": {
"main": [
[
{
"node": "f2773ff3-af21-4a57-bf87-c58a8fb9272a",
"type": "main",
"index": 0
}
]
]
},
"e9f96ccc-a1cc-497f-aceb-b3867dd39dd3": {
"main": [
[
{
"node": "81a86b7e-0a23-45d4-9491-200fc7487156",
"type": "main",
"index": 0
}
],
[
{
"node": "0fa625ab-3ebf-4568-a508-324bf1371b72",
"type": "main",
"index": 0
},
{
"node": "2b4ef6c6-535e-47f1-8834-d5b9544ff690",
"type": "main",
"index": 0
}
]
]
}
}
}Wie verwende ich diesen Workflow?
Kopieren Sie den obigen JSON-Code, erstellen Sie einen neuen Workflow in Ihrer n8n-Instanz und wählen Sie "Aus JSON importieren". Fügen Sie die Konfiguration ein und passen Sie die Anmeldedaten nach Bedarf an.
Für welche Szenarien ist dieser Workflow geeignet?
Experte - Ticketverwaltung, Verschiedenes, Multimodales KI
Ist es kostenpflichtig?
Dieser Workflow ist völlig kostenlos. Beachten Sie jedoch, dass Drittanbieterdienste (wie OpenAI API), die im Workflow verwendet werden, möglicherweise kostenpflichtig sind.
Verwandte Workflows
Omer Fayyaz
@omerfayyazn8n Expert with deep experience in designing and implementing automation workflows that optimize business processes, reduce manual effort, and improve scalability. Skilled in integrating n8n with diverse platforms, APIs, and enterprise systems to deliver end-to-end automation solutions. With 13+ years of background in web development (PHP & JavaScript), I bring strong technical expertise to create custom, reliable, and efficient workflows.
Diesen Workflow teilen