Version all workflows at v1.0
This commit is contained in:
363
n8n-workflows/01-grafana-alert-ai-gotify-v1.0.json
Normal file
363
n8n-workflows/01-grafana-alert-ai-gotify-v1.0.json
Normal file
@@ -0,0 +1,363 @@
|
||||
{
|
||||
"updatedAt": "2026-05-07T03:32:35.930Z",
|
||||
"createdAt": "2026-05-07T03:32:32.026Z",
|
||||
"id": "GXtkp4xKka90XrXH",
|
||||
"name": "Grafana Alert \u2192 AI \u2192 Gotify v1.0",
|
||||
"description": null,
|
||||
"active": true,
|
||||
"isArchived": false,
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "grafana-alert",
|
||||
"options": {}
|
||||
},
|
||||
"id": "a6e7dfb1-8e9b-4048-b028-4383c30a7e0d",
|
||||
"name": "Grafana Webhook",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"webhookId": "0492788e-db4e-4d15-9572-9d6c3efc80c3"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "// Parse Grafana alert payload into a clean summary for the LLM\nconst alerts = $input.first().json.body?.alerts || $input.first().json.alerts || [];\n\nconst parsed = alerts.map(a => ({\n status: a.status || 'unknown',\n alertName: a.labels?.alertname || 'Unnamed Alert',\n host: a.labels?.host || a.labels?.instance || 'unknown host',\n severity: a.labels?.severity || 'warning',\n summary: a.annotations?.summary || '',\n description: a.annotations?.description || '',\n value: a.valueString || '',\n startsAt: a.startsAt || '',\n endsAt: a.endsAt || ''\n}));\n\nconst alertText = parsed.map(a => \n `[${a.status.toUpperCase()}] ${a.alertName} on ${a.host}\\nSeverity: ${a.severity}\\nSummary: ${a.summary}\\nDescription: ${a.description}\\nValue: ${a.value}\\nStarted: ${a.startsAt}`\n).join('\\n---\\n');\n\nreturn [{\n json: {\n alertText,\n alertCount: parsed.length,\n hasResolved: parsed.some(a => a.status === 'resolved'),\n hasFiring: parsed.some(a => a.status === 'firing'),\n parsed\n }\n}];"
|
||||
},
|
||||
"id": "ea216058-69db-42cc-88d0-8f67e1b8951b",
|
||||
"name": "Parse Alert Payload",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
224,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "http://10.5.1.6:4000/v1/chat/completions",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"name": "Authorization",
|
||||
"value": "Bearer sk-a95bd142d43d175b6476ebc862e81aa1f6ef34b1153f839698d07541d2f55308"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"specifyBody": "json",
|
||||
"jsonBody": "={{\n {\n \"model\": \"medium\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a concise homelab monitoring assistant. Summarize infrastructure alerts in 2-3 sentences. Include: what happened, which host, severity, and a suggested action. Keep it brief \u2014 this goes to a phone notification.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Summarize this Grafana alert:\\n\\n\" + $json.alertText\n }\n ],\n \"max_tokens\": 200,\n \"temperature\": 0.3\n }\n}}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "8ef1aa9d-d5b1-41ea-abc6-703b6491ea33",
|
||||
"name": "LiteLLM Summarize",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
1792,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const response = $input.first().json;\nconst summary = response.choices?.[0]?.message?.content || 'Could not generate summary';\nconst alertData = $('Parse Alert Payload').first().json;\n\nconst title = alertData.hasFiring \n ? `\ud83d\udd25 Alert Firing (${alertData.alertCount})` \n : `\u2705 Alert Resolved (${alertData.alertCount})`;\n\nconst priority = alertData.hasFiring ? 8 : 2;\n\nreturn [{\n json: {\n title,\n message: summary,\n priority\n }\n}];"
|
||||
},
|
||||
"id": "2e969bca-8458-4477-a358-664fd1c50c4f",
|
||||
"name": "Format Notification",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
2016,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"message": "={{ $json.message }}",
|
||||
"additionalFields": {
|
||||
"priority": "={{ $json.priority }}",
|
||||
"title": "={{ $json.title }}"
|
||||
},
|
||||
"options": {
|
||||
"contentType": "text/plain"
|
||||
}
|
||||
},
|
||||
"id": "65c2b53a-6e03-4460-9aa6-5d967d244de0",
|
||||
"name": "Push to Gotify",
|
||||
"type": "n8n-nodes-base.gotify",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
2224,
|
||||
0
|
||||
],
|
||||
"credentials": {
|
||||
"gotifyApi": {
|
||||
"id": "DXdYZDfVZecDTaNU",
|
||||
"name": "Gotify account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const parsed = $('Parse Alert Payload').first().json;\nconst now = new Date();\nconst hour = now.getHours();\nconst fingerprint = (parsed.parsed || [])\n .map(a => `${a.alertName}:${a.host}`)\n .sort().join('|') || 'unknown';\nreturn [{ json: { ...parsed, fingerprint, isNightTime: hour >= 0 && hour < 7 } }];\n"
|
||||
},
|
||||
"id": "df26d9ca-c72c-4dee-9327-14a0f5fcf3a0",
|
||||
"name": "Build Fingerprint",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
448,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "executeQuery",
|
||||
"query": "SELECT fingerprint, last_seen FROM grafana_alert_dedup WHERE fingerprint = '{{ $json.fingerprint }}' AND last_seen > NOW() - INTERVAL '30 minutes' LIMIT 1;",
|
||||
"options": {}
|
||||
},
|
||||
"id": "3fd78a53-7885-4739-a4b7-b441a27e993e",
|
||||
"name": "Lookup Dedup",
|
||||
"type": "n8n-nodes-base.postgres",
|
||||
"typeVersion": 2.5,
|
||||
"position": [
|
||||
672,
|
||||
0
|
||||
],
|
||||
"credentials": {
|
||||
"postgres": {
|
||||
"id": "n9svoXemqSZoNNUB",
|
||||
"name": "Postgres account"
|
||||
}
|
||||
},
|
||||
"continueOnFail": true
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const alertData = $('Build Fingerprint').first().json;\nconst rows = $input.all().filter(r => r.json && r.json.fingerprint);\nconst alreadySeen = rows.length > 0;\nconst isLowPriority = !alertData.hasFiring;\nconst suppressNight = alertData.isNightTime && isLowPriority;\nconst suppress = alreadySeen || suppressNight;\nreturn [{ json: { ...alertData, suppress, suppressReason: alreadySeen ? 'dedup' : suppressNight ? 'night_suppress' : null } }];\n"
|
||||
},
|
||||
"id": "c34b4b0e-1a47-4624-b1c4-9ef6b5cdeb6c",
|
||||
"name": "Check Should Notify",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
896,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"conditions": {
|
||||
"options": {
|
||||
"caseSensitive": true,
|
||||
"leftValue": "",
|
||||
"typeValidation": "strict"
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"id": "edee2fbd-0b2b-43bf-b542-9d9297d39d66",
|
||||
"leftValue": "={{ $json.suppress }}",
|
||||
"rightValue": false,
|
||||
"operator": {
|
||||
"type": "boolean",
|
||||
"operation": "equal"
|
||||
}
|
||||
}
|
||||
],
|
||||
"combinator": "and"
|
||||
}
|
||||
},
|
||||
"id": "29929dc8-17f6-4cc8-90c2-c501eaba8be5",
|
||||
"name": "Should Notify?",
|
||||
"type": "n8n-nodes-base.if",
|
||||
"typeVersion": 2.2,
|
||||
"position": [
|
||||
1120,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "executeQuery",
|
||||
"query": "INSERT INTO grafana_alert_dedup (fingerprint, last_seen, alert_name, host) VALUES ('{{ $json.fingerprint }}', NOW(), '{{ ($json.parsed && $json.parsed[0]) ? $json.parsed[0].alertName : \"unknown\" }}', '{{ ($json.parsed && $json.parsed[0]) ? $json.parsed[0].host : \"unknown\" }}') ON CONFLICT (fingerprint) DO UPDATE SET last_seen = NOW();",
|
||||
"options": {}
|
||||
},
|
||||
"id": "25a14a6a-db17-49ca-a6d2-6ed2f97d2889",
|
||||
"name": "Upsert Dedup Record",
|
||||
"type": "n8n-nodes-base.postgres",
|
||||
"typeVersion": 2.5,
|
||||
"position": [
|
||||
1344,
|
||||
0
|
||||
],
|
||||
"credentials": {
|
||||
"postgres": {
|
||||
"id": "n9svoXemqSZoNNUB",
|
||||
"name": "Postgres account"
|
||||
}
|
||||
},
|
||||
"continueOnFail": true
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"Grafana Webhook": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Parse Alert Payload",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Parse Alert Payload": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Build Fingerprint",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Build Fingerprint": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Lookup Dedup",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Lookup Dedup": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Check Should Notify",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Check Should Notify": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Should Notify?",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Should Notify?": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Upsert Dedup Record",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
[]
|
||||
]
|
||||
},
|
||||
"Upsert Dedup Record": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "LiteLLM Summarize",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"LiteLLM Summarize": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Format Notification",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format Notification": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Push to Gotify",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1",
|
||||
"binaryMode": "separate"
|
||||
},
|
||||
"staticData": null,
|
||||
"meta": {
|
||||
"templateCredsSetupCompleted": true
|
||||
},
|
||||
"pinData": {},
|
||||
"versionId": "ba3a4eab-60b8-4b1c-ac9f-07a0fdcec9c0",
|
||||
"activeVersionId": "ba3a4eab-60b8-4b1c-ac9f-07a0fdcec9c0",
|
||||
"versionCounter": 10,
|
||||
"triggerCount": 1,
|
||||
"tags": [
|
||||
{
|
||||
"updatedAt": "2026-05-06T22:38:51.678Z",
|
||||
"createdAt": "2026-05-06T22:38:51.678Z",
|
||||
"id": "S9FxzVfHLsHmyzyt",
|
||||
"name": "ai"
|
||||
},
|
||||
{
|
||||
"updatedAt": "2026-05-06T22:38:51.660Z",
|
||||
"createdAt": "2026-05-06T22:38:51.660Z",
|
||||
"id": "0ETpkL5jJ5wwgt8k",
|
||||
"name": "monitoring"
|
||||
}
|
||||
],
|
||||
"shared": [
|
||||
{
|
||||
"updatedAt": "2026-05-07T03:32:32.026Z",
|
||||
"createdAt": "2026-05-07T03:32:32.026Z",
|
||||
"role": "workflow:owner",
|
||||
"workflowId": "GXtkp4xKka90XrXH",
|
||||
"projectId": "dxCRnBdX5uJizCGa",
|
||||
"project": {
|
||||
"updatedAt": "2026-05-06T01:10:37.484Z",
|
||||
"createdAt": "2026-05-06T01:08:07.721Z",
|
||||
"id": "dxCRnBdX5uJizCGa",
|
||||
"name": "Wilfred Fizzlepoof <admin@paccoco.com>",
|
||||
"type": "personal",
|
||||
"icon": null,
|
||||
"description": null,
|
||||
"creatorId": "47b2227f-2fc2-4a08-bd35-ea157b92df0d"
|
||||
}
|
||||
}
|
||||
],
|
||||
"versionMetadata": {
|
||||
"name": "Version ba3a4eab",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
394
n8n-workflows/02-rag-ingest-and-query-v1.0.json
Normal file
394
n8n-workflows/02-rag-ingest-and-query-v1.0.json
Normal file
@@ -0,0 +1,394 @@
|
||||
{
|
||||
"updatedAt": "2026-05-06T23:25:33.293Z",
|
||||
"createdAt": "2026-05-06T23:25:29.005Z",
|
||||
"id": "gYyOggC4J98keLbj",
|
||||
"name": "RAG Pipeline v1.0",
|
||||
"description": null,
|
||||
"active": true,
|
||||
"isArchived": false,
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "rag/ingest",
|
||||
"responseMode": "lastNode",
|
||||
"responseData": "allEntries",
|
||||
"options": {}
|
||||
},
|
||||
"id": "31ce8413-d15c-490f-92d1-956ef214e9a3",
|
||||
"name": "Ingest Webhook",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"webhookId": "411ad4e3-eb9f-49e2-97c4-2f30e01dd609"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "// Split incoming text into chunks for embedding\nconst input = $input.first().json.body || $input.first().json;\nconst text = input.text || input.content || '';\nconst source = input.source || 'manual';\nconst metadata = input.metadata || {};\n\nconst CHUNK_SIZE = 500;\nconst OVERLAP = 50;\n\nconst chunks = [];\nconst sentences = text.split(/(?<=[.!?])\\s+/);\nlet current = '';\n\nfor (const sentence of sentences) {\n if ((current + ' ' + sentence).length > CHUNK_SIZE && current.length > 0) {\n chunks.push(current.trim());\n // Keep overlap\n const words = current.split(' ');\n current = words.slice(-OVERLAP).join(' ') + ' ' + sentence;\n } else {\n current = current ? current + ' ' + sentence : sentence;\n }\n}\nif (current.trim()) chunks.push(current.trim());\n\nreturn chunks.map((chunk, i) => ({\n json: {\n chunk,\n chunkIndex: i,\n totalChunks: chunks.length,\n source,\n metadata\n }\n}));"
|
||||
},
|
||||
"id": "5d5aa0b1-c84b-48f6-9b5e-618cb05e5e61",
|
||||
"name": "Chunk Text",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
224,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "http://10.5.1.6:11434/v1/embeddings",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"specifyBody": "json",
|
||||
"jsonBody": "={\n \"model\": \"nomic-embed-text\",\n \"input\": \"{{ $json.chunk }}\"\n}",
|
||||
"options": {
|
||||
"batching": {
|
||||
"batch": {
|
||||
"batchSize": 5,
|
||||
"batchInterval": 500
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"id": "89c692c6-b987-409c-b5c1-3533097d06e3",
|
||||
"name": "Get Embedding",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
448,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const embeddingResponse = $input.first().json;\nconst chunkData = $('Chunk Text').item;\nconst embedding = embeddingResponse.data?.[0]?.embedding || [];\n\nconst pointId = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => { const r = Math.random() * 16 | 0; return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16); });\n\nreturn [{\n json: {\n id: pointId,\n vector: embedding,\n payload: {\n text: chunkData.json.chunk,\n source: chunkData.json.source,\n chunkIndex: chunkData.json.chunkIndex,\n totalChunks: chunkData.json.totalChunks,\n metadata: chunkData.json.metadata,\n ingested_at: new Date().toISOString()\n }\n }\n}];"
|
||||
},
|
||||
"id": "fec59066-958f-4b96-8224-6f4e48ad5abb",
|
||||
"name": "Prepare Qdrant Point",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
672,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "PUT",
|
||||
"url": "http://10.5.1.6:6333/collections/knowledge_base/points",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"specifyBody": "json",
|
||||
"jsonBody": "={\n \"points\": [\n {\n \"id\": \"{{ $json.id }}\",\n \"vector\": {{ JSON.stringify($json.vector) }},\n \"payload\": {{ JSON.stringify($json.payload) }}\n }\n ]\n}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "9404c8fe-46ae-4d8a-bf35-35ecba4939c0",
|
||||
"name": "Upsert to Qdrant",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
880,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "rag/query",
|
||||
"responseMode": "lastNode",
|
||||
"responseData": "allEntries",
|
||||
"options": {}
|
||||
},
|
||||
"id": "1a5c921c-0351-4a5e-a3e4-0aab71313af1",
|
||||
"name": "Query Webhook",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
0,
|
||||
304
|
||||
],
|
||||
"webhookId": "aad4fe04-74b0-4136-80e9-380a7e4db1c2"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "http://10.5.1.6:11434/v1/embeddings",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"specifyBody": "json",
|
||||
"jsonBody": "={\n \"model\": \"nomic-embed-text\",\n \"input\": \"{{ $json.body.query || $json.query }}\"\n}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "0a294ba5-a890-4dfa-8ae7-ba25cd0a4534",
|
||||
"name": "Embed Query",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
224,
|
||||
304
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "http://10.5.1.6:6333/collections/knowledge_base/points/search",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"specifyBody": "json",
|
||||
"jsonBody": "={\n \"vector\": {{ JSON.stringify($json.data[0].embedding) }},\n \"limit\": 5,\n \"with_payload\": true\n}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "2cb68891-c57e-4006-b3ac-c290aec28220",
|
||||
"name": "Search Qdrant",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
448,
|
||||
304
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const searchResults = $input.first().json.result || [];\nconst query = $('Query Webhook').first().json.body?.query || $('Query Webhook').first().json.query || '';\n\nconst context = searchResults.map((r, i) => \n `[${i+1}] (score: ${r.score.toFixed(3)}) ${r.payload.text}`\n).join('\\n\\n');\n\nreturn [{\n json: {\n query,\n context,\n sources: searchResults.map(r => ({\n source: r.payload.source,\n score: r.score,\n text_preview: r.payload.text.substring(0, 100) + '...'\n }))\n }\n}];"
|
||||
},
|
||||
"id": "d32ee814-81d0-4ea6-8f28-59632d09b1b9",
|
||||
"name": "Build Context",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
672,
|
||||
304
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "http://10.5.1.6:4000/v1/chat/completions",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"name": "Authorization",
|
||||
"value": "Bearer sk-a95bd142d43d175b6476ebc862e81aa1f6ef34b1153f839698d07541d2f55308"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"specifyBody": "json",
|
||||
"jsonBody": "={\n \"model\": \"medium\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a helpful knowledge base assistant. Answer the user's question using ONLY the provided context. If the context doesn't contain enough information, say so. Cite which source numbers you used.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Context:\\n{{ $json.context }}\\n\\nQuestion: {{ $json.query }}\"\n }\n ],\n \"max_tokens\": 500,\n \"temperature\": 0.2\n}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "e1360454-8457-40ce-b179-670c182da59e",
|
||||
"name": "LiteLLM Answer",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
880,
|
||||
304
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const response = $input.first().json;\nconst contextData = $('Build Context').first().json;\n\nreturn [{\n json: {\n answer: response.choices?.[0]?.message?.content || 'No answer generated',\n sources: contextData.sources,\n query: contextData.query\n }\n}];"
|
||||
},
|
||||
"id": "fe16d3a1-0d11-442f-b941-56fb74804601",
|
||||
"name": "Format Response",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1104,
|
||||
304
|
||||
]
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"Ingest Webhook": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Chunk Text",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Chunk Text": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Get Embedding",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Get Embedding": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Prepare Qdrant Point",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Prepare Qdrant Point": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Upsert to Qdrant",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Query Webhook": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Embed Query",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Embed Query": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Search Qdrant",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Search Qdrant": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Build Context",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Build Context": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "LiteLLM Answer",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"LiteLLM Answer": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Format Response",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1",
|
||||
"binaryMode": "separate"
|
||||
},
|
||||
"staticData": null,
|
||||
"meta": null,
|
||||
"pinData": {},
|
||||
"versionId": "832248e5-106e-4fc4-8ebd-a5d0034e2b14",
|
||||
"activeVersionId": "832248e5-106e-4fc4-8ebd-a5d0034e2b14",
|
||||
"versionCounter": 14,
|
||||
"triggerCount": 2,
|
||||
"tags": [
|
||||
{
|
||||
"updatedAt": "2026-05-06T22:38:51.678Z",
|
||||
"createdAt": "2026-05-06T22:38:51.678Z",
|
||||
"id": "S9FxzVfHLsHmyzyt",
|
||||
"name": "ai"
|
||||
},
|
||||
{
|
||||
"updatedAt": "2026-05-06T22:39:33.284Z",
|
||||
"createdAt": "2026-05-06T22:39:33.284Z",
|
||||
"id": "7uuEyQrIlcuruZBk",
|
||||
"name": "rag"
|
||||
}
|
||||
],
|
||||
"shared": [
|
||||
{
|
||||
"updatedAt": "2026-05-06T23:25:29.005Z",
|
||||
"createdAt": "2026-05-06T23:25:29.005Z",
|
||||
"role": "workflow:owner",
|
||||
"workflowId": "gYyOggC4J98keLbj",
|
||||
"projectId": "dxCRnBdX5uJizCGa",
|
||||
"project": {
|
||||
"updatedAt": "2026-05-06T01:10:37.484Z",
|
||||
"createdAt": "2026-05-06T01:08:07.721Z",
|
||||
"id": "dxCRnBdX5uJizCGa",
|
||||
"name": "Wilfred Fizzlepoof <admin@paccoco.com>",
|
||||
"type": "personal",
|
||||
"icon": null,
|
||||
"description": null,
|
||||
"creatorId": "47b2227f-2fc2-4a08-bd35-ea157b92df0d"
|
||||
}
|
||||
}
|
||||
],
|
||||
"versionMetadata": {
|
||||
"name": "Version 832248e5",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
348
n8n-workflows/03-paperless-ai-processing-v1.0.json
Normal file
348
n8n-workflows/03-paperless-ai-processing-v1.0.json
Normal file
@@ -0,0 +1,348 @@
|
||||
{
|
||||
"updatedAt": "2026-05-07T20:24:47.896Z",
|
||||
"createdAt": "2026-05-07T20:24:40.153Z",
|
||||
"id": "dQ1d5deV4mF0s5eP",
|
||||
"name": "Paperless AI Processing v1.0",
|
||||
"description": null,
|
||||
"active": true,
|
||||
"isArchived": false,
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "paperless/new-document",
|
||||
"options": {}
|
||||
},
|
||||
"id": "3d8bc021-e27f-4f7b-b716-a202d66551be",
|
||||
"name": "Paperless Webhook",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"webhookId": "fd1eaa3a-fbf1-4a17-94fd-bb483df602b7"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "// Extract document ID from whatever Paperless sends\nconst data = $input.first().json;\nconst body = data.body || data;\n\n// Try multiple possible field names and formats\nlet docId = body.document_id || body.id || body.doc_id || body.pk;\n\n// If it's a string like '{document_id}' (template not resolved), fall back to latest doc\nif (!docId || typeof docId === 'string' && docId.includes('{')) {\n docId = null;\n}\n\nreturn [{ json: { docId } }];"
|
||||
},
|
||||
"id": "48277e9e-a835-4e12-8608-63e905abe74d",
|
||||
"name": "Extract Document ID",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
224,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"url": "=https://paperless.paccoco.com/api/documents/{{ $json.docId ? $json.docId + '/' : '?ordering=-added&page_size=1' }}",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Authorization",
|
||||
"value": "Token 4fb34ba35b4ab76a0715e8c56faf00a31de4fb5d"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "17ed7e6f-ccaa-43d3-9031-9f3d2bb12dec",
|
||||
"name": "Fetch Document",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
448,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const response = $input.first().json;\n\n// Handle both single doc response and list response\nconst doc = response.results ? response.results[0] : response;\n\nif (!doc || !doc.id) {\n throw new Error('No document found in response');\n}\n\n// Content is already in the metadata from Paperless OCR\nconst content = (doc.content || '').substring(0, 4000);\n\nreturn [{\n json: {\n documentId: doc.id,\n title: doc.title || 'Untitled',\n originalFilename: doc.original_file_name || '',\n correspondent: doc.correspondent_name || null,\n content: content,\n created: doc.created || new Date().toISOString()\n }\n}];"
|
||||
},
|
||||
"id": "3a026b3b-141b-48b4-a9ae-03998914f45c",
|
||||
"name": "Prepare Content",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
672,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "http://10.5.1.6:4000/v1/chat/completions",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"name": "Authorization",
|
||||
"value": "Bearer sk-a95bd142d43d175b6476ebc862e81aa1f6ef34b1153f839698d07541d2f55308"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"specifyBody": "json",
|
||||
"jsonBody": "={\n \"model\": \"medium\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a document classification assistant. Analyze the document and return ONLY valid JSON. Do not include markdown. Do not include code fences.\\n\\nReturn this exact JSON structure:\\n{\\n \\\"summary\\\": \\\"short 1-2 sentence summary with no sensitive identifiers\\\",\\n \\\"doc_type\\\": \\\"invoice | receipt | letter | contract | manual | report | medical | tax | military | other\\\",\\n \\\"suggested_tags\\\": [\\\"tag1\\\", \\\"tag2\\\", \\\"tag3\\\"]\\n}\\n\\nIf the document is sensitive, summarize only generally and say sensitive personal identifiers were present and redacted. If the document is not sensitive, provide a normal 1-2 sentence summary. Never mention or summarize sensitive field categories such as SSNs, dates of birth, addresses, phone numbers, financial amounts, ID numbers, service numbers, or exact dates.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"{{ JSON.stringify('Document title: ' + ($json.title || 'Untitled') + '\\nFilename: ' + ($json.originalFilename || '') + '\\nCorrespondent: ' + ($json.correspondent || 'Unknown') + '\\n\\nContent:\\n' + ($json.content || '')).slice(1, -1) }}\"\n }\n ],\n \"max_tokens\": 350,\n \"temperature\": 0.1,\n \"response_format\": {\n \"type\": \"json_object\"\n }\n}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "51374897-d90e-49a2-889e-0476817dd9d8",
|
||||
"name": "AI Classify & Extract",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
880,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const response = $input.first().json;\nconst docData = $('Prepare Content').first().json;\n\nconst raw = response.choices?.[0]?.message?.content || '{}';\nlet analysis;\n\ntry {\n analysis = JSON.parse(raw);\n} catch (e) {\n analysis = {\n summary: 'Document processed, but AI response could not be parsed cleanly. Sensitive details were not included.',\n doc_type: 'other',\n suggested_tags: []\n };\n}\n\nfunction cleanText(value) {\n return String(value || '')\n .replace(/\\b\\d{3}[- ]?\\d{2}[- ]?\\d{4}\\b/g, '[REDACTED_SSN]')\n .replace(/\\b\\d{8}\\b/g, '[REDACTED_DATE]')\n .replace(/\\b\\d{1,5}\\s+[A-Za-z0-9 .'-]+\\s+(Road|RD|Street|St|Avenue|Ave|Drive|Dr|Lane|Ln|Court|Ct|Branch|Blvd|Boulevard)\\b[^,\\n]*/gi, '[REDACTED_ADDRESS]')\n .replace(/\\b\\d{5}(?:-\\d{4})?\\b/g, '[REDACTED_ZIP]');\n}\n\nconst tags = Array.isArray(analysis.suggested_tags)\n ? analysis.suggested_tags\n .map(t => cleanText(t).trim().toLowerCase())\n .filter(Boolean)\n .map(t => t.replace(/[^a-z0-9 _-]/gi, '').trim())\n .filter(Boolean)\n .slice(0, 5)\n : [];\n\nreturn [\n {\n json: {\n documentId: docData.documentId,\n title: cleanText(docData.title || 'Untitled'),\n summary: cleanText(analysis.summary || 'Document processed.'),\n doc_type: cleanText(analysis.doc_type || 'other').toLowerCase(),\n suggested_tags: tags\n }\n }\n];"
|
||||
},
|
||||
"id": "1f37f096-132b-43b4-bcb4-f5ed094bc9e5",
|
||||
"name": "Parse Analysis",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1104,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "=https://paperless.paccoco.com/api/documents/{{ $json.documentId }}/notes/",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Authorization",
|
||||
"value": "Token 4fb34ba35b4ab76a0715e8c56faf00a31de4fb5d"
|
||||
},
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"specifyBody": "json",
|
||||
"jsonBody": "={\n \"note\": \"{{ JSON.stringify('**AI Analysis**\\nType: ' + ($json.doc_type || 'other') + '\\nSummary: ' + ($json.summary || '') + '\\nSuggested tags: ' + (($json.suggested_tags || []).join(', '))).slice(1, -1) }}\"\n}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "5597c8c1-436e-4373-bb54-0180be4e7bca",
|
||||
"name": "Add Note to Document",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
1328,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const data = $input.first().json;\n\nconst tags = Array.isArray(data.suggested_tags)\n ? data.suggested_tags.join(', ')\n : 'None';\n\nconst message = [\n data.title || 'Untitled',\n '',\n `Type: ${data.doc_type || 'other'}`,\n '',\n `Summary: ${data.summary || 'No summary returned'}`,\n '',\n `Suggested tags: ${tags || 'None'}`\n].join('\\n');\n\nreturn [{\n json: {\n title: '\ud83d\udcc4 New Document Processed',\n message,\n priority: 4\n }\n}];"
|
||||
},
|
||||
"id": "c3319471-e3f1-4cd3-aae1-c794f081b1e3",
|
||||
"name": "Format Gotify Document Message",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1328,
|
||||
208
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"message": "={{ $json.message }}",
|
||||
"additionalFields": {
|
||||
"priority": "={{ $json.priority }}",
|
||||
"title": "={{ $json.title }}"
|
||||
},
|
||||
"options": {
|
||||
"contentType": "text/plain"
|
||||
}
|
||||
},
|
||||
"id": "193f19dc-2ad6-41af-bd29-a0f5dc0ef1a0",
|
||||
"name": "Send Gotify Message",
|
||||
"type": "n8n-nodes-base.gotify",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1552,
|
||||
208
|
||||
],
|
||||
"credentials": {
|
||||
"gotifyApi": {
|
||||
"id": "ajvRjvj0QldLQYmo",
|
||||
"name": "Paperless"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const data = $input.first().json;\n\nconst PAPERLESS_BASE_URL = 'https://paperless.paccoco.com';\nconst PAPERLESS_TOKEN = '4fb34ba35b4ab76a0715e8c56faf00a31de4fb5d';\n\nconst headers = {\n Authorization: `Token ${PAPERLESS_TOKEN}`,\n 'Content-Type': 'application/json',\n};\n\nfunction normalizeTagName(tag) {\n return String(tag || '')\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9 _-]/gi, '')\n .replace(/\\s+/g, ' ')\n .slice(0, 64);\n}\n\nconst suggestedTags = Array.isArray(data.suggested_tags)\n ? [...new Set(data.suggested_tags.map(normalizeTagName).filter(Boolean))].slice(0, 5)\n : [];\n\nif (!data.documentId) {\n throw new Error('No documentId found; cannot apply tags.');\n}\n\nif (suggestedTags.length === 0) {\n return [{\n json: {\n ...data,\n tag_apply_status: 'skipped_no_suggested_tags',\n applied_tag_names: [],\n applied_tag_ids: []\n }\n }];\n}\n\nasync function request(method, url, body) {\n const options = {\n method,\n url,\n headers,\n json: true,\n };\n\n if (body !== undefined) {\n options.body = body;\n }\n\n return await this.helpers.httpRequest(options);\n}\n\n// Fetch all existing tags. Handles pagination.\nconst existingTags = [];\nlet tagsUrl = `${PAPERLESS_BASE_URL}/api/tags/?page_size=100`;\n\nwhile (tagsUrl) {\n const page = await request.call(this, 'GET', tagsUrl);\n const results = Array.isArray(page.results) ? page.results : (Array.isArray(page) ? page : []);\n existingTags.push(...results);\n\n if (page.next) {\n tagsUrl = page.next.startsWith('http') ? page.next : `${PAPERLESS_BASE_URL}${page.next}`;\n } else {\n tagsUrl = null;\n }\n}\n\nconst tagsByName = new Map(\n existingTags.map(tag => [normalizeTagName(tag.name), tag])\n);\n\nconst appliedTags = [];\n\nfor (const tagName of suggestedTags) {\n let tag = tagsByName.get(tagName);\n\n if (!tag) {\n tag = await request.call(this, 'POST', `${PAPERLESS_BASE_URL}/api/tags/`, {\n name: tagName,\n });\n tagsByName.set(tagName, tag);\n }\n\n if (tag?.id) {\n appliedTags.push(tag);\n }\n}\n\n// Fetch current document so we merge tags instead of overwriting existing ones.\nconst doc = await request.call(this, 'GET', `${PAPERLESS_BASE_URL}/api/documents/${data.documentId}/`);\nconst currentTagIds = Array.isArray(doc.tags) ? doc.tags : [];\nconst appliedTagIds = appliedTags.map(tag => tag.id);\nconst mergedTagIds = [...new Set([...currentTagIds, ...appliedTagIds])];\n\nawait request.call(this, 'PATCH', `${PAPERLESS_BASE_URL}/api/documents/${data.documentId}/`, {\n tags: mergedTagIds,\n});\n\nreturn [{\n json: {\n ...data,\n tag_apply_status: 'updated',\n applied_tag_names: appliedTags.map(tag => tag.name),\n applied_tag_ids: appliedTagIds,\n final_tag_ids: mergedTagIds,\n }\n}];"
|
||||
},
|
||||
"id": "b0d5423b-dc83-4adf-98c6-d95afa3e5c1b",
|
||||
"name": "Apply Suggested Tags to Paperless",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1328,
|
||||
400
|
||||
]
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"Paperless Webhook": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Extract Document ID",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Extract Document ID": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Fetch Document",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Fetch Document": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Prepare Content",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Prepare Content": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "AI Classify & Extract",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"AI Classify & Extract": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Parse Analysis",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Parse Analysis": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Add Note to Document",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Format Gotify Document Message",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Apply Suggested Tags to Paperless",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format Gotify Document Message": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Send Gotify Message",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1",
|
||||
"binaryMode": "separate"
|
||||
},
|
||||
"staticData": null,
|
||||
"meta": {
|
||||
"templateCredsSetupCompleted": true
|
||||
},
|
||||
"pinData": {},
|
||||
"versionId": "199d2609-e3e7-46aa-b144-df038eb10a0d",
|
||||
"activeVersionId": "199d2609-e3e7-46aa-b144-df038eb10a0d",
|
||||
"versionCounter": 11,
|
||||
"triggerCount": 1,
|
||||
"tags": [
|
||||
{
|
||||
"updatedAt": "2026-05-06T22:39:46.433Z",
|
||||
"createdAt": "2026-05-06T22:39:46.433Z",
|
||||
"id": "dZUptsMy60GbLHft",
|
||||
"name": "documents"
|
||||
},
|
||||
{
|
||||
"updatedAt": "2026-05-06T22:38:51.678Z",
|
||||
"createdAt": "2026-05-06T22:38:51.678Z",
|
||||
"id": "S9FxzVfHLsHmyzyt",
|
||||
"name": "ai"
|
||||
},
|
||||
{
|
||||
"updatedAt": "2026-05-06T22:39:46.476Z",
|
||||
"createdAt": "2026-05-06T22:39:46.476Z",
|
||||
"id": "NxHjuO4MMd5kdPR7",
|
||||
"name": "paperless"
|
||||
}
|
||||
],
|
||||
"shared": [
|
||||
{
|
||||
"updatedAt": "2026-05-07T20:24:40.153Z",
|
||||
"createdAt": "2026-05-07T20:24:40.153Z",
|
||||
"role": "workflow:owner",
|
||||
"workflowId": "dQ1d5deV4mF0s5eP",
|
||||
"projectId": "dxCRnBdX5uJizCGa",
|
||||
"project": {
|
||||
"updatedAt": "2026-05-06T01:10:37.484Z",
|
||||
"createdAt": "2026-05-06T01:08:07.721Z",
|
||||
"id": "dxCRnBdX5uJizCGa",
|
||||
"name": "Wilfred Fizzlepoof <admin@paccoco.com>",
|
||||
"type": "personal",
|
||||
"icon": null,
|
||||
"description": null,
|
||||
"creatorId": "47b2227f-2fc2-4a08-bd35-ea157b92df0d"
|
||||
}
|
||||
}
|
||||
],
|
||||
"versionMetadata": {
|
||||
"name": "Version 199d2609",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
589
n8n-workflows/04-whisper-transcription-v1.0.json
Normal file
589
n8n-workflows/04-whisper-transcription-v1.0.json
Normal file
@@ -0,0 +1,589 @@
|
||||
{
|
||||
"updatedAt": "2026-05-06T23:30:36.237Z",
|
||||
"createdAt": "2026-05-06T23:30:36.237Z",
|
||||
"id": "QEVnqyN4h5kcpVuJ",
|
||||
"name": "Whisper Transcription v1.0",
|
||||
"description": null,
|
||||
"active": true,
|
||||
"isArchived": false,
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "transcribe",
|
||||
"responseMode": "lastNode",
|
||||
"responseData": "allEntries",
|
||||
"options": {
|
||||
"rawBody": true
|
||||
}
|
||||
},
|
||||
"id": "91945dd9-42f8-4343-b131-9e46272f04bf",
|
||||
"name": "Transcription Webhook",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"webhookId": "f50eec94-1e56-4189-88ee-51b701c1d889"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "http://10.5.1.6:8786/v1/audio/transcriptions",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Accept",
|
||||
"value": "application/json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"contentType": "multipart-form-data",
|
||||
"bodyParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"parameterType": "formBinaryData",
|
||||
"name": "file",
|
||||
"inputDataFieldName": "data"
|
||||
},
|
||||
{
|
||||
"name": "model",
|
||||
"value": "Systran/faster-whisper-large-v3"
|
||||
},
|
||||
{
|
||||
"name": "language",
|
||||
"value": "en"
|
||||
},
|
||||
{
|
||||
"name": "response_format",
|
||||
"value": "verbose_json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "fc726196-f62d-4ff4-9be6-a84b9dbfff9e",
|
||||
"name": "Whisper Transcribe",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
224,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const result = $input.first().json;\n\nconst segments = result.segments || [];\nconst fullText = result.text || segments.map(s => s.text).join(' ');\nconst duration = result.duration || segments[segments.length - 1]?.end || 0;\n\n// Format timestamps\nconst timestamped = segments.map(s => {\n const start = new Date(s.start * 1000).toISOString().substr(11, 8);\n return `[${start}] ${s.text.trim()}`;\n}).join('\\n');\n\nreturn [{\n json: {\n text: fullText.trim(),\n timestamped_text: timestamped,\n duration_seconds: Math.round(duration),\n segment_count: segments.length,\n language: result.language || 'en'\n }\n}];"
|
||||
},
|
||||
"id": "1b6f017f-849d-456f-9e4b-a0bced1d8e9f",
|
||||
"name": "Format Transcript",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
448,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "transcribe/summarize",
|
||||
"responseMode": "lastNode",
|
||||
"responseData": "allEntries",
|
||||
"options": {
|
||||
"rawBody": true
|
||||
}
|
||||
},
|
||||
"id": "c2f8a2dd-cbbc-4b62-ae24-0f4a95bdf862",
|
||||
"name": "Transcribe + Summarize Webhook",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
0,
|
||||
304
|
||||
],
|
||||
"webhookId": "69b4b2e8-9486-4aa3-b9db-fb8e6bdae98e"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "http://10.5.1.6:8786/v1/audio/transcriptions",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Accept",
|
||||
"value": "application/json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"contentType": "multipart-form-data",
|
||||
"bodyParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"parameterType": "formBinaryData",
|
||||
"name": "file",
|
||||
"inputDataFieldName": "data"
|
||||
},
|
||||
{
|
||||
"name": "model",
|
||||
"value": "Systran/faster-whisper-large-v3"
|
||||
},
|
||||
{
|
||||
"name": "language",
|
||||
"value": "en"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "ee25bf40-99ef-472b-928d-6ef63516094c",
|
||||
"name": "Whisper Transcribe 2",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
224,
|
||||
304
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "http://10.5.1.6:4000/v1/chat/completions",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"name": "Authorization",
|
||||
"value": "Bearer sk-a95bd142d43d175b6476ebc862e81aa1f6ef34b1153f839698d07541d2f55308"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"specifyBody": "json",
|
||||
"jsonBody": "={\n \"model\": \"medium\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a meeting/audio note summarizer. Given a transcription, provide:\\n1. A brief summary (2-3 sentences)\\n2. Key points as a bullet list\\n3. Any action items mentioned\\n\\nRespond in JSON with keys: summary, key_points (array), action_items (array)\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Summarize this transcription:\\n\\n{{ $json.text }}\"\n }\n ],\n \"max_tokens\": 500,\n \"temperature\": 0.2,\n \"response_format\": { \"type\": \"json_object\" }\n}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "eda24425-dc26-4b4b-858e-9ae0d5e1a5e4",
|
||||
"name": "AI Summarize Audio",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
448,
|
||||
304
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const llmResponse = $input.first().json;\nconst transcript = $('Whisper Transcribe 2').first().json;\nlet analysis;\n\ntry {\n analysis = JSON.parse(llmResponse.choices?.[0]?.message?.content || '{}');\n} catch(e) {\n analysis = { summary: llmResponse.choices?.[0]?.message?.content || 'Summary failed', key_points: [], action_items: [] };\n}\n\nreturn [{\n json: {\n transcript: transcript.text || '',\n duration_seconds: Math.round(transcript.duration || 0),\n language: transcript.language || 'en',\n summary: analysis.summary,\n key_points: analysis.key_points || [],\n action_items: analysis.action_items || []\n }\n}];"
|
||||
},
|
||||
"id": "cf41669b-8bf7-433b-b390-10765954b0a9",
|
||||
"name": "Format Summary Response",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
672,
|
||||
304
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const t = $input.first().json;\nconst mins = Math.floor(t.duration_seconds / 60);\nconst secs = t.duration_seconds % 60;\nreturn [{ json: {\n title: '\ud83c\udf99\ufe0f Transcription Complete',\n message: `Duration: ${mins}m ${secs}s \u00b7 ${t.segment_count} segments \u00b7 Language: ${t.language}`,\n priority: 3\n}}];\n"
|
||||
},
|
||||
"id": "5c692355-2a46-4c66-860a-c02a21c73597",
|
||||
"name": "Format Transcription Notify",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
672,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"message": "={{ $json.message }}",
|
||||
"additionalFields": {
|
||||
"priority": "={{ $json.priority }}",
|
||||
"title": "={{ $json.title }}"
|
||||
},
|
||||
"options": {
|
||||
"contentType": "text/plain"
|
||||
}
|
||||
},
|
||||
"id": "0e96240d-50e2-49f7-be62-4f57451e0543",
|
||||
"name": "Notify Transcription Done",
|
||||
"type": "n8n-nodes-base.gotify",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
896,
|
||||
0
|
||||
],
|
||||
"credentials": {
|
||||
"gotifyApi": {
|
||||
"id": "SETUP_REQUIRED",
|
||||
"name": "Whisper"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const t = $('Format Transcript').first().json;\nconst title = `Transcript ${new Date().toLocaleDateString('en-US')}`;\nconst content = `Transcript\\nDate: ${new Date().toISOString()}\\nDuration: ${t.duration_seconds}s\\nLanguage: ${t.language}\\n\\n${t.timestamped_text || t.text}`;\nreturn [{ binary: { document: { data: Buffer.from(content,'utf-8').toString('base64'), mimeType:'text/plain', fileName: `${title}.txt` }}, json: { title } }];\n"
|
||||
},
|
||||
"id": "da9f4d8d-8c5b-413a-badd-71287dbe0a3c",
|
||||
"name": "Prepare Transcript Doc",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1120,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "https://paperless.paccoco.com/api/documents/post_document/",
|
||||
"options": {},
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Authorization",
|
||||
"value": "Bearer ${PAPERLESS_API_TOKEN}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"contentType": "multipart-form-data",
|
||||
"bodyParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "document",
|
||||
"value": "data",
|
||||
"parameterType": "formBinaryData"
|
||||
},
|
||||
{
|
||||
"name": "title",
|
||||
"value": "={{ $json.title }}"
|
||||
},
|
||||
{
|
||||
"name": "tags[]",
|
||||
"value": "${PAPERLESS_TAG_TRANSCRIPTION}"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"id": "7c84da5a-41e2-4b38-9e58-19acfd73f81d",
|
||||
"name": "Save Transcript to Paperless",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
1344,
|
||||
0
|
||||
],
|
||||
"continueOnFail": true
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const s = $input.first().json;\nconst mins = Math.floor(s.duration_seconds / 60);\nconst points = (s.key_points || []).slice(0,3).map((p,i) => `${i+1}. ${p}`).join('\\n');\nreturn [{ json: {\n title: '\ud83c\udf99\ufe0f Transcription + Summary Complete',\n message: `${mins}m audio\\n\\nSummary: ${s.summary}\\n\\nKey points:\\n${points}`,\n priority: 4\n}}];\n"
|
||||
},
|
||||
"id": "e55363e4-ff9b-4df4-b40a-fd23227c23e8",
|
||||
"name": "Format Summary Notify",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
896,
|
||||
304
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"message": "={{ $json.message }}",
|
||||
"additionalFields": {
|
||||
"priority": "={{ $json.priority }}",
|
||||
"title": "={{ $json.title }}"
|
||||
},
|
||||
"options": {
|
||||
"contentType": "text/plain"
|
||||
}
|
||||
},
|
||||
"id": "b5defea9-35a0-4a22-8769-ed9496a022f6",
|
||||
"name": "Notify Summary Done",
|
||||
"type": "n8n-nodes-base.gotify",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1120,
|
||||
304
|
||||
],
|
||||
"credentials": {
|
||||
"gotifyApi": {
|
||||
"id": "SETUP_REQUIRED",
|
||||
"name": "Whisper"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const s = $('Format Summary Response').first().json;\nconst title = `Audio Summary ${new Date().toLocaleDateString('en-US')}`;\nconst points = (s.key_points || []).map((p,i) => `${i+1}. ${p}`).join('\\n');\nconst actions = (s.action_items || []).map((a,i) => `${i+1}. ${a}`).join('\\n');\nconst content = [\n `Audio Transcription & Summary`, `Date: ${new Date().toISOString()}`,\n `Duration: ${Math.floor(s.duration_seconds/60)}m ${s.duration_seconds%60}s`,\n `Language: ${s.language}`, '', `Summary`, `=======`, s.summary,\n '', `Key Points`, `==========`, points,\n ...(actions ? ['', `Action Items`, `============`, actions] : []),\n '', `Full Transcript`, `==============`, s.transcript\n].join('\\n');\nreturn [{ binary: { document: { data: Buffer.from(content,'utf-8').toString('base64'), mimeType:'text/plain', fileName:`${title}.txt` }}, json: { title } }];\n"
|
||||
},
|
||||
"id": "1f31f608-7985-4a9a-afcf-6cf4e44150ba",
|
||||
"name": "Prepare Summary Doc",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1344,
|
||||
304
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "https://paperless.paccoco.com/api/documents/post_document/",
|
||||
"options": {},
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Authorization",
|
||||
"value": "Bearer ${PAPERLESS_API_TOKEN}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"contentType": "multipart-form-data",
|
||||
"bodyParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "document",
|
||||
"value": "data",
|
||||
"parameterType": "formBinaryData"
|
||||
},
|
||||
{
|
||||
"name": "title",
|
||||
"value": "={{ $json.title }}"
|
||||
},
|
||||
{
|
||||
"name": "tags[]",
|
||||
"value": "${PAPERLESS_TAG_TRANSCRIPTION}"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"id": "e9eaee2f-d08e-4a76-af53-ed824ebfe68f",
|
||||
"name": "Save Summary to Paperless",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
1568,
|
||||
304
|
||||
],
|
||||
"continueOnFail": true
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"Transcription Webhook": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Whisper Transcribe",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Whisper Transcribe": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Format Transcript",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Transcribe + Summarize Webhook": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Whisper Transcribe 2",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Whisper Transcribe 2": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "AI Summarize Audio",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"AI Summarize Audio": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Format Summary Response",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format Transcript": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Format Transcription Notify",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format Transcription Notify": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Notify Transcription Done",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Notify Transcription Done": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Prepare Transcript Doc",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Prepare Transcript Doc": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Save Transcript to Paperless",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format Summary Response": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Format Summary Notify",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format Summary Notify": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Notify Summary Done",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Notify Summary Done": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Prepare Summary Doc",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Prepare Summary Doc": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Save Summary to Paperless",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1",
|
||||
"binaryMode": "separate"
|
||||
},
|
||||
"staticData": null,
|
||||
"meta": null,
|
||||
"pinData": {},
|
||||
"versionId": "20275daf-b924-4311-9a7f-116a99911764",
|
||||
"activeVersionId": "20275daf-b924-4311-9a7f-116a99911764",
|
||||
"versionCounter": 12,
|
||||
"triggerCount": 2,
|
||||
"tags": [
|
||||
{
|
||||
"updatedAt": "2026-05-06T22:39:59.719Z",
|
||||
"createdAt": "2026-05-06T22:39:59.719Z",
|
||||
"id": "GLLrEIR8I7eA4ydv",
|
||||
"name": "transcription"
|
||||
},
|
||||
{
|
||||
"updatedAt": "2026-05-06T22:39:59.716Z",
|
||||
"createdAt": "2026-05-06T22:39:59.716Z",
|
||||
"id": "tuPxDoKFqpVrrQoX",
|
||||
"name": "whisper"
|
||||
},
|
||||
{
|
||||
"updatedAt": "2026-05-06T22:38:51.678Z",
|
||||
"createdAt": "2026-05-06T22:38:51.678Z",
|
||||
"id": "S9FxzVfHLsHmyzyt",
|
||||
"name": "ai"
|
||||
}
|
||||
],
|
||||
"shared": [
|
||||
{
|
||||
"updatedAt": "2026-05-06T23:30:36.237Z",
|
||||
"createdAt": "2026-05-06T23:30:36.237Z",
|
||||
"role": "workflow:owner",
|
||||
"workflowId": "QEVnqyN4h5kcpVuJ",
|
||||
"projectId": "dxCRnBdX5uJizCGa",
|
||||
"project": {
|
||||
"updatedAt": "2026-05-06T01:10:37.484Z",
|
||||
"createdAt": "2026-05-06T01:08:07.721Z",
|
||||
"id": "dxCRnBdX5uJizCGa",
|
||||
"name": "Wilfred Fizzlepoof <admin@paccoco.com>",
|
||||
"type": "personal",
|
||||
"icon": null,
|
||||
"description": null,
|
||||
"creatorId": "47b2227f-2fc2-4a08-bd35-ea157b92df0d"
|
||||
}
|
||||
}
|
||||
],
|
||||
"versionMetadata": {
|
||||
"name": "Version 20275daf",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
357
n8n-workflows/05-paperless-to-rag-v1.0.json
Normal file
357
n8n-workflows/05-paperless-to-rag-v1.0.json
Normal file
@@ -0,0 +1,357 @@
|
||||
{
|
||||
"updatedAt": "2026-05-07T00:48:49.355Z",
|
||||
"createdAt": "2026-05-07T00:48:49.355Z",
|
||||
"id": "4YKnRQ9rOiQCeYEU",
|
||||
"name": "Paperless \u2192 RAG v1.0",
|
||||
"description": null,
|
||||
"active": true,
|
||||
"isArchived": false,
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "paperless/rag-ingest",
|
||||
"options": {}
|
||||
},
|
||||
"id": "a86d7025-bbf0-4c1b-a59c-ad254ddc913e",
|
||||
"name": "Paperless RAG Webhook",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"webhookId": "f2eccecb-9935-425b-be6a-f57fe4473f34"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const data = $input.first().json;\nconst body = data.body || data;\n\nlet docId = body.document_id || body.id || body.doc_id || body.pk;\n\nif (!docId || typeof docId === 'string' && docId.includes('{')) {\n docId = null;\n}\n\nreturn [{ json: { docId } }];"
|
||||
},
|
||||
"id": "8f6af849-bdd9-466e-af81-84d057fd7ca1",
|
||||
"name": "Extract Document ID",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
224,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"url": "=https://paperless.paccoco.com/api/documents/{{ $json.docId ? $json.docId + '/' : '?ordering=-added&page_size=1' }}",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Authorization",
|
||||
"value": "Token 4fb34ba35b4ab76a0715e8c56faf00a31de4fb5d"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "0b53d951-40cd-4ef0-ab81-3dea73f8b1d7",
|
||||
"name": "Fetch Document",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
448,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const response = $input.first().json;\nconst doc = response.results ? response.results[0] : response;\n\nif (!doc || !doc.id) {\n throw new Error('No document found in response');\n}\n\nconst content = doc.content || '';\nconst title = doc.title || 'Untitled';\nconst correspondent = doc.correspondent_name || 'Unknown';\nconst created = doc.created || new Date().toISOString();\nconst docType = doc.document_type_name || 'unknown';\nconst tags = (doc.tags || []).join(', ');\n\n// Build rich text for RAG with metadata context\nconst ragText = `Document: ${title}\\nCorrespondent: ${correspondent}\\nType: ${docType}\\nTags: ${tags}\\nDate: ${created}\\n\\n${content}`;\n\nreturn [{\n json: {\n documentId: doc.id,\n title,\n ragText,\n source: `paperless-doc-${doc.id}`,\n metadata: {\n paperless_id: doc.id,\n title,\n correspondent,\n document_type: docType,\n created\n }\n }\n}];"
|
||||
},
|
||||
"id": "e3d506bc-1677-4825-b3d3-f6187156da22",
|
||||
"name": "Prepare RAG Text",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
672,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "// Split text into chunks for embedding\nconst input = $input.first().json;\nconst text = input.ragText || '';\nconst source = input.source;\nconst metadata = input.metadata;\n\nconst CHUNK_SIZE = 500;\nconst OVERLAP = 50;\n\nconst chunks = [];\nconst sentences = text.split(/(?<=[.!?])\\s+/);\nlet current = '';\n\nfor (const sentence of sentences) {\n if ((current + ' ' + sentence).length > CHUNK_SIZE && current.length > 0) {\n chunks.push(current.trim());\n const words = current.split(' ');\n current = words.slice(-OVERLAP).join(' ') + ' ' + sentence;\n } else {\n current = current ? current + ' ' + sentence : sentence;\n }\n}\nif (current.trim()) chunks.push(current.trim());\n\nreturn chunks.map((chunk, i) => ({\n json: {\n chunk,\n chunkIndex: i,\n totalChunks: chunks.length,\n source,\n metadata\n }\n}));"
|
||||
},
|
||||
"id": "9a523501-3adb-41a3-b963-b6bb5adb25fe",
|
||||
"name": "Chunk Text",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
880,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "http://10.5.1.6:11434/v1/embeddings",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"specifyBody": "json",
|
||||
"jsonBody": "={\n \"model\": \"nomic-embed-text\",\n \"input\": \"{{ $json.chunk }}\"\n}",
|
||||
"options": {
|
||||
"batching": {
|
||||
"batch": {
|
||||
"batchSize": 5,
|
||||
"batchInterval": 500
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"id": "0b631ea4-b11f-4533-960f-f5161ac798f3",
|
||||
"name": "Get Embedding",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
1104,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const embeddingResponse = $input.first().json;\nconst chunkData = $('Chunk Text').item;\nconst embedding = embeddingResponse.data?.[0]?.embedding || [];\n\nconst pointId = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {\n const r = Math.random() * 16 | 0;\n return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);\n});\n\nreturn [{\n json: {\n id: pointId,\n vector: embedding,\n payload: {\n text: chunkData.json.chunk,\n source: chunkData.json.source,\n chunkIndex: chunkData.json.chunkIndex,\n totalChunks: chunkData.json.totalChunks,\n metadata: chunkData.json.metadata,\n ingested_at: new Date().toISOString()\n }\n }\n}];"
|
||||
},
|
||||
"id": "ad9dc677-e3a2-464e-a82e-2aa4d8b9b042",
|
||||
"name": "Prepare Qdrant Point",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1328,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "PUT",
|
||||
"url": "http://10.5.1.6:6333/collections/knowledge_base/points",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"specifyBody": "json",
|
||||
"jsonBody": "={\n \"points\": [\n {\n \"id\": \"{{ $json.id }}\",\n \"vector\": {{ JSON.stringify($json.vector) }},\n \"payload\": {{ JSON.stringify($json.payload) }}\n }\n ]\n}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "e977b536-d470-4da0-a970-794a858e8aa9",
|
||||
"name": "Upsert to Qdrant",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
1552,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const ragText = $('Prepare RAG Text').first().json;\nconst chunks = $('Chunk Text').first().json;\nreturn [{\n json: {\n title: '\ud83d\udcda Document Added to RAG',\n message: `${ragText.title} has been chunked and ingested into the knowledge base (${chunks.totalChunks || '?'} chunks)`,\n priority: 3\n }\n}];"
|
||||
},
|
||||
"id": "fmt05-0001-0000-0000-000000000005",
|
||||
"name": "Format Gotify Message",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1520,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"message": "={{ $json.message }}",
|
||||
"additionalFields": {
|
||||
"priority": "={{ $json.priority }}",
|
||||
"title": "={{ $json.title }}"
|
||||
},
|
||||
"options": {
|
||||
"contentType": "text/plain"
|
||||
}
|
||||
},
|
||||
"id": "ccdee208-b8f8-4ad4-a20c-94c4735d2e3d",
|
||||
"name": "Notify via Gotify",
|
||||
"type": "n8n-nodes-base.gotify",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1760,
|
||||
0
|
||||
],
|
||||
"credentials": {
|
||||
"gotifyApi": {
|
||||
"id": "SETUP_REQUIRED",
|
||||
"name": "Paperless RAG"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"Paperless RAG Webhook": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Extract Document ID",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Extract Document ID": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Fetch Document",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Fetch Document": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Prepare RAG Text",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Prepare RAG Text": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Chunk Text",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Chunk Text": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Get Embedding",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Get Embedding": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Prepare Qdrant Point",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Prepare Qdrant Point": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Upsert to Qdrant",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Upsert to Qdrant": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Format Gotify Message",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format Gotify Message": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Notify via Gotify",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1",
|
||||
"binaryMode": "separate"
|
||||
},
|
||||
"staticData": null,
|
||||
"meta": null,
|
||||
"pinData": {},
|
||||
"versionId": "3c20b423-8708-4540-8bf9-8db4880335a5",
|
||||
"activeVersionId": "3c20b423-8708-4540-8bf9-8db4880335a5",
|
||||
"versionCounter": 12,
|
||||
"triggerCount": 1,
|
||||
"tags": [
|
||||
{
|
||||
"updatedAt": "2026-05-06T22:39:46.476Z",
|
||||
"createdAt": "2026-05-06T22:39:46.476Z",
|
||||
"id": "NxHjuO4MMd5kdPR7",
|
||||
"name": "paperless"
|
||||
},
|
||||
{
|
||||
"updatedAt": "2026-05-06T22:39:33.284Z",
|
||||
"createdAt": "2026-05-06T22:39:33.284Z",
|
||||
"id": "7uuEyQrIlcuruZBk",
|
||||
"name": "rag"
|
||||
},
|
||||
{
|
||||
"updatedAt": "2026-05-06T22:38:51.678Z",
|
||||
"createdAt": "2026-05-06T22:38:51.678Z",
|
||||
"id": "S9FxzVfHLsHmyzyt",
|
||||
"name": "ai"
|
||||
}
|
||||
],
|
||||
"shared": [
|
||||
{
|
||||
"updatedAt": "2026-05-07T00:48:49.355Z",
|
||||
"createdAt": "2026-05-07T00:48:49.355Z",
|
||||
"role": "workflow:owner",
|
||||
"workflowId": "4YKnRQ9rOiQCeYEU",
|
||||
"projectId": "dxCRnBdX5uJizCGa",
|
||||
"project": {
|
||||
"updatedAt": "2026-05-06T01:10:37.484Z",
|
||||
"createdAt": "2026-05-06T01:08:07.721Z",
|
||||
"id": "dxCRnBdX5uJizCGa",
|
||||
"name": "Wilfred Fizzlepoof <admin@paccoco.com>",
|
||||
"type": "personal",
|
||||
"icon": null,
|
||||
"description": null,
|
||||
"creatorId": "47b2227f-2fc2-4a08-bd35-ea157b92df0d"
|
||||
}
|
||||
}
|
||||
],
|
||||
"versionMetadata": {
|
||||
"name": "Version 3c20b423",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
588
n8n-workflows/06-web-scrape-summarize-v1.0.json
Normal file
588
n8n-workflows/06-web-scrape-summarize-v1.0.json
Normal file
File diff suppressed because one or more lines are too long
210
n8n-workflows/07-git-commit-summarizer-v1.0.json
Normal file
210
n8n-workflows/07-git-commit-summarizer-v1.0.json
Normal file
@@ -0,0 +1,210 @@
|
||||
{
|
||||
"updatedAt": "2026-05-07T00:49:43.226Z",
|
||||
"createdAt": "2026-05-07T00:49:43.226Z",
|
||||
"id": "CFYWbBRx9RPf4HjS",
|
||||
"name": "Git Commit \u2192 AI Summary \u2192 Gotify v1.0",
|
||||
"description": null,
|
||||
"active": true,
|
||||
"isArchived": false,
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "git/push",
|
||||
"options": {}
|
||||
},
|
||||
"id": "fe377ac9-adcf-427d-a096-679f5469f8d8",
|
||||
"name": "Git Push Webhook",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"webhookId": "d1d31942-6fe8-48a2-aab7-7eefaf800420"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const data = $input.first().json;\nconst body = data.body || data;\n\n// Works with Gitea, Forgejo, GitHub, and GitLab webhook payloads\nconst repo = body.repository?.full_name || body.repository?.name || body.project?.path_with_namespace || 'unknown-repo';\nconst branch = (body.ref || '').replace('refs/heads/', '');\nconst pusher = body.pusher?.name || body.pusher?.login || body.user_name || body.sender?.login || 'unknown';\n\n// Extract commits\nconst commits = (body.commits || []).map(c => ({\n id: (c.id || c.sha || '').substring(0, 7),\n message: (c.message || '').split('\\n')[0],\n author: c.author?.name || c.author?.username || 'unknown',\n added: (c.added || []).length,\n modified: (c.modified || []).length,\n removed: (c.removed || []).length\n}));\n\nconst commitSummary = commits.map(c =>\n `${c.id}: ${c.message} (by ${c.author}) [+${c.added} ~${c.modified} -${c.removed}]`\n).join('\\n');\n\nreturn [{\n json: {\n repo,\n branch,\n pusher,\n commitCount: commits.length,\n commitSummary,\n compareUrl: body.compare_url || body.compare || ''\n }\n}];"
|
||||
},
|
||||
"id": "8dda4f14-9563-490f-89b3-aef80f64ba0b",
|
||||
"name": "Parse Git Payload",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
224,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "http://10.5.1.6:4000/v1/chat/completions",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"name": "Authorization",
|
||||
"value": "Bearer sk-a95bd142d43d175b6476ebc862e81aa1f6ef34b1153f839698d07541d2f55308"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"specifyBody": "json",
|
||||
"jsonBody": "={\n \"model\": \"light\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a git commit summarizer. Given a list of commits pushed to a repo, write a 1-2 sentence summary of what changed. Be concise and technical. Focus on the purpose of the changes, not just listing files.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Repository: {{ $json.repo }}\\nBranch: {{ $json.branch }}\\nPushed by: {{ $json.pusher }}\\n\\nCommits ({{ $json.commitCount }}):\\n{{ $json.commitSummary }}\"\n }\n ],\n \"max_tokens\": 150,\n \"temperature\": 0.2\n}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "c6b2b71b-2612-4ef7-8561-8adccbfa9be8",
|
||||
"name": "AI Summarize Commits",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
448,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const response = $input.first().json;\nconst gitData = $('Parse Git Payload').first().json;\nconst summary = response.choices?.[0]?.message?.content || 'Could not summarize';\n\nconst title = `\ud83d\udd00 ${gitData.repo}:${gitData.branch} (${gitData.commitCount} commit${gitData.commitCount !== 1 ? 's' : ''})`;\n\nreturn [{\n json: {\n title,\n message: `${summary}\\n\\nPushed by: ${gitData.pusher}`,\n priority: 3\n }\n}];"
|
||||
},
|
||||
"id": "94f5c120-0ae6-4a23-9556-d4f564f9f967",
|
||||
"name": "Format Notification",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
672,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"message": "={{ $json.message }}",
|
||||
"additionalFields": {
|
||||
"priority": "={{ $json.priority }}",
|
||||
"title": "={{ $json.title }}"
|
||||
},
|
||||
"options": {
|
||||
"contentType": "text/plain"
|
||||
}
|
||||
},
|
||||
"id": "4f731683-574c-4a39-84fe-025280193ba1",
|
||||
"name": "Push to Gotify",
|
||||
"type": "n8n-nodes-base.gotify",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
880,
|
||||
0
|
||||
],
|
||||
"credentials": {
|
||||
"gotifyApi": {
|
||||
"id": "SETUP_REQUIRED",
|
||||
"name": "Git Commits"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"Git Push Webhook": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Parse Git Payload",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Parse Git Payload": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "AI Summarize Commits",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"AI Summarize Commits": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Format Notification",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format Notification": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Push to Gotify",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1",
|
||||
"binaryMode": "separate"
|
||||
},
|
||||
"staticData": null,
|
||||
"meta": null,
|
||||
"pinData": {},
|
||||
"versionId": "61fca126-b5dd-4425-b0ee-c621d3ed58af",
|
||||
"activeVersionId": "61fca126-b5dd-4425-b0ee-c621d3ed58af",
|
||||
"versionCounter": 12,
|
||||
"triggerCount": 1,
|
||||
"tags": [
|
||||
{
|
||||
"updatedAt": "2026-05-07T00:49:41.640Z",
|
||||
"createdAt": "2026-05-07T00:49:41.640Z",
|
||||
"id": "36CVfQVO41QQyOmh",
|
||||
"name": "notifications"
|
||||
},
|
||||
{
|
||||
"updatedAt": "2026-05-07T00:49:41.638Z",
|
||||
"createdAt": "2026-05-07T00:49:41.638Z",
|
||||
"id": "2oumYE52ygvhrieZ",
|
||||
"name": "git"
|
||||
},
|
||||
{
|
||||
"updatedAt": "2026-05-06T22:38:51.678Z",
|
||||
"createdAt": "2026-05-06T22:38:51.678Z",
|
||||
"id": "S9FxzVfHLsHmyzyt",
|
||||
"name": "ai"
|
||||
}
|
||||
],
|
||||
"shared": [
|
||||
{
|
||||
"updatedAt": "2026-05-07T00:49:43.226Z",
|
||||
"createdAt": "2026-05-07T00:49:43.226Z",
|
||||
"role": "workflow:owner",
|
||||
"workflowId": "CFYWbBRx9RPf4HjS",
|
||||
"projectId": "dxCRnBdX5uJizCGa",
|
||||
"project": {
|
||||
"updatedAt": "2026-05-06T01:10:37.484Z",
|
||||
"createdAt": "2026-05-06T01:08:07.721Z",
|
||||
"id": "dxCRnBdX5uJizCGa",
|
||||
"name": "Wilfred Fizzlepoof <admin@paccoco.com>",
|
||||
"type": "personal",
|
||||
"icon": null,
|
||||
"description": null,
|
||||
"creatorId": "47b2227f-2fc2-4a08-bd35-ea157b92df0d"
|
||||
}
|
||||
}
|
||||
],
|
||||
"versionMetadata": {
|
||||
"name": "Version 61fca126",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
532
n8n-workflows/08-class-recording-rag-v1.0.json
Normal file
532
n8n-workflows/08-class-recording-rag-v1.0.json
Normal file
@@ -0,0 +1,532 @@
|
||||
{
|
||||
"updatedAt": "2026-05-07T01:16:50.340Z",
|
||||
"createdAt": "2026-05-07T01:16:50.340Z",
|
||||
"id": "91I278E72FAaQenD",
|
||||
"name": "Class Recording \u2192 RAG v1.0",
|
||||
"description": null,
|
||||
"active": true,
|
||||
"isArchived": false,
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"httpMethod": "POST",
|
||||
"path": "class/upload",
|
||||
"responseMode": "lastNode",
|
||||
"responseData": "allEntries",
|
||||
"options": {
|
||||
"rawBody": true
|
||||
}
|
||||
},
|
||||
"id": "e475f17b-8560-4376-852e-a613ba6b300e",
|
||||
"name": "Class Upload Webhook",
|
||||
"type": "n8n-nodes-base.webhook",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"webhookId": "d0ee8226-db56-477e-8a3f-572a9129aea9"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const data = $input.first().json;\nconst body = data.body || data;\n\n// Class name comes from:\n// 1. Form field 'class_name' in multipart upload\n// 2. Query parameter ?class=CS101\n// 3. Header X-Class-Name\nconst className = body.class_name || data.headers?.['x-class-name'] || data.query?.class || 'unclassified';\n\n// Lecture title from:\n// 1. Form field 'lecture_title'\n// 2. Query param ?title=...\n// 3. Header X-Lecture-Title\n// 4. Form field 'filename' (original filename)\nconst rawTitle = body.lecture_title || data.headers?.['x-lecture-title'] || data.query?.title || body.filename || 'Untitled Lecture';\nconst lectureTitle = rawTitle.replace(/\\.wav$/i, '').replace(/[-_]/g, ' ');\n\nconst classSlug = className.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');\n\nreturn [{\n json: {\n className,\n classSlug,\n lectureTitle,\n uploadedAt: new Date().toISOString()\n }\n}];"
|
||||
},
|
||||
"id": "24e4a726-ab50-4767-a144-1751616c781d",
|
||||
"name": "Extract Class Info",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
224,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "http://10.5.1.6:8786/v1/audio/transcriptions",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Accept",
|
||||
"value": "application/json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"contentType": "multipart-form-data",
|
||||
"bodyParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"parameterType": "formBinaryData",
|
||||
"name": "file",
|
||||
"inputDataFieldName": "data"
|
||||
},
|
||||
{
|
||||
"name": "model",
|
||||
"value": "Systran/faster-whisper-large-v3"
|
||||
},
|
||||
{
|
||||
"name": "language",
|
||||
"value": "en"
|
||||
},
|
||||
{
|
||||
"name": "response_format",
|
||||
"value": "verbose_json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {
|
||||
"timeout": 600000
|
||||
}
|
||||
},
|
||||
"id": "fcd1062d-8f60-4214-85ee-f53b914abcbb",
|
||||
"name": "Whisper Transcribe",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
448,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const result = $input.first().json;\nconst classInfo = $('Extract Class Info').first().json;\n\nconst segments = result.segments || [];\nconst fullText = result.text || segments.map(s => s.text).join(' ');\nconst duration = result.duration || segments[segments.length - 1]?.end || 0;\n\nconst timestamped = segments.map(s => {\n const mins = Math.floor(s.start / 60);\n const secs = Math.floor(s.start % 60);\n return `[${mins}:${String(secs).padStart(2, '0')}] ${s.text.trim()}`;\n}).join('\\n');\n\nreturn [{\n json: {\n className: classInfo.className,\n classSlug: classInfo.classSlug,\n lectureTitle: classInfo.lectureTitle,\n fullText: fullText.trim(),\n timestampedText: timestamped,\n durationMinutes: Math.round(duration / 60),\n segmentCount: segments.length\n }\n}];"
|
||||
},
|
||||
"id": "ecf09ad2-327e-4a82-90f3-95da5590e0ac",
|
||||
"name": "Format Transcript",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
672,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "http://10.5.1.6:4000/v1/chat/completions",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
},
|
||||
{
|
||||
"name": "Authorization",
|
||||
"value": "Bearer sk-a95bd142d43d175b6476ebc862e81aa1f6ef34b1153f839698d07541d2f55308"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"specifyBody": "json",
|
||||
"jsonBody": "={\n \"model\": \"medium\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are an academic note-taking assistant. Given a class lecture transcription, provide:\\n1. A concise summary (3-5 sentences)\\n2. Key concepts covered (as a list)\\n3. Important definitions or formulas\\n4. Any assignments or deadlines mentioned\\n\\nRespond in JSON with keys: summary, key_concepts (array), definitions (array of {term, definition}), assignments (array)\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Class: {{ $json.className }}\\nLecture: {{ $json.lectureTitle }}\\n\\nTranscription (first 3000 chars):\\n{{ $json.fullText.substring(0, 3000) }}\"\n }\n ],\n \"max_tokens\": 600,\n \"temperature\": 0.2,\n \"response_format\": { \"type\": \"json_object\" }\n}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "e7407d06-f7f4-4105-a817-055d4703d59d",
|
||||
"name": "AI Extract Notes",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
880,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const llmResponse = $input.first().json;\nconst transcriptData = $('Format Transcript').first().json;\n\nlet notes;\ntry {\n notes = JSON.parse(llmResponse.choices?.[0]?.message?.content || '{}');\n} catch(e) {\n notes = { summary: 'Could not parse notes', key_concepts: [], definitions: [], assignments: [] };\n}\n\nconst ragText = [\n `Class: ${transcriptData.className}`,\n `Lecture: ${transcriptData.lectureTitle}`,\n `Duration: ${transcriptData.durationMinutes} minutes`,\n `Summary: ${notes.summary}`,\n `Key Concepts: ${(notes.key_concepts || []).join(', ')}`,\n '',\n 'Full Transcript:',\n transcriptData.fullText\n].join('\\n');\n\nreturn [{\n json: {\n className: transcriptData.className,\n classSlug: transcriptData.classSlug,\n lectureTitle: transcriptData.lectureTitle,\n durationMinutes: transcriptData.durationMinutes,\n notes,\n ragText,\n source: `class-${transcriptData.classSlug}-${Date.now()}`,\n metadata: {\n class_name: transcriptData.className,\n class_slug: transcriptData.classSlug,\n lecture_title: transcriptData.lectureTitle,\n duration_minutes: transcriptData.durationMinutes,\n type: 'class_recording',\n recorded_at: new Date().toISOString()\n }\n }\n}];"
|
||||
},
|
||||
"id": "71b0807d-03ba-45b2-b75b-b6fbeee5687e",
|
||||
"name": "Prepare for RAG",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1104,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const input = $input.first().json;\nconst text = input.ragText || '';\nconst source = input.source;\nconst metadata = input.metadata;\n\nconst CHUNK_SIZE = 500;\nconst OVERLAP = 50;\n\nconst chunks = [];\nconst sentences = text.split(/(?<=[.!?])\\s+/);\nlet current = '';\n\nfor (const sentence of sentences) {\n if ((current + ' ' + sentence).length > CHUNK_SIZE && current.length > 0) {\n chunks.push(current.trim());\n const words = current.split(' ');\n current = words.slice(-OVERLAP).join(' ') + ' ' + sentence;\n } else {\n current = current ? current + ' ' + sentence : sentence;\n }\n}\nif (current.trim()) chunks.push(current.trim());\n\nreturn chunks.map((chunk, i) => ({\n json: {\n chunk,\n chunkIndex: i,\n totalChunks: chunks.length,\n source,\n metadata\n }\n}));"
|
||||
},
|
||||
"id": "9e4bbe70-72b0-4955-848f-0d1b62ae94a4",
|
||||
"name": "Chunk Text",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1328,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "http://10.5.1.6:11434/v1/embeddings",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"specifyBody": "json",
|
||||
"jsonBody": "={\n \"model\": \"nomic-embed-text\",\n \"input\": \"{{ $json.chunk }}\"\n}",
|
||||
"options": {
|
||||
"batching": {
|
||||
"batch": {
|
||||
"batchSize": 5,
|
||||
"batchInterval": 500
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"id": "4ae1ab11-c76f-4478-84e0-7bcdfb20b83b",
|
||||
"name": "Get Embedding",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
1552,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const embeddingResponse = $input.first().json;\nconst chunkData = $('Chunk Text').item;\nconst embedding = embeddingResponse.data?.[0]?.embedding || [];\n\nconst pointId = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {\n const r = Math.random() * 16 | 0;\n return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);\n});\n\nreturn [{\n json: {\n id: pointId,\n vector: embedding,\n payload: {\n text: chunkData.json.chunk,\n source: chunkData.json.source,\n chunkIndex: chunkData.json.chunkIndex,\n totalChunks: chunkData.json.totalChunks,\n metadata: chunkData.json.metadata,\n ingested_at: new Date().toISOString()\n }\n }\n}];"
|
||||
},
|
||||
"id": "d4232b02-23fc-4cbd-ac2d-2fdbfbe9583a",
|
||||
"name": "Prepare Qdrant Point",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1760,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "PUT",
|
||||
"url": "http://10.5.1.6:6333/collections/knowledge_base/points",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Content-Type",
|
||||
"value": "application/json"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"specifyBody": "json",
|
||||
"jsonBody": "={\n \"points\": [\n {\n \"id\": \"{{ $json.id }}\",\n \"vector\": {{ JSON.stringify($json.vector) }},\n \"payload\": {{ JSON.stringify($json.payload) }}\n }\n ]\n}",
|
||||
"options": {}
|
||||
},
|
||||
"id": "845a2aa0-2546-431d-96e8-b36875d1fe7d",
|
||||
"name": "Upsert to Qdrant",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
1984,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const rag = $('Prepare for RAG').first().json;\nreturn [{\n json: {\n title: `\ud83c\udf93 ${rag.className} Lecture Processed`,\n message: `${rag.lectureTitle} (${rag.durationMinutes}min)\\nSummary: ${rag.notes.summary}\\nKey concepts: ${(rag.notes.key_concepts || []).slice(0, 5).join(', ')}`,\n priority: 5\n }\n}];"
|
||||
},
|
||||
"id": "fmt08-0001-0000-0000-000000000008",
|
||||
"name": "Format Gotify Message",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1968,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"message": "={{ $json.message }}",
|
||||
"additionalFields": {
|
||||
"priority": "={{ $json.priority }}",
|
||||
"title": "={{ $json.title }}"
|
||||
},
|
||||
"options": {
|
||||
"contentType": "text/plain"
|
||||
}
|
||||
},
|
||||
"id": "5b31b660-c414-40d1-82a5-d68511203133",
|
||||
"name": "Notify via Gotify",
|
||||
"type": "n8n-nodes-base.gotify",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
2208,
|
||||
0
|
||||
],
|
||||
"credentials": {
|
||||
"gotifyApi": {
|
||||
"id": "SETUP_REQUIRED",
|
||||
"name": "Class Recordings"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const rag = $('Prepare for RAG').first().json;\nconst notes = rag.notes || {};\nconst concepts = (notes.key_concepts || []).map((c,i) => `${i+1}. ${c}`).join('\\n');\nconst defs = Object.entries(notes.definitions || {}).map(([k,v]) => `${k}: ${v}`).join('\\n');\nconst assignments = (notes.assignments || []).map((a,i) => `${i+1}. ${a}`).join('\\n');\nconst content = [\n `Lecture Notes: ${rag.lectureTitle}`,\n `Class: ${rag.className}`,\n `Duration: ${rag.durationMinutes} minutes`,\n `Date: ${new Date().toISOString()}`, '',\n `Summary`, `=======`, notes.summary || '', '',\n `Key Concepts`, `=============`, concepts,\n ...(defs ? ['', `Definitions`, `===========`, defs] : []),\n ...(assignments ? ['', `Assignments`, `===========`, assignments] : []),\n].join('\\n');\nconst title = `${rag.className} \u2014 ${rag.lectureTitle}`;\nreturn [{ binary: { document: { data: Buffer.from(content,'utf-8').toString('base64'), mimeType:'text/plain', fileName:`${title}.txt` }}, json: { title, className: rag.className } }];\n"
|
||||
},
|
||||
"id": "95aea3a7-3b15-4196-9e4a-dc8f6ed8d49e",
|
||||
"name": "Prepare Notes Doc",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
2208,
|
||||
-200
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "POST",
|
||||
"url": "https://paperless.paccoco.com/api/documents/post_document/",
|
||||
"options": {},
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Authorization",
|
||||
"value": "Bearer ${PAPERLESS_API_TOKEN}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendBody": true,
|
||||
"contentType": "multipart-form-data",
|
||||
"bodyParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "document",
|
||||
"value": "data",
|
||||
"parameterType": "formBinaryData"
|
||||
},
|
||||
{
|
||||
"name": "title",
|
||||
"value": "={{ $json.title }}"
|
||||
},
|
||||
{
|
||||
"name": "tags[]",
|
||||
"value": "${PAPERLESS_TAG_LECTURE_NOTES}"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"id": "c902a153-ab26-4518-af2a-585f0b72fe6c",
|
||||
"name": "Save Notes to Paperless",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
2432,
|
||||
-200
|
||||
],
|
||||
"continueOnFail": true
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"Class Upload Webhook": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Extract Class Info",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Extract Class Info": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Whisper Transcribe",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Whisper Transcribe": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Format Transcript",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format Transcript": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "AI Extract Notes",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"AI Extract Notes": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Prepare for RAG",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Prepare for RAG": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Chunk Text",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Chunk Text": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Get Embedding",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Get Embedding": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Prepare Qdrant Point",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Prepare Qdrant Point": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Upsert to Qdrant",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Upsert to Qdrant": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Format Gotify Message",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
},
|
||||
{
|
||||
"node": "Prepare Notes Doc",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format Gotify Message": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Notify via Gotify",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Prepare Notes Doc": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Save Notes to Paperless",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1",
|
||||
"binaryMode": "separate"
|
||||
},
|
||||
"staticData": null,
|
||||
"meta": null,
|
||||
"pinData": {},
|
||||
"versionId": "d64293a7-5537-4b01-a11b-6b838d6cacbf",
|
||||
"activeVersionId": "d64293a7-5537-4b01-a11b-6b838d6cacbf",
|
||||
"versionCounter": 11,
|
||||
"triggerCount": 1,
|
||||
"tags": [
|
||||
{
|
||||
"updatedAt": "2026-05-07T00:49:56.081Z",
|
||||
"createdAt": "2026-05-07T00:49:56.081Z",
|
||||
"id": "Q9lCYtCOuy9XmeyL",
|
||||
"name": "school"
|
||||
},
|
||||
{
|
||||
"updatedAt": "2026-05-06T22:39:59.716Z",
|
||||
"createdAt": "2026-05-06T22:39:59.716Z",
|
||||
"id": "tuPxDoKFqpVrrQoX",
|
||||
"name": "whisper"
|
||||
},
|
||||
{
|
||||
"updatedAt": "2026-05-06T22:39:33.284Z",
|
||||
"createdAt": "2026-05-06T22:39:33.284Z",
|
||||
"id": "7uuEyQrIlcuruZBk",
|
||||
"name": "rag"
|
||||
},
|
||||
{
|
||||
"updatedAt": "2026-05-06T22:38:51.678Z",
|
||||
"createdAt": "2026-05-06T22:38:51.678Z",
|
||||
"id": "S9FxzVfHLsHmyzyt",
|
||||
"name": "ai"
|
||||
}
|
||||
],
|
||||
"shared": [
|
||||
{
|
||||
"updatedAt": "2026-05-07T01:16:50.340Z",
|
||||
"createdAt": "2026-05-07T01:16:50.340Z",
|
||||
"role": "workflow:owner",
|
||||
"workflowId": "91I278E72FAaQenD",
|
||||
"projectId": "dxCRnBdX5uJizCGa",
|
||||
"project": {
|
||||
"updatedAt": "2026-05-06T01:10:37.484Z",
|
||||
"createdAt": "2026-05-06T01:08:07.721Z",
|
||||
"id": "dxCRnBdX5uJizCGa",
|
||||
"name": "Wilfred Fizzlepoof <admin@paccoco.com>",
|
||||
"type": "personal",
|
||||
"icon": null,
|
||||
"description": null,
|
||||
"creatorId": "47b2227f-2fc2-4a08-bd35-ea157b92df0d"
|
||||
}
|
||||
}
|
||||
],
|
||||
"versionMetadata": {
|
||||
"name": "Version d64293a7",
|
||||
"description": ""
|
||||
}
|
||||
}
|
||||
292
n8n-workflows/14-paperless-inbox-reminder-v1.0.json
Normal file
292
n8n-workflows/14-paperless-inbox-reminder-v1.0.json
Normal file
@@ -0,0 +1,292 @@
|
||||
{
|
||||
"name": "Paperless Inbox Reminder v1.0",
|
||||
"active": true,
|
||||
"isArchived": false,
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"rule": {
|
||||
"interval": [
|
||||
{
|
||||
"field": "weeks",
|
||||
"weeksInterval": 1,
|
||||
"triggerAtDay": [
|
||||
1
|
||||
],
|
||||
"triggerAtHour": 9,
|
||||
"triggerAtMinute": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"id": "41404371-29ed-4660-9989-a5cbd890555b",
|
||||
"name": "Every Monday 9 AM",
|
||||
"type": "n8n-nodes-base.scheduleTrigger",
|
||||
"typeVersion": 1.2,
|
||||
"position": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "GET",
|
||||
"url": "https://paperless.paccoco.com/api/documents/",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Authorization",
|
||||
"value": "Bearer ={{ $env.PAPERLESS_API_TOKEN }}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendQuery": true,
|
||||
"queryParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "is_tagged",
|
||||
"value": "0"
|
||||
},
|
||||
{
|
||||
"name": "page_size",
|
||||
"value": "25"
|
||||
},
|
||||
{
|
||||
"name": "ordering",
|
||||
"value": "created"
|
||||
},
|
||||
{
|
||||
"name": "fields",
|
||||
"value": "id,title,created,document_type,tags"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "fdcd5728-6d27-445f-961b-18f204297469",
|
||||
"name": "Fetch Inbox Docs",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
224,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const data = $input.first().json;\nconst docs = data.results || [];\nconst total = data.count || 0;\n\n// Oldest 5 for the reminder body\nconst oldest = docs.slice(0, 5).map(d => {\n const date = d.created ? d.created.substring(0, 10) : 'unknown date';\n return ` \u2022 ${d.title || 'Untitled'} (added ${date})`;\n});\n\nreturn [{\n json: {\n total,\n hasItems: total > 0,\n oldestList: oldest.join('\\n'),\n remaining: Math.max(0, total - 5)\n }\n}];"
|
||||
},
|
||||
"id": "8fbe6be0-1ed3-4126-8f21-c3f4efb161c6",
|
||||
"name": "Parse Response",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
448,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"conditions": {
|
||||
"options": {
|
||||
"caseSensitive": true,
|
||||
"leftValue": "",
|
||||
"typeValidation": "strict"
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"id": "efdd4f81-1976-4d26-a565-d110bfeba1df",
|
||||
"leftValue": "={{ $json.hasItems }}",
|
||||
"rightValue": true,
|
||||
"operator": {
|
||||
"type": "boolean",
|
||||
"operation": "equal"
|
||||
}
|
||||
}
|
||||
],
|
||||
"combinator": "and"
|
||||
}
|
||||
},
|
||||
"id": "e24344a1-e857-462c-b96a-842169e83a6d",
|
||||
"name": "Has Inbox Items?",
|
||||
"type": "n8n-nodes-base.if",
|
||||
"typeVersion": 2.2,
|
||||
"position": [
|
||||
672,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const d = $input.first().json;\nconst extra = d.remaining > 0 ? `\\n \u2026 and ${d.remaining} more` : '';\nconst body = `${d.total} untagged document${d.total !== 1 ? 's' : ''} in Paperless inbox:\\n${d.oldestList}${extra}\\n\\nhttps://paperless.paccoco.com`;\nreturn [{ json: { title: '\ud83d\udce5 Paperless Inbox Needs Attention', message: body, priority: 5 } }];"
|
||||
},
|
||||
"id": "897af9c9-4429-445f-8160-a03a14a318a3",
|
||||
"name": "Format Reminder",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
896,
|
||||
-120
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "return [{ json: { title: '\u2705 Paperless Inbox Clear', message: 'No untagged documents \u2014 inbox is clean.', priority: 1 } }];"
|
||||
},
|
||||
"id": "bd8fe88e-7876-45dd-8344-983674fba79d",
|
||||
"name": "Format Clear",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
896,
|
||||
120
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"message": "={{ $json.message }}",
|
||||
"additionalFields": {
|
||||
"priority": "={{ $json.priority }}",
|
||||
"title": "={{ $json.title }}"
|
||||
},
|
||||
"options": {
|
||||
"contentType": "text/plain"
|
||||
}
|
||||
},
|
||||
"id": "74860e7f-42e3-448f-9e46-5cfb6f12cdc2",
|
||||
"name": "Push to Gotify (Reminder)",
|
||||
"type": "n8n-nodes-base.gotify",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1120,
|
||||
-120
|
||||
],
|
||||
"credentials": {
|
||||
"gotifyApi": {
|
||||
"id": "SETUP_REQUIRED",
|
||||
"name": "Reminders"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"message": "={{ $json.message }}",
|
||||
"additionalFields": {
|
||||
"priority": "={{ $json.priority }}",
|
||||
"title": "={{ $json.title }}"
|
||||
},
|
||||
"options": {
|
||||
"contentType": "text/plain"
|
||||
}
|
||||
},
|
||||
"id": "b1dbd39b-87c3-43ec-9cec-f63eabbd0fa5",
|
||||
"name": "Push to Gotify (Clear)",
|
||||
"type": "n8n-nodes-base.gotify",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1120,
|
||||
120
|
||||
],
|
||||
"credentials": {
|
||||
"gotifyApi": {
|
||||
"id": "SETUP_REQUIRED",
|
||||
"name": "Reminders"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"Every Monday 9 AM": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Fetch Inbox Docs",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Fetch Inbox Docs": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Parse Response",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Parse Response": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Has Inbox Items?",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Has Inbox Items?": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Format Reminder",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"node": "Format Clear",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format Reminder": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Push to Gotify (Reminder)",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format Clear": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Push to Gotify (Clear)",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1",
|
||||
"binaryMode": "separate"
|
||||
},
|
||||
"staticData": null,
|
||||
"meta": null,
|
||||
"pinData": {},
|
||||
"tags": [
|
||||
{
|
||||
"name": "reminders"
|
||||
},
|
||||
{
|
||||
"name": "paperless"
|
||||
},
|
||||
{
|
||||
"name": "scheduled"
|
||||
}
|
||||
]
|
||||
}
|
||||
383
n8n-workflows/15-n8n-health-monitor-v1.0.json
Normal file
383
n8n-workflows/15-n8n-health-monitor-v1.0.json
Normal file
@@ -0,0 +1,383 @@
|
||||
{
|
||||
"name": "n8n Self-Health Monitor v1.0",
|
||||
"active": true,
|
||||
"isArchived": false,
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"rule": {
|
||||
"interval": [
|
||||
{
|
||||
"field": "minutes",
|
||||
"minutesInterval": 15
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"id": "dabcb0ae-d513-410e-b779-4570df5c4a35",
|
||||
"name": "Every 15 Minutes",
|
||||
"type": "n8n-nodes-base.scheduleTrigger",
|
||||
"typeVersion": 1.2,
|
||||
"position": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"method": "GET",
|
||||
"url": "http://10.5.1.6:5678/api/v1/executions",
|
||||
"sendHeaders": true,
|
||||
"headerParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "X-N8N-API-KEY",
|
||||
"value": "={{ $env.N8N_API_KEY }}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sendQuery": true,
|
||||
"queryParameters": {
|
||||
"parameters": [
|
||||
{
|
||||
"name": "status",
|
||||
"value": "error"
|
||||
},
|
||||
{
|
||||
"name": "includeData",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"name": "limit",
|
||||
"value": "50"
|
||||
}
|
||||
]
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
"id": "806d75e9-b95a-499a-b997-a7f7dc046775",
|
||||
"name": "Fetch Failed Executions",
|
||||
"type": "n8n-nodes-base.httpRequest",
|
||||
"typeVersion": 4.2,
|
||||
"position": [
|
||||
224,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const data = $input.first().json;\nconst executions = data.data || [];\nconst oneHourAgo = Date.now() - (60 * 60 * 1000);\n\n// Filter to failures in the past hour\nconst recent = executions.filter(e => {\n const ts = new Date(e.startedAt || e.stoppedAt || 0).getTime();\n return ts >= oneHourAgo;\n});\n\n// Group by workflow name + error message for dedup key\nconst failures = recent.map(e => ({\n executionId: e.id,\n workflowId: e.workflowId,\n workflowName: e.workflowData?.name || `Workflow ${e.workflowId}`,\n startedAt: e.startedAt,\n stoppedAt: e.stoppedAt,\n errorMessage: e.data?.resultData?.error?.message || 'Unknown error'\n}));\n\n// Deduplicate by workflowName (report once per workflow per check)\nconst seen = new Set();\nconst unique = failures.filter(f => {\n if (seen.has(f.workflowName)) return false;\n seen.add(f.workflowName);\n return true;\n});\n\nreturn [{ json: { hasFailures: unique.length > 0, count: unique.length, failures: unique } }];"
|
||||
},
|
||||
"id": "f5d47910-5047-4c4f-aa84-a6907aa38551",
|
||||
"name": "Filter Recent Failures",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
448,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"conditions": {
|
||||
"options": {
|
||||
"caseSensitive": true,
|
||||
"leftValue": "",
|
||||
"typeValidation": "strict"
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"id": "a76d10a7-1313-467e-9648-471b296229a3",
|
||||
"leftValue": "={{ $json.hasFailures }}",
|
||||
"rightValue": true,
|
||||
"operator": {
|
||||
"type": "boolean",
|
||||
"operation": "equal"
|
||||
}
|
||||
}
|
||||
],
|
||||
"combinator": "and"
|
||||
}
|
||||
},
|
||||
"id": "7c298433-ab89-435e-8955-73da6b986f46",
|
||||
"name": "Has Failures?",
|
||||
"type": "n8n-nodes-base.if",
|
||||
"typeVersion": 2.2,
|
||||
"position": [
|
||||
672,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const d = $input.first().json;\n// Fingerprint = sorted workflow names joined \u2014 stable across retriggers\nconst fingerprint = (d.failures || [])\n .map(f => f.workflowName)\n .sort()\n .join('|') || 'unknown';\nreturn [{ json: { ...d, fingerprint } }];"
|
||||
},
|
||||
"id": "d3609d45-ba9f-41d3-a9bd-8c558a719f10",
|
||||
"name": "Build Fingerprint",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
896,
|
||||
-120
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "executeQuery",
|
||||
"query": "SELECT fingerprint, last_seen FROM n8n_health_dedup WHERE fingerprint = '{{ $json.fingerprint }}' AND last_seen > NOW() - INTERVAL '1 hour' LIMIT 1;",
|
||||
"options": {}
|
||||
},
|
||||
"id": "15a3dd71-bc5b-4396-9534-63518e097438",
|
||||
"name": "Lookup Dedup",
|
||||
"type": "n8n-nodes-base.postgres",
|
||||
"typeVersion": 2.5,
|
||||
"position": [
|
||||
1120,
|
||||
-120
|
||||
],
|
||||
"credentials": {
|
||||
"postgres": {
|
||||
"id": "n9svoXemqSZoNNUB",
|
||||
"name": "Postgres account"
|
||||
}
|
||||
},
|
||||
"continueOnFail": true
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const alertData = $('Build Fingerprint').first().json;\nconst rows = $input.all().filter(r => r.json && r.json.fingerprint);\nconst alreadyNotified = rows.length > 0;\nreturn [{ json: { ...alertData, alreadyNotified, shouldNotify: !alreadyNotified } }];"
|
||||
},
|
||||
"id": "a92590e3-7044-4ba3-9b39-f6a9457c5fbe",
|
||||
"name": "Check Already Notified",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1344,
|
||||
-120
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"conditions": {
|
||||
"options": {
|
||||
"caseSensitive": true,
|
||||
"leftValue": "",
|
||||
"typeValidation": "strict"
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"id": "b1e77af5-6875-47dd-97af-8e13958a7217",
|
||||
"leftValue": "={{ $json.shouldNotify }}",
|
||||
"rightValue": true,
|
||||
"operator": {
|
||||
"type": "boolean",
|
||||
"operation": "equal"
|
||||
}
|
||||
}
|
||||
],
|
||||
"combinator": "and"
|
||||
}
|
||||
},
|
||||
"id": "39ac0eaf-73ce-4fe1-9c4b-d09ac920291d",
|
||||
"name": "Should Notify?",
|
||||
"type": "n8n-nodes-base.if",
|
||||
"typeVersion": 2.2,
|
||||
"position": [
|
||||
1568,
|
||||
-120
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"operation": "executeQuery",
|
||||
"query": "INSERT INTO n8n_health_dedup (fingerprint, last_seen, workflow_names) VALUES ('{{ $json.fingerprint }}', NOW(), '{{ $json.failures.map(f => f.workflowName).join(\", \") }}') ON CONFLICT (fingerprint) DO UPDATE SET last_seen = NOW(), workflow_names = EXCLUDED.workflow_names;",
|
||||
"options": {}
|
||||
},
|
||||
"id": "0c3be155-0c3a-4354-b863-73a3f5bbf598",
|
||||
"name": "Upsert Dedup Record",
|
||||
"type": "n8n-nodes-base.postgres",
|
||||
"typeVersion": 2.5,
|
||||
"position": [
|
||||
1792,
|
||||
-120
|
||||
],
|
||||
"credentials": {
|
||||
"postgres": {
|
||||
"id": "n9svoXemqSZoNNUB",
|
||||
"name": "Postgres account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "const d = $('Build Fingerprint').first().json;\nconst lines = (d.failures || []).map(f =>\n ` \u2022 ${f.workflowName}\\n ${f.errorMessage.substring(0, 120)}`\n);\nconst body = `${d.count} workflow${d.count !== 1 ? 's' : ''} failed in the past hour:\\n\\n${lines.join('\\n')}\\n\\nhttps://n8n.paccoco.com`;\nreturn [{ json: { title: `\u26a0\ufe0f n8n: ${d.count} Workflow Failure${d.count !== 1 ? 's' : ''}`, message: body, priority: 7 } }];"
|
||||
},
|
||||
"id": "1c6b42bf-a38e-47b6-82ac-50c43ee9e583",
|
||||
"name": "Format Notification",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
2016,
|
||||
-120
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"message": "={{ $json.message }}",
|
||||
"additionalFields": {
|
||||
"priority": "={{ $json.priority }}",
|
||||
"title": "={{ $json.title }}"
|
||||
},
|
||||
"options": {
|
||||
"contentType": "text/plain"
|
||||
}
|
||||
},
|
||||
"id": "09435c2f-9044-432a-8ca8-dd3ce3262c76",
|
||||
"name": "Push to Gotify",
|
||||
"type": "n8n-nodes-base.gotify",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
2240,
|
||||
-120
|
||||
],
|
||||
"credentials": {
|
||||
"gotifyApi": {
|
||||
"id": "SETUP_REQUIRED",
|
||||
"name": "n8n Health"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"Every 15 Minutes": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Fetch Failed Executions",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Fetch Failed Executions": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Filter Recent Failures",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Filter Recent Failures": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Has Failures?",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Has Failures?": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Build Fingerprint",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
[]
|
||||
]
|
||||
},
|
||||
"Build Fingerprint": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Lookup Dedup",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Lookup Dedup": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Check Already Notified",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Check Already Notified": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Should Notify?",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Should Notify?": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Upsert Dedup Record",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
[]
|
||||
]
|
||||
},
|
||||
"Upsert Dedup Record": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Format Notification",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format Notification": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Push to Gotify",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1",
|
||||
"binaryMode": "separate"
|
||||
},
|
||||
"staticData": null,
|
||||
"meta": null,
|
||||
"pinData": {},
|
||||
"tags": [
|
||||
{
|
||||
"name": "monitoring"
|
||||
},
|
||||
{
|
||||
"name": "scheduled"
|
||||
},
|
||||
{
|
||||
"name": "n8n"
|
||||
}
|
||||
]
|
||||
}
|
||||
449
n8n-workflows/16-nfs-watchdog-v1.0.json
Normal file
449
n8n-workflows/16-nfs-watchdog-v1.0.json
Normal file
@@ -0,0 +1,449 @@
|
||||
{
|
||||
"name": "NFS Mount Watchdog + Auto-Heal v1.0",
|
||||
"active": true,
|
||||
"isArchived": false,
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {
|
||||
"rule": {
|
||||
"interval": [
|
||||
{
|
||||
"field": "minutes",
|
||||
"minutesInterval": 5
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"id": "8c466a67-a0fa-42dc-8ed8-0918834fc3a7",
|
||||
"name": "Every 5 Minutes",
|
||||
"type": "n8n-nodes-base.scheduleTrigger",
|
||||
"typeVersion": 1.2,
|
||||
"position": [
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"command": "mountpoint -q /mnt/unraid/data/media && echo MEDIA_OK || echo MEDIA_MISSING; mountpoint -q /mnt/unraid/data/photos && echo PHOTOS_OK || echo PHOTOS_MISSING"
|
||||
},
|
||||
"id": "f5b2fee9-d67a-4da7-80dd-f72e6078aed9",
|
||||
"name": "Probe Mounts",
|
||||
"type": "n8n-nodes-base.ssh",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
224,
|
||||
0
|
||||
],
|
||||
"credentials": {
|
||||
"sshPrivateKey": {
|
||||
"id": "SETUP_REQUIRED",
|
||||
"name": "PD SSH"
|
||||
}
|
||||
},
|
||||
"continueOnFail": true
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "\nconst out = ($input.first().json.stdout || '') + ($input.first().json.stderr || '');\nconst mediaOk = out.includes('MEDIA_OK');\nconst photosOk = out.includes('PHOTOS_OK');\nconst missing = [];\nif (!mediaOk) missing.push({ mount: '/mnt/unraid/data/media', label: 'media',\n containers: ['plex','audiobookshelf'] });\nif (!photosOk) missing.push({ mount: '/mnt/unraid/data/photos', label: 'photos',\n containers: ['immich-server','immich-microservices','immich-machine-learning'] });\nreturn [{ json: { mediaOk, photosOk, anyMissing: missing.length > 0, missing } }];\n"
|
||||
},
|
||||
"id": "25bb3239-49cb-4570-b706-4022b9aa751c",
|
||||
"name": "Parse Mount Status",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
448,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"conditions": {
|
||||
"options": {
|
||||
"caseSensitive": true,
|
||||
"leftValue": "",
|
||||
"typeValidation": "strict"
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"id": "442964fa-a29c-4aa2-98d1-9e25e927c496",
|
||||
"leftValue": "={{ $json.anyMissing }}",
|
||||
"rightValue": true,
|
||||
"operator": {
|
||||
"type": "boolean",
|
||||
"operation": "equal"
|
||||
}
|
||||
}
|
||||
],
|
||||
"combinator": "and"
|
||||
}
|
||||
},
|
||||
"id": "68b74832-85a7-4193-9382-a0c22a666e66",
|
||||
"name": "Any Missing?",
|
||||
"type": "n8n-nodes-base.if",
|
||||
"typeVersion": 2.2,
|
||||
"position": [
|
||||
672,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"command": "sudo bash /mnt/tank/docker/scripts/mount-unraid-nfs.sh 2>&1"
|
||||
},
|
||||
"id": "b18c7537-0c2f-4122-bfe5-6469d6be6853",
|
||||
"name": "Run Mount Script",
|
||||
"type": "n8n-nodes-base.ssh",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
896,
|
||||
-120
|
||||
],
|
||||
"credentials": {
|
||||
"sshPrivateKey": {
|
||||
"id": "SETUP_REQUIRED",
|
||||
"name": "PD SSH"
|
||||
}
|
||||
},
|
||||
"continueOnFail": true
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resume": "timeInterval",
|
||||
"unit": "seconds",
|
||||
"value": 10
|
||||
},
|
||||
"id": "2e927f83-9ddc-4816-8ee6-76d21ce21a5e",
|
||||
"name": "Wait 10s",
|
||||
"type": "n8n-nodes-base.wait",
|
||||
"typeVersion": 1.1,
|
||||
"position": [
|
||||
1120,
|
||||
-120
|
||||
],
|
||||
"webhookId": "4e89e8d0-7f08-4378-a2b7-63756665b039"
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"command": "mountpoint -q /mnt/unraid/data/media && echo MEDIA_OK || echo MEDIA_MISSING; mountpoint -q /mnt/unraid/data/photos && echo PHOTOS_OK || echo PHOTOS_MISSING"
|
||||
},
|
||||
"id": "d15c0c90-e94f-404a-a787-75f1b1b5befa",
|
||||
"name": "Re-probe Mounts",
|
||||
"type": "n8n-nodes-base.ssh",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
1344,
|
||||
-120
|
||||
],
|
||||
"credentials": {
|
||||
"sshPrivateKey": {
|
||||
"id": "SETUP_REQUIRED",
|
||||
"name": "PD SSH"
|
||||
}
|
||||
},
|
||||
"continueOnFail": true
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "\nconst out = ($input.first().json.stdout || '') + ($input.first().json.stderr || '');\nconst mediaOk = out.includes('MEDIA_OK');\nconst photosOk = out.includes('PHOTOS_OK');\n\n// What was originally missing (from step 3)\nconst originalMissing = $('Parse Mount Status').first().json.missing || [];\n\n// Which of the originally-missing mounts are now up?\nconst healed = originalMissing.filter(m =>\n (m.label === 'media' && mediaOk) ||\n (m.label === 'photos' && photosOk)\n);\nconst stillDown = originalMissing.filter(m =>\n (m.label === 'media' && !mediaOk) ||\n (m.label === 'photos' && !photosOk)\n);\n\n// Build flat container list to restart (only for healed mounts)\nconst containersToRestart = [...new Set(healed.flatMap(m => m.containers))];\nconst restartCmd = containersToRestart.length > 0\n ? `sudo docker restart ${containersToRestart.join(' ')}`\n : 'echo NO_RESTART_NEEDED';\n\nreturn [{ json: {\n allHealed: stillDown.length === 0,\n healed, stillDown,\n containersToRestart,\n restartCmd,\n originalMissing\n}}];\n"
|
||||
},
|
||||
"id": "48de38c2-df08-406f-ad61-809ca6e306a1",
|
||||
"name": "Parse Heal Result",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1568,
|
||||
-120
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"conditions": {
|
||||
"options": {
|
||||
"caseSensitive": true,
|
||||
"leftValue": "",
|
||||
"typeValidation": "strict"
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"id": "566dda6e-2234-406a-ad87-c886c7c5ae08",
|
||||
"leftValue": "={{ $json.allHealed }}",
|
||||
"rightValue": true,
|
||||
"operator": {
|
||||
"type": "boolean",
|
||||
"operation": "equal"
|
||||
}
|
||||
}
|
||||
],
|
||||
"combinator": "and"
|
||||
}
|
||||
},
|
||||
"id": "29a1b544-97b3-433f-9821-2bf5a8af95d2",
|
||||
"name": "Healed?",
|
||||
"type": "n8n-nodes-base.if",
|
||||
"typeVersion": 2.2,
|
||||
"position": [
|
||||
1792,
|
||||
-120
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"command": "={{ $json.restartCmd }}"
|
||||
},
|
||||
"id": "8d791509-9e18-44c1-bf58-ed3027927710",
|
||||
"name": "Restart Containers",
|
||||
"type": "n8n-nodes-base.ssh",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
2016,
|
||||
-240
|
||||
],
|
||||
"credentials": {
|
||||
"sshPrivateKey": {
|
||||
"id": "SETUP_REQUIRED",
|
||||
"name": "PD SSH"
|
||||
}
|
||||
},
|
||||
"continueOnFail": true
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "\nconst d = $('Parse Heal Result').first().json;\nconst mountList = d.healed.map(m => ` \u2022 ${m.mount}`).join('\\n');\nconst containers = d.containersToRestart.join(', ') || 'none';\nconst body = `NFS mounts were missing and have been automatically remounted.\\n\\nRemounted:\\n${mountList}\\n\\nContainers restarted: ${containers}`;\nreturn [{ json: { title: '\ud83d\udd17 NFS Auto-Healed', message: body, priority: 5 } }];\n"
|
||||
},
|
||||
"id": "75c8976f-d622-43cd-a332-72c32f0c7c60",
|
||||
"name": "Format Healed Notify",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
2240,
|
||||
-240
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"message": "={{ $json.message }}",
|
||||
"additionalFields": {
|
||||
"priority": "={{ $json.priority }}",
|
||||
"title": "={{ $json.title }}"
|
||||
},
|
||||
"options": {
|
||||
"contentType": "text/plain"
|
||||
}
|
||||
},
|
||||
"id": "38705cd2-775b-4ef9-b470-4a7709f132e5",
|
||||
"name": "Gotify (Healed)",
|
||||
"type": "n8n-nodes-base.gotify",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
2464,
|
||||
-240
|
||||
],
|
||||
"credentials": {
|
||||
"gotifyApi": {
|
||||
"id": "SETUP_REQUIRED",
|
||||
"name": "Uptime / Infra"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "\nconst d = $('Parse Heal Result').first().json;\nconst downList = d.stillDown.map(m => ` \u2022 ${m.mount}`).join('\\n');\nconst healedList = d.healed.length > 0\n ? `\\nPartially healed:\\n${d.healed.map(m => ' \u2022 ' + m.mount).join('\\n')}`\n : '';\nconst body = `NFS mount script ran but the following paths are still unavailable. Manual intervention required.\\n\\nStill down:\\n${downList}${healedList}\\n\\nCheck Serenity (TrueNAS) is up and NFS service is running.`;\nreturn [{ json: { title: '\ud83d\udea8 NFS Down \u2014 Manual Fix Needed', message: body, priority: 9 } }];\n"
|
||||
},
|
||||
"id": "074b984f-7fc2-45bc-b97f-f5db4d8d589b",
|
||||
"name": "Format Escalation",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
2016,
|
||||
-20
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"message": "={{ $json.message }}",
|
||||
"additionalFields": {
|
||||
"priority": "={{ $json.priority }}",
|
||||
"title": "={{ $json.title }}"
|
||||
},
|
||||
"options": {
|
||||
"contentType": "text/plain"
|
||||
}
|
||||
},
|
||||
"id": "f929dd77-6072-4ac9-9dc4-11246110efed",
|
||||
"name": "Gotify (Escalation)",
|
||||
"type": "n8n-nodes-base.gotify",
|
||||
"typeVersion": 1,
|
||||
"position": [
|
||||
2240,
|
||||
-20
|
||||
],
|
||||
"credentials": {
|
||||
"gotifyApi": {
|
||||
"id": "SETUP_REQUIRED",
|
||||
"name": "Uptime / Infra"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
"Every 5 Minutes": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Probe Mounts",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Probe Mounts": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Parse Mount Status",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Parse Mount Status": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Any Missing?",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Any Missing?": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Run Mount Script",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
[]
|
||||
]
|
||||
},
|
||||
"Run Mount Script": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Wait 10s",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Wait 10s": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Re-probe Mounts",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Re-probe Mounts": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Parse Heal Result",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Parse Heal Result": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Healed?",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Healed?": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Restart Containers",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"node": "Format Escalation",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Restart Containers": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Format Healed Notify",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format Healed Notify": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Gotify (Healed)",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Format Escalation": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Gotify (Escalation)",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"executionOrder": "v1",
|
||||
"binaryMode": "separate"
|
||||
},
|
||||
"staticData": null,
|
||||
"meta": null,
|
||||
"pinData": {},
|
||||
"tags": [
|
||||
{
|
||||
"name": "monitoring"
|
||||
},
|
||||
{
|
||||
"name": "infrastructure"
|
||||
},
|
||||
{
|
||||
"name": "scheduled"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user