refactor(n8n): consolidate school paperless enrichment
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
"updatedAt": "2026-05-07T20:24:47.896Z",
|
||||
"createdAt": "2026-05-07T20:24:40.153Z",
|
||||
"id": "dQ1d5deV4mF0s5eP",
|
||||
"name": "Paperless-NGX → AI Processing → Native Gotify + Apply Tags",
|
||||
"name": "Paperless AI Processing v1.0",
|
||||
"description": null,
|
||||
"active": true,
|
||||
"isArchived": false,
|
||||
@@ -61,7 +61,7 @@
|
||||
},
|
||||
{
|
||||
"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}];"
|
||||
"jsCode": "\nconst response = $input.first().json;\nconst doc = response.results ? response.results[0] : response;\nif (!doc || !doc.id) {\n throw new Error('No document found in response');\n}\nconst title = doc.title || 'Untitled';\nconst originalFilename = doc.original_file_name || '';\nconst isSchoolIntake = /^school-/i.test(originalFilename) || / \u2014 (draft|final|revision|proposal)$/i.test(title);\nconst content = (doc.content || '').substring(0, 4000);\nreturn [{\n json: {\n documentId: doc.id,\n title,\n originalFilename,\n correspondent: doc.correspondent_name || null,\n content,\n created: doc.created || new Date().toISOString(),\n isSchoolIntake\n }\n}];"
|
||||
},
|
||||
"id": "3a026b3b-141b-48b4-a9ae-03998914f45c",
|
||||
"name": "Prepare Content",
|
||||
@@ -149,7 +149,7 @@
|
||||
},
|
||||
{
|
||||
"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: '📄 New Document Processed',\n message,\n priority: 4\n }\n}];"
|
||||
"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",
|
||||
@@ -198,6 +198,52 @@
|
||||
1328,
|
||||
400
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"conditions": {
|
||||
"options": {
|
||||
"caseSensitive": true,
|
||||
"leftValue": "",
|
||||
"typeValidation": "strict",
|
||||
"version": 2
|
||||
},
|
||||
"conditions": [
|
||||
{
|
||||
"id": "skip-school-docs",
|
||||
"leftValue": "={{$json.isSchoolIntake}}",
|
||||
"rightValue": true,
|
||||
"operator": {
|
||||
"type": "boolean",
|
||||
"operation": "true",
|
||||
"singleValue": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"combinator": "and"
|
||||
}
|
||||
},
|
||||
"id": "if-school-intake-skip",
|
||||
"name": "Is School Intake?",
|
||||
"type": "n8n-nodes-base.if",
|
||||
"typeVersion": 2.2,
|
||||
"position": [
|
||||
800,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"jsCode": "return [{ json: { skipped: true, reason: 'school_intake_owned_by_school_workflow', documentId: $json.documentId, title: $json.title } }];"
|
||||
},
|
||||
"id": "skip-school-return",
|
||||
"name": "Return School Skip",
|
||||
"type": "n8n-nodes-base.code",
|
||||
"typeVersion": 2,
|
||||
"position": [
|
||||
1040,
|
||||
-160
|
||||
]
|
||||
}
|
||||
],
|
||||
"connections": {
|
||||
@@ -238,7 +284,7 @@
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "AI Classify & Extract",
|
||||
"node": "Is School Intake?",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
@@ -287,6 +333,24 @@
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Is School Intake?": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Return School Skip",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"node": "AI Classify & Extract",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
|
||||
Reference in New Issue
Block a user