Quick overview
This workflow provides an n8n “safety net” by logging failed workflow executions to an n8n Data Table and sending email alerts, and by fingerprinting workflows nightly or via a secured webhook using the n8n API to detect suspicious edits and store clean versions.
How it works
- Triggers when another workflow errors (as an n8n error workflow), on a nightly schedule, or via a Header Auth–protected webhook for before/after edit checks.
- Routes the incoming event to either the incident-handling path or the workflow snapshot/guard path based on the payload.
- For incidents, extracts key failure details (workflow, execution ID, failed node, error message, and execution URL) and inserts them into an n8n Data Table as a dead-letter log.
- Sends an SMTP email alert with the incident details even if the Data Table insert fails.
- For snapshots, uses the n8n API to fetch workflows and computes a content-based fingerprint (hash, node count, non-ASCII counts, U+FFFD replacement characters, and question marks).
- Compares the current fingerprints to the latest stored fingerprints in an n8n Data Table, stores a new workflow version and updates the latest fingerprint when changes are safe, and flags warnings/errors for suspicious changes.
- Emails a report when warnings or errors are detected, and for webhook-driven checks responds with JSON and an HTTP 409 status on errors so calling scripts can stop a deployment.
Setup
- Create three n8n Data Tables named
workflow_incidents, workflow_versions, and workflow_fingerprints with the columns expected by the insert/upsert steps.
- Add credentials for n8n API (to read workflows), SMTP (to send alerts), and Header Auth (to protect the webhook endpoint).
- Update the recipient and sender addresses in the workflow settings values (
alertTo and alertFrom).
- Activate (publish) this workflow so the nightly schedule and the webhook run, then set it as the "Error workflow" in the settings of each workflow you want to protect.
- For API-based edits, call the webhook with
{"action":"before"|"after","workflowId":"<id>"} and ensure your script stops if the response status is 409.
Requirements
- n8n with data tables. Tested on n8n 2.47.7 (self-hosted).