feat: add paperless intake triage workflow
This commit is contained in:
@@ -268,3 +268,111 @@ Edit the "Define RSS Feeds" Code node to add/remove feeds. Default feeds:
|
||||
- Hacker News
|
||||
|
||||
Add any RSS feed URL you want monitored.
|
||||
|
||||
---
|
||||
|
||||
## Workflow 17 — Paperless Intake Triage → Doris Review Queue
|
||||
|
||||
Import `17-paperless-intake-triage.json` for a review-first Paperless intake workflow. It is intentionally conservative: it writes a sanitized local review queue for Doris Dashboard and does **not** delete documents. Automatic Paperless updates are disabled by default.
|
||||
|
||||
### Trigger
|
||||
|
||||
Configure a Paperless-NGX post-consumption webhook to POST to:
|
||||
|
||||
```text
|
||||
https://n8n.paccoco.com/webhook/paperless/intake-triage
|
||||
```
|
||||
|
||||
Body:
|
||||
|
||||
```json
|
||||
{"document_id": 12345}
|
||||
```
|
||||
|
||||
Fixture: `fixtures/paperless-intake-webhook.example.json`.
|
||||
|
||||
### Environment variables
|
||||
|
||||
Add these to `automation/.env` and expose them in the n8n `environment:` block:
|
||||
|
||||
| Variable | Required | Default | Purpose |
|
||||
|----------|----------|---------|---------|
|
||||
| `PAPERLESS_BASE_URL` | yes | `https://paperless.paccoco.com` | Paperless API/UI base URL |
|
||||
| `PAPERLESS_API_TOKEN` | yes | none | Paperless API token; used as `Token ...` |
|
||||
| `LITELLM_BASE_URL` | yes | `http://10.5.1.6:4000` | LiteLLM OpenAI-compatible endpoint |
|
||||
| `LITELLM_API_KEY` | yes | none | LiteLLM key |
|
||||
| `PAPERLESS_TRIAGE_MODEL` | no | `gpt-4o-mini` | Model for strict JSON triage |
|
||||
| `PAPERLESS_TRIAGE_REVIEW_QUEUE_PATH` | yes | `/data/paperless_review.json` | Sanitized JSON queue path mounted for Doris Dashboard |
|
||||
| `PAPERLESS_TRIAGE_REVIEW_MAX_ITEMS` | no | `200` | Max queue entries retained |
|
||||
| `PAPERLESS_TRIAGE_APPLY_SAFE` | no | `false` | Enables low-risk title-only update branch when `true` |
|
||||
| `GOTIFY_URL` | no | none | Enables urgent-doc notification only when token also set |
|
||||
| `GOTIFY_TOKEN` | no | none | Gotify app token for urgent docs |
|
||||
| `NODE_FUNCTION_ALLOW_BUILTIN` | yes for queue file | none | Must include `fs,path` for the Code node that writes JSON |
|
||||
| `N8N_BLOCK_ENV_ACCESS_IN_NODE` | yes | existing note | Must be `false` so Code nodes can read `$env` |
|
||||
|
||||
Example environment additions:
|
||||
|
||||
```yaml
|
||||
N8N_BLOCK_ENV_ACCESS_IN_NODE: "false"
|
||||
NODE_FUNCTION_ALLOW_BUILTIN: fs,path
|
||||
PAPERLESS_BASE_URL: ${PAPERLESS_BASE_URL}
|
||||
PAPERLESS_API_TOKEN: ${PAPERLESS_API_TOKEN}
|
||||
LITELLM_BASE_URL: ${LITELLM_BASE_URL}
|
||||
LITELLM_API_KEY: ${LITELLM_API_KEY}
|
||||
PAPERLESS_TRIAGE_MODEL: ${PAPERLESS_TRIAGE_MODEL}
|
||||
PAPERLESS_TRIAGE_REVIEW_QUEUE_PATH: /workspace/doris-dashboard/data/paperless_review.json
|
||||
PAPERLESS_TRIAGE_APPLY_SAFE: "false"
|
||||
```
|
||||
|
||||
Mount the Doris dashboard data directory read/write into the n8n container if it is not already mounted. The workflow writes only sanitized display data: document IDs, titles, filenames, archive URL, current metadata names/IDs, triage summary, review reason, urgency, confidence, and safety flags. It must not contain tokens.
|
||||
|
||||
### Safety gates
|
||||
|
||||
The LLM must return strict JSON:
|
||||
|
||||
```json
|
||||
{
|
||||
"summary": "plain English summary",
|
||||
"suggested_title": "clean title",
|
||||
"document_type": "bill|receipt|school|medical|tax|insurance|legal|manual|letter|other",
|
||||
"suggested_correspondent": "string or null",
|
||||
"suggested_tags": ["..."],
|
||||
"due_date": "YYYY-MM-DD or null",
|
||||
"needs_review": true,
|
||||
"urgency": "none|low|medium|high",
|
||||
"reason": "why review/why not",
|
||||
"confidence": "high|medium|low"
|
||||
}
|
||||
```
|
||||
|
||||
The workflow forcibly marks `needs_review=true` for:
|
||||
|
||||
- legal, medical, school, tax, or insurance documents
|
||||
- any due date
|
||||
- bill/payment/invoice language
|
||||
- low confidence
|
||||
- urgency medium or high
|
||||
|
||||
Only high-confidence, low-risk docs with no due date and urgency `none|low` become eligible for automatic update, and even then the branch is disabled unless `PAPERLESS_TRIAGE_APPLY_SAFE=true`. The safe update branch currently updates **title only**. It does not delete, archive, or apply high-risk metadata.
|
||||
|
||||
### Test payload and expected result
|
||||
|
||||
- Webhook payload: `fixtures/paperless-intake-webhook.example.json`
|
||||
- Example Paperless API document: `fixtures/paperless-intake-document.example.json`
|
||||
- Expected triage JSON: `fixtures/paperless-intake-expected-triage.example.json`
|
||||
|
||||
The fixture is a utility bill with a due date, so the safety gate must force human review.
|
||||
|
||||
### Import/deploy steps
|
||||
|
||||
1. Import `17-paperless-intake-triage.json` in n8n.
|
||||
2. Add env vars and required volume mount.
|
||||
3. Restart n8n using the normal automation compose procedure.
|
||||
4. Keep `PAPERLESS_TRIAGE_APPLY_SAFE=false` for initial testing.
|
||||
5. Use a known test document and POST `{"document_id": <id>}` to `/webhook/paperless/intake-triage`.
|
||||
6. Confirm `doris-dashboard/data/paperless_review.json` updates and contains no secrets.
|
||||
7. Activate the Paperless webhook only after the test queue file is correct.
|
||||
|
||||
### Rollback
|
||||
|
||||
Deactivate the workflow and remove the Paperless webhook target. If needed, move `doris-dashboard/data/paperless_review.json` aside; it is display-only derived data. No Paperless deletion path exists in this workflow.
|
||||
|
||||
Reference in New Issue
Block a user