Automatisierung der E-Mail-Klassifizierung und Antwortgenerierung mit Gmail und GPT-4
Dies ist ein Ticket Management, Multimodal AI-Bereich Automatisierungsworkflow mit 15 Nodes. Hauptsächlich werden If, Gmail, OpenAi, Webhook, GoogleSheets und andere Nodes verwendet. Automatisierung der E-Mail-Klassifizierung und Antwortgenerierung mit Gmail und GPT-4
- •Google-Konto + Gmail API-Anmeldedaten
- •OpenAI API Key
- •HTTP Webhook-Endpunkt (wird von n8n automatisch generiert)
- •Google Sheets API-Anmeldedaten
Verwendete Nodes (15)
Kategorie
{
"meta": {
"instanceId": "e7ccf4281d5afb175c79c02db95b45f15d5b53862cb6bc357c5e5bc26567f35c"
},
"nodes": [
{
"id": "759d4f88-c6de-4cee-af9a-628102d93200",
"name": "📧 Gmail Webhook Trigger",
"type": "n8n-nodes-base.webhook",
"notes": "🔧 SETUP REQUIRED:\n1. Copy webhook URL after saving\n2. Configure Gmail webhook in Google Cloud Console\n3. Set up Gmail push notifications\n4. Test with sample email",
"position": [
-800,
464
],
"webhookId": "gmail-email-webhook",
"parameters": {
"path": "gmail-webhook",
"options": {},
"httpMethod": "POST",
"responseMode": "responseNode"
},
"typeVersion": 1
},
{
"id": "000229fb-153f-4db4-ad19-cda7b78f3b57",
"name": "📩 E-Mail-Details abrufen",
"type": "n8n-nodes-base.gmail",
"notes": "🔧 SETUP REQUIRED:\n1. Create Gmail OAuth2 credentials\n2. Add scopes: gmail.readonly, gmail.modify\n3. Authorize the connection\n4. Test connection",
"position": [
-576,
464
],
"webhookId": "0d0edb78-408d-41be-b856-b3bdff6b4e4f",
"parameters": {
"messageId": "={{ $json.message.data.messageId }}",
"operation": "get"
},
"credentials": {
"gmailOAuth2": {
"id": "zDJ58xrpmivGPuAW",
"name": "Gmail account"
}
},
"typeVersion": 2
},
{
"id": "daf62cc0-3dc9-4b67-801b-3c48eeb3d4df",
"name": "🤖 KI-E-Mail-Analyzer",
"type": "n8n-nodes-base.openAi",
"notes": "🔧 SETUP REQUIRED:\n1. Get OpenAI API key\n2. Add to credentials\n3. Choose model (gpt-4 recommended)\n4. Adjust temperature for consistency\n5. Test with sample emails",
"position": [
-368,
464
],
"parameters": {
"model": "gpt-4",
"prompt": "=Analyze this email and provide a JSON response with the following structure:\n{\n \"category\": \"urgent|important|promotional|spam|personal|work\",\n \"sentiment\": \"positive|negative|neutral\",\n \"priority\": \"high|medium|low\",\n \"action_needed\": \"reply|forward|archive|delete|flag\",\n \"summary\": \"brief summary in 1-2 sentences\",\n \"suggested_response\": \"suggested response if reply needed\",\n \"keywords\": [\"array\", \"of\", \"relevant\", \"keywords\"]\n}\n\nEmail details:\nFrom: {{ $node['📩 Get Email Details'].json.payload.headers.find(h => h.name === 'From').value }}\nSubject: {{ $node['📩 Get Email Details'].json.payload.headers.find(h => h.name === 'Subject').value }}\nBody: {{ $node['📩 Get Email Details'].json.snippet }}",
"options": {
"maxTokens": 1000,
"temperature": 0.3
},
"requestOptions": {}
},
"credentials": {
"openAiApi": {
"id": "OQJASLp1qn1StvpI",
"name": "OpenAi account"
}
},
"typeVersion": 1
},
{
"id": "cf1eba5b-6645-4b21-b5bb-d8cb4ae5015e",
"name": "🚦 Priority Router",
"type": "n8n-nodes-base.if",
"notes": "📝 POST-IT NOTE:\nRoutes emails based on AI analysis\n- High priority → Immediate notification\n- Medium/Low → Standard processing\n- Customize conditions as needed",
"position": [
-144,
464
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": false,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ JSON.parse($json.choices[0].message.content).priority }}",
"rightValue": "high"
}
]
}
},
"typeVersion": 2
},
{
"id": "cbb52bdb-1065-4d4f-b09f-08e9367940f4",
"name": "🚨 High Priority Alert",
"type": "n8n-nodes-base.gmail",
"notes": "🔧 SETUP REQUIRED:\n1. Update notification email address\n2. Customize alert message\n3. Consider using Slack/Teams instead\n4. Test notification delivery",
"position": [
80,
352
],
"webhookId": "76854229-c43b-4331-9860-d44d5e02b8ec",
"parameters": {
"message": "=High priority email received:\n\nFrom: {{ $node['📩 Get Email Details'].json.payload.headers.find(h => h.name === 'From').value }}\nSubject: {{ $node['📩 Get Email Details'].json.payload.headers.find(h => h.name === 'Subject').value }}\n\nAI Summary: {{ JSON.parse($node['🤖 AI Email Analyzer'].json.choices[0].message.content).summary }}\n\nSuggested Action: {{ JSON.parse($node['🤖 AI Email Analyzer'].json.choices[0].message.content).action_needed }}\n\nView in Gmail: https://mail.google.com/mail/u/0/#inbox/{{ $node['📩 Get Email Details'].json.id }}",
"options": {},
"subject": "🚨 High Priority Email Alert"
},
"credentials": {
"gmailOAuth2": {
"id": "zDJ58xrpmivGPuAW",
"name": "Gmail account"
}
},
"typeVersion": 2
},
{
"id": "b77a498a-001c-4029-a60a-1307dafa27fc",
"name": "🛡️ Spam Detector",
"type": "n8n-nodes-base.if",
"notes": "📝 POST-IT NOTE:\nDetects spam emails\n- Auto-delete or move to spam\n- Log spam attempts\n- Update spam filters",
"position": [
80,
560
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": false,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ JSON.parse($node['🤖 AI Email Analyzer'].json.choices[0].message.content).category }}",
"rightValue": "spam"
}
]
}
},
"typeVersion": 2
},
{
"id": "1b7b3f23-01cb-42c0-8985-79696d0a38b2",
"name": "🗑️ In Spam verschieben",
"type": "n8n-nodes-base.gmail",
"notes": "📝 POST-IT NOTE:\nMoves spam to spam folder\n- Removes from inbox\n- Adds spam label\n- Consider auto-delete after time",
"position": [
304,
656
],
"webhookId": "ca7a4755-b0f4-4f7e-9b3a-4c20971b2ce1",
"parameters": {
"operation": "modify"
},
"typeVersion": 2
},
{
"id": "63ae92b9-71c5-41e9-82f7-606985a1e4f3",
"name": "💬 Auto-Reply Detector",
"type": "n8n-nodes-base.if",
"notes": "📝 POST-IT NOTE:\nDetects emails needing replies\n- AI suggests response\n- Option for auto-send or draft\n- Customize reply rules",
"position": [
304,
480
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": false,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ JSON.parse($node['🤖 AI Email Analyzer'].json.choices[0].message.content).action_needed }}",
"rightValue": "reply"
}
]
}
},
"typeVersion": 2
},
{
"id": "778961c6-43d4-4624-abdb-3d6bebcf6249",
"name": "📝 Antwortentwurf erstellen",
"type": "n8n-nodes-base.gmail",
"notes": "📝 POST-IT NOTE:\nCreates AI-generated reply draft\n- Review before sending\n- Customize response style\n- Option to auto-send for simple cases",
"position": [
528,
352
],
"webhookId": "2af91249-fdb6-4447-b573-8c06249a52fe",
"parameters": {
"message": "={{ JSON.parse($node['🤖 AI Email Analyzer'].json.choices[0].message.content).suggested_response }}\n\n---\nThis is an AI-generated draft. Please review before sending.",
"options": {},
"subject": "=Re: {{ $node['📩 Get Email Details'].json.payload.headers.find(h => h.name === 'Subject').value }}",
"resource": "draft"
},
"typeVersion": 2
},
{
"id": "4a6f205f-80e6-42fc-be48-a672b76163ee",
"name": "🏷️ E-Mail kategorisieren",
"type": "n8n-nodes-base.gmail",
"notes": "🔧 SETUP REQUIRED:\n1. Create Gmail labels:\n - URGENT, IMPORTANT\n - PROMOTIONAL, PERSONAL\n - WORK, PROJECTS\n2. Customize categories\n3. Set up label colors",
"position": [
528,
560
],
"webhookId": "8c0f452c-f1ac-4c72-8f92-834477ecd627",
"parameters": {
"operation": "modify"
},
"typeVersion": 2
},
{
"id": "9be9a801-9b54-45f2-a820-4a35dc7915bb",
"name": "📊 In Tabellenkalkulation protokollieren",
"type": "n8n-nodes-base.googleSheets",
"notes": "🔧 SETUP REQUIRED:\n1. Create Google Sheets log\n2. Add headers: timestamp, messageId, from, subject, category, priority, sentiment, action_taken, ai_summary\n3. Share sheet with service account\n4. Update spreadsheet ID",
"position": [
752,
464
],
"parameters": {
"resource": "spreadsheet",
"operation": "appendOrUpdate"
},
"typeVersion": 4
},
{
"id": "0f78144e-bb3a-4065-b15e-3294750b13b7",
"name": "✅ Webhook Response",
"type": "n8n-nodes-base.respondToWebhook",
"notes": "📝 POST-IT NOTE:\nSends response back to Gmail\n- Confirms processing\n- Includes analysis results\n- Required for webhook completion",
"position": [
960,
464
],
"parameters": {
"options": {},
"respondWith": "json",
"responseBody": {
"details": {
"category": "={{ JSON.parse($node['🤖 AI Email Analyzer'].json.choices[0].message.content).category }}",
"priority": "={{ JSON.parse($node['🤖 AI Email Analyzer'].json.choices[0].message.content).priority }}",
"messageId": "={{ $node['📩 Get Email Details'].json.id }}",
"action_taken": "={{ JSON.parse($node['🤖 AI Email Analyzer'].json.choices[0].message.content).action_needed }}"
},
"message": "Email processed successfully",
"success": true
}
},
"typeVersion": 1
},
{
"id": "fe23603a-8174-48ee-8ebf-3cabf507ecd7",
"name": "Sticky Note9",
"type": "n8n-nodes-base.stickyNote",
"position": [
-768,
-320
],
"parameters": {
"color": 3,
"width": 576,
"height": 560,
"content": "## Need a tailor-made workflow? Tell me about your business and get a free proposal:\n\n**[Start here → Custom Automation Form](https://taskmorphr.com/contact)**\n\n---\n## 📈 Cost-Savings Snapshot \nCurious what automation could save you? \nRun the 60-second calculator:\n\n**[ROI / Cost Comparison](https://taskmorphr.com/cost-comparison)**\n\n---\n### ✉️ Reach me directly \n`paul@taskmorphr.com`"
},
"typeVersion": 1
},
{
"id": "4ca8fea5-6f43-41f9-9e68-e2dca7f73d8e",
"name": "Sticky Note10",
"type": "n8n-nodes-base.stickyNote",
"position": [
-464,
64
],
"parameters": {
"color": 3,
"width": 224,
"height": 128,
"content": "### 🛠️ Build it yourself \nBrowse every ready-made workflow: \n[Full Template Pack — coming soon](https://n8n.io/creators/diagopl/)\n"
},
"typeVersion": 1
},
{
"id": "f2cbe293-04fa-48c4-8849-4637063becf3",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1776,
-304
],
"parameters": {
"width": 848,
"height": 2272,
"content": "# Gmail AI Email Manager - Setup Guide\n\n## 🎯 Workflow Overview\n\nThis workflow will create an intelligent Gmail email manager that can:\n- Monitor incoming emails via webhook\n- Analyze email content using AI\n- Categorize emails automatically\n- Generate smart responses\n- Take actions based on email content\n- Send notifications for important emails\n\n## 📋 Pre-Setup Checklist\n\nBefore we build the workflow, let me gather the necessary information and validate our approach.\n\n### Phase 1: Discovery & Planning\n- [ ] Search for Gmail nodes\n- [ ] Find AI analysis nodes\n- [ ] Identify webhook trigger options\n- [ ] Check notification nodes\n\n### Phase 2: Configuration Requirements\n- [ ] Gmail API credentials\n- [ ] AI service (OpenAI/Claude) API key\n- [ ] Webhook URL setup\n- [ ] Email classification rules\n\n## 🔧 Setup Instructions\n\n### Step 1: Gmail API Setup\n1. Go to Google Cloud Console\n2. Create new project or select existing\n3. Enable Gmail API\n4. Create OAuth 2.0 credentials\n5. Add authorized redirect URI: `https://your-n8n-instance.com/rest/oauth2-credential/callback`\n\n### Step 2: AI Service Setup\nChoose one of the following:\n- **OpenAI**: Get API key from platform.openai.com\n- **Claude**: Get API key from console.anthropic.com\n- **Local AI**: Set up Ollama or similar\n\n### Step 3: n8n Credentials\n1. Gmail OAuth2: Add client ID, secret, and scopes\n2. AI Service: Add API key\n3. Webhook: Configure webhook URL\n\n# Gmail AI Email Manager - Setup Guide\n\n## 🔧 Quick Setup Checklist\n\n### 1. Google Cloud Console\n- [ ] Enable Gmail API\n- [ ] Create OAuth2 credentials \n- [ ] Add redirect URI: `https://your-n8n.com/rest/oauth2-credential/callback`\n- [ ] Set up Gmail push notifications with Pub/Sub\n\n### 2. API Keys\n- [ ] Get OpenAI API key from platform.openai.com\n- [ ] Create Google Sheets for logging (optional)\n\n### 3. n8n Credentials\n- [ ] **Gmail OAuth2**: Client ID, Secret, Scopes: `gmail.readonly,gmail.modify,gmail.compose`\n- [ ] **OpenAI API**: Your API key\n\n### 4. Gmail Labels (Create these)\n- [ ] URGENT (red) \n- [ ] IMPORTANT (orange)\n- [ ] PROMOTIONAL (purple)\n- [ ] PERSONAL (green) \n- [ ] WORK (blue)\n- [ ] SPAM (gray)\n\n### 5. Update Workflow Values\n- [ ] High Priority Alert: Change notification email\n- [ ] Spreadsheet Log: Update sheet ID (if using)\n- [ ] Webhook: Copy URL after saving workflow\n\n### 6. Test\n- [ ] Save & activate workflow\n- [ ] Send test email to Gmail\n- [ ] Check execution log\n- [ ] Verify auto-categorization works\n\n**That's it! Your AI email manager is ready! 🚀**"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"1b7b3f23-01cb-42c0-8985-79696d0a38b2": {
"main": [
[
{
"node": "9be9a801-9b54-45f2-a820-4a35dc7915bb",
"type": "main",
"index": 0
}
]
]
},
"cf1eba5b-6645-4b21-b5bb-d8cb4ae5015e": {
"main": [
[
{
"node": "cbb52bdb-1065-4d4f-b09f-08e9367940f4",
"type": "main",
"index": 0
}
],
[
{
"node": "b77a498a-001c-4029-a60a-1307dafa27fc",
"type": "main",
"index": 0
}
]
]
},
"b77a498a-001c-4029-a60a-1307dafa27fc": {
"main": [
[
{
"node": "1b7b3f23-01cb-42c0-8985-79696d0a38b2",
"type": "main",
"index": 0
}
],
[
{
"node": "63ae92b9-71c5-41e9-82f7-606985a1e4f3",
"type": "main",
"index": 0
}
]
]
},
"000229fb-153f-4db4-ad19-cda7b78f3b57": {
"main": [
[
{
"node": "daf62cc0-3dc9-4b67-801b-3c48eeb3d4df",
"type": "main",
"index": 0
}
]
]
},
"daf62cc0-3dc9-4b67-801b-3c48eeb3d4df": {
"main": [
[
{
"node": "cf1eba5b-6645-4b21-b5bb-d8cb4ae5015e",
"type": "main",
"index": 0
}
]
]
},
"9be9a801-9b54-45f2-a820-4a35dc7915bb": {
"main": [
[
{
"node": "0f78144e-bb3a-4065-b15e-3294750b13b7",
"type": "main",
"index": 0
}
]
]
},
"778961c6-43d4-4624-abdb-3d6bebcf6249": {
"main": [
[
{
"node": "4a6f205f-80e6-42fc-be48-a672b76163ee",
"type": "main",
"index": 0
}
]
]
},
"4a6f205f-80e6-42fc-be48-a672b76163ee": {
"main": [
[
{
"node": "9be9a801-9b54-45f2-a820-4a35dc7915bb",
"type": "main",
"index": 0
}
]
]
},
"63ae92b9-71c5-41e9-82f7-606985a1e4f3": {
"main": [
[
{
"node": "778961c6-43d4-4624-abdb-3d6bebcf6249",
"type": "main",
"index": 0
}
],
[
{
"node": "4a6f205f-80e6-42fc-be48-a672b76163ee",
"type": "main",
"index": 0
}
]
]
},
"cbb52bdb-1065-4d4f-b09f-08e9367940f4": {
"main": [
[
{
"node": "4a6f205f-80e6-42fc-be48-a672b76163ee",
"type": "main",
"index": 0
}
]
]
},
"759d4f88-c6de-4cee-af9a-628102d93200": {
"main": [
[
{
"node": "000229fb-153f-4db4-ad19-cda7b78f3b57",
"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?
Fortgeschritten - Ticketverwaltung, 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
Paul
@diagoplAutomation expert & n8n power user. I build advanced workflows combining AI, outbound, and business logic. Grab my templates or reach out for custom builds.
Diesen Workflow teilen