refactor(n8n): consolidate school paperless enrichment

This commit is contained in:
Fizzlepoof
2026-05-14 02:18:40 +00:00
parent df70c6cbca
commit 8e182b31c7
4 changed files with 583 additions and 9 deletions

View File

@@ -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",
@@ -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": {