Add n8n workflows 01-08 (with upgrades), 14-16; planning docs; .gitignore
This commit is contained in:
186
docs/planning/N8N_WORKFLOW_IDEAS.md
Normal file
186
docs/planning/N8N_WORKFLOW_IDEAS.md
Normal file
@@ -0,0 +1,186 @@
|
||||
# n8n Workflow Ideas & Upgrade Proposals
|
||||
|
||||
Generated: 2026-05-09
|
||||
|
||||
---
|
||||
|
||||
## Upgrades to Existing Workflows
|
||||
|
||||
### 01 — Grafana Alert → AI → Gotify
|
||||
**Current state:** Webhook → parse → LiteLLM summarize → Gotify
|
||||
**Suggested upgrades:**
|
||||
- **Alert deduplication:** Store last-seen alert fingerprint in Postgres. If the same alert fires again within 30 min, suppress the Gotify push (you're already awake, you've seen it).
|
||||
- **Recovery notifications:** Grafana sends both `firing` and `resolved` states. Add a branch so resolved alerts get a `✅ RESOLVED` message with a distinct priority (1 = low).
|
||||
- **Auto-acknowledge low-priority alerts:** If priority < 3 and it's between midnight and 7am, skip Gotify and log to Postgres only.
|
||||
|
||||
---
|
||||
|
||||
### 04 — Whisper Audio Transcription
|
||||
**Current state:** Returns transcript inline, no Gotify notification
|
||||
**Suggested upgrades:**
|
||||
- **Add completion notification:** When a long transcription finishes, push to Gotify (Whisper Transcriptions app) so you know it's done without polling.
|
||||
- **Save transcript to Paperless:** After transcription, POST the text to Paperless-NGX as a new document with auto-tagging (`transcription`, `audio`, date).
|
||||
- **Save to Qdrant:** After transcription + summary, auto-ingest into RAG so all your audio content is searchable.
|
||||
|
||||
---
|
||||
|
||||
### 05 — Paperless → RAG Ingest
|
||||
**Current state:** Webhook → fetch → chunk → embed → Qdrant → Gotify
|
||||
**Suggested upgrades:**
|
||||
- **Retry on failure:** If Qdrant upsert fails, retry up to 3 times with exponential backoff before erroring out.
|
||||
- **Collection routing:** Add metadata tagging so documents from different Paperless tags go into different Qdrant collections (e.g., `knowledge_base` vs `receipts` vs `medical`).
|
||||
|
||||
---
|
||||
|
||||
### 08 — Class Recording → Transcribe → RAG
|
||||
**Current state:** Webhook → Whisper → AI notes → RAG → Gotify
|
||||
**Suggested upgrades:**
|
||||
- **Export notes to Paperless:** After extracting key concepts, create a Paperless document for the class notes (title = class + lecture, tags = class name, `lecture-notes`).
|
||||
- **Weekly class digest:** Scheduled workflow that queries RAG for all chunks from the past week, grouped by class, and sends a consolidated study summary to Gotify every Sunday night.
|
||||
- **Quiz generation:** Add an optional webhook endpoint that takes a class name + RAG query and generates 5 practice questions from the lecture material via LiteLLM.
|
||||
|
||||
---
|
||||
|
||||
## New Workflow Proposals
|
||||
|
||||
### 09 — Immich → AI Event Tagger
|
||||
**Trigger:** Immich post-upload webhook (or scheduled poll via Immich API)
|
||||
**What it does:**
|
||||
1. Fetch newly uploaded photos from Immich API
|
||||
2. Send image to a vision-capable model (gemma3:27b on Rocinante via LiteLLM)
|
||||
3. AI generates descriptive tags, detects events (birthday, trip, holiday), extracts visible text
|
||||
4. Write tags back to Immich via API
|
||||
5. Notify via Gotify (Immich app)
|
||||
|
||||
**Why:** Immich's built-in ML does faces, not semantic tagging. This adds searchable event context automatically.
|
||||
|
||||
---
|
||||
|
||||
### 10 — Home Assistant → Morning Briefing
|
||||
**Trigger:** Schedule (e.g. 7:00 AM daily)
|
||||
**What it does:**
|
||||
1. Fetch current weather from Home Assistant or weather API
|
||||
2. Query Grafana/Prometheus for overnight anomalies (high CPU, disk warnings)
|
||||
3. Check Pi-hole stats (queries blocked, top blocked domain)
|
||||
4. Check Paperless for any unread/untagged documents
|
||||
5. Summarize via LiteLLM into a 5-bullet morning briefing
|
||||
6. Push to Gotify (Morning Briefing app) and optionally to Home Assistant notification
|
||||
|
||||
**Why:** Single daily digest so you know what happened overnight without checking 4 different dashboards.
|
||||
|
||||
---
|
||||
|
||||
### 11 — Uptime Kuma → Smart Alert Escalation
|
||||
**Trigger:** Uptime Kuma webhook on status change
|
||||
**What it does:**
|
||||
1. Receive down/recovery event from Uptime Kuma
|
||||
2. Check Prometheus to confirm actual service health (avoids false positives)
|
||||
3. If confirmed down: check how long it's been down
|
||||
- < 2 min: log only (transient blip)
|
||||
- 2–10 min: Gotify push (medium priority)
|
||||
- > 10 min: Gotify push (high priority) + attempt auto-restart via `docker restart` API call to PD
|
||||
4. On recovery: send resolution notification with total downtime
|
||||
|
||||
**Why:** Uptime Kuma already sends webhooks but has no intelligence. This adds confirmation, suppression of transient blips, and auto-remediation for stuck containers.
|
||||
|
||||
---
|
||||
|
||||
### 12 — Pi-hole Stats Digest
|
||||
**Trigger:** Schedule (daily at 8 AM)
|
||||
**What it does:**
|
||||
1. Query Pi-hole API on PD (`http://10.5.1.6:8953/api/stats/summary`)
|
||||
2. Query secondary Pi-hole on Serenity
|
||||
3. LiteLLM summarizes notable blocked domains and compares primary vs secondary query load
|
||||
4. Push digest to Gotify (Pi-hole app) with 24h block count, top blocked domains, and any unusual spikes
|
||||
|
||||
**Why:** Passive DNS visibility — know if something on your network is phoning home unexpectedly.
|
||||
|
||||
---
|
||||
|
||||
### 13 — Lidarr → Kima-Hub New Music Notifier
|
||||
**Trigger:** Lidarr webhook on album download complete
|
||||
**What it does:**
|
||||
1. Receive download event from Lidarr
|
||||
2. Fetch album art and metadata from MusicBrainz or Lidarr API
|
||||
3. Format a rich notification: artist, album, year, genre
|
||||
4. Push to Gotify (Music app) with album art link
|
||||
5. Optionally trigger Kima-Hub library rescan via API
|
||||
|
||||
**Why:** Know when new music lands without watching Lidarr activity logs.
|
||||
|
||||
---
|
||||
|
||||
### 14 — Paperless Inbox Reminder
|
||||
**Trigger:** Schedule (every Monday 9 AM)
|
||||
**What it does:**
|
||||
1. Query Paperless API for documents with no tags or in the inbox
|
||||
2. If count > 0: push reminder to Gotify listing the oldest unprocessed documents
|
||||
3. If inbox is clear: send a ✅ confirmation
|
||||
|
||||
**Why:** It's easy to forget to process scanned documents. This ensures nothing sits in the inbox untagged for weeks.
|
||||
|
||||
---
|
||||
|
||||
### 15 — n8n Self-Health Monitor
|
||||
**Trigger:** Schedule (every 15 min)
|
||||
**What it does:**
|
||||
1. Check n8n's own execution history via API — look for failed executions in the past hour
|
||||
2. If failures found: fetch the error message from n8n API
|
||||
3. Push a "Workflow Failed" notification to Gotify (n8n Health app) with the workflow name and error summary
|
||||
4. Skip if the failure is the same as the last-notified one (dedup via Postgres)
|
||||
|
||||
**Why:** n8n doesn't natively alert you when a workflow silently fails. This closes that blind spot.
|
||||
|
||||
---
|
||||
|
||||
### 16 — NFS Mount Watchdog + Auto-Heal
|
||||
**Trigger:** Schedule (every 5 min)
|
||||
**What it does:**
|
||||
1. SSH into PD (10.5.1.6) and probe each expected NFS mount path with `mountpoint -q`:
|
||||
- `/mnt/unraid/data/media` (Plex, Audiobookshelf)
|
||||
- `/mnt/unraid/data/photos` (Immich)
|
||||
- Any other mounts defined in the mount script
|
||||
2. If all mounts are healthy: silent exit
|
||||
3. If any mount is missing:
|
||||
a. Run the NFS mount script: `sudo bash /mnt/tank/docker/scripts/mount-unraid-nfs.sh`
|
||||
b. Wait 10 seconds, re-probe to confirm mounts came up
|
||||
c. If mounts confirmed: restart only the affected containers:
|
||||
- Media mount missing → `sudo docker restart plex audiobookshelf`
|
||||
- Photos mount missing → `sudo docker restart immich-server immich-microservices immich-machine-learning`
|
||||
d. If mounts still missing after script: escalate to Gotify (high priority — NFS down, manual intervention needed)
|
||||
4. Push result to Gotify (Infra app):
|
||||
- Auto-healed: priority 5, list which mounts were remounted and which containers restarted
|
||||
- Escalation: priority 9, list which paths are still unavailable
|
||||
|
||||
**Implementation notes:**
|
||||
- Uses n8n SSH node connecting to `10.5.1.6` with an SSH credential (key-based auth from n8n container)
|
||||
- SSH node runs a single compound command: `mountpoint -q /mnt/unraid/data/media && echo MEDIA_OK || echo MEDIA_MISSING` etc.
|
||||
- Parse output in a Code node to determine which mounts failed
|
||||
- Use separate SSH nodes for: (1) running the mount script, (2) restarting containers — keeps the flow readable
|
||||
- `continueOnFail: true` on the mount script SSH node so a TrueNAS-unreachable scenario still escalates instead of dying silently
|
||||
- Add a Postgres dedup table (`nfs_heal_log`) so repeated failures within 30 min only send one Gotify push, but every successful auto-heal always notifies
|
||||
|
||||
**Why:** TrueNAS reboots (updates, power blips) drop NFS mounts and crash-loop dependent containers. This closes the gap between "Serenity rebooted at 3 AM" and "you notice Immich is broken at noon."
|
||||
|
||||
---
|
||||
|
||||
## Suggested Gotify App / Channel Structure
|
||||
|
||||
Based on all workflows above, here's the full recommended channel layout:
|
||||
|
||||
| App Name | Workflows |
|
||||
|----------|-----------|
|
||||
| Grafana Alerts | 01 |
|
||||
| Paperless | 03 |
|
||||
| Paperless RAG | 05 |
|
||||
| RSS Feed | 06 |
|
||||
| Git Commits | 07 |
|
||||
| Class Recordings | 08 |
|
||||
| Immich | 09 (new) |
|
||||
| Morning Briefing | 10 (new) |
|
||||
| Uptime / Infra | 11, 16 (new) |
|
||||
| Pi-hole | 12 (new) |
|
||||
| Music | 13 (new) |
|
||||
| Reminders | 14 (new) |
|
||||
| n8n Health | 15 (new) |
|
||||
| Whisper | 04 (after upgrade) |
|
||||
Reference in New Issue
Block a user