WORKFLOW · N8N
AI Email Auto-Responder (Ollama)
Productivity👁 6
WORKFLOW JSON
{
"name": "AI Email Auto-Responder (Ollama)",
"tags": [
{
"name": "AI"
},
{
"name": "Ollama"
},
{
"name": "Email"
},
{
"name": "Automation"
}
],
"nodes": [
{
"id": "schedule",
"name": "Check Every 5 Minutes",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
240,
300
],
"parameters": {
"rule": {
"interval": [
{
"field": "minutes",
"minutesInterval": 5
}
]
}
},
"typeVersion": 1.2
},
{
"id": "get-emails",
"name": "Get Unread Emails (IMAP)",
"type": "n8n-nodes-base.emailReadImap",
"position": [
460,
300
],
"parameters": {
"limit": 10,
"filters": {
"readStatus": "unread"
},
"operation": "getAll",
"returnAll": false
},
"credentials": {
"imap": {
"id": "REPLACE_WITH_YOUR_IMAP_CREDENTIAL_ID",
"name": "Your IMAP Account"
}
},
"typeVersion": 2
},
{
"id": "classify",
"name": "1. Classify Email (Ollama)",
"type": "n8n-nodes-base.httpRequest",
"position": [
680,
300
],
"parameters": {
"url": "http://localhost:11434/api/generate",
"options": {
"timeout": 60000
},
"jsonBody": "={{ JSON.stringify({ model: 'llama3:8b', prompt: 'Classify this email into one of these categories: URGENT, QUESTION, FEEDBACK, SPAM, OTHER.\\n\\nFrom: ' + $json.from + '\\nSubject: ' + $json.subject + '\\nBody: ' + ($json.text || '').substring(0, 1000) + '\\n\\nRespond with ONLY the category name, nothing else.', stream: false, options: { temperature: 0.1, num_predict: 20 } }) }}",
"sendBody": true,
"specifyBody": "json"
},
"typeVersion": 4.2
},
{
"id": "filter-spam",
"name": "Filter Spam",
"type": "n8n-nodes-base.filter",
"position": [
900,
300
],
"parameters": {
"conditions": {
"options": {
"caseSensitive": false
},
"combinator": "or",
"conditions": [
{
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ JSON.parse($json.data).response.trim() }}",
"rightValue": "SPAM"
}
]
}
},
"typeVersion": 2
},
{
"id": "draft-reply",
"name": "2. Draft Reply (Ollama)",
"type": "n8n-nodes-base.httpRequest",
"position": [
1120,
300
],
"parameters": {
"url": "http://localhost:11434/api/generate",
"options": {
"timeout": 120000
},
"jsonBody": "={{ JSON.stringify({ model: 'llama3:8b', prompt: 'Write a professional, helpful email reply to this message. Be concise and friendly.\\n\\nFrom: ' + $('Get Unread Emails (IMAP)').item.json.from + '\\nSubject: ' + $('Get Unread Emails (IMAP)').item.json.subject + '\\nBody: ' + ($('Get Unread Emails (IMAP)').item.json.text || '').substring(0, 2000) + '\\n\\nWrite ONLY the reply body (no subject line, no greeting format instructions). Sign off as the team.', stream: false, options: { temperature: 0.5, num_predict: 1000 } }) }}",
"sendBody": true,
"specifyBody": "json"
},
"typeVersion": 4.2
},
{
"id": "prepare-output",
"name": "Prepare Draft for Review",
"type": "n8n-nodes-base.set",
"position": [
1340,
300
],
"parameters": {
"assignments": {
"assignments": [
{
"id": "draft",
"name": "draft_reply",
"type": "string",
"value": "={{ JSON.parse($json.data).response }}"
},
{
"id": "original_from",
"name": "original_from",
"type": "string",
"value": "={{ $('Get Unread Emails (IMAP)').item.json.from }}"
},
{
"id": "original_subject",
"name": "original_subject",
"type": "string",
"value": "={{ 'Re: ' + $('Get Unread Emails (IMAP)').item.json.subject }}"
},
{
"id": "category",
"name": "category",
"type": "string",
"value": "={{ JSON.parse($('1. Classify Email (Ollama)').item.json.data).response.trim() }}"
}
]
}
},
"typeVersion": 3.4
}
],
"settings": {
"executionOrder": "v1"
},
"connections": {
"Filter Spam": {
"main": [
[
{
"node": "2. Draft Reply (Ollama)",
"type": "main",
"index": 0
}
]
]
},
"Check Every 5 Minutes": {
"main": [
[
{
"node": "Get Unread Emails (IMAP)",
"type": "main",
"index": 0
}
]
]
},
"2. Draft Reply (Ollama)": {
"main": [
[
{
"node": "Prepare Draft for Review",
"type": "main",
"index": 0
}
]
]
},
"Get Unread Emails (IMAP)": {
"main": [
[
{
"node": "1. Classify Email (Ollama)",
"type": "main",
"index": 0
}
]
]
},
"1. Classify Email (Ollama)": {
"main": [
[
{
"node": "Filter Spam",
"type": "main",
"index": 0
}
]
]
}
}
}RELATED WORKFLOWS
COMMENTS
No comments yet — be the first.
