Templates / Diagnose failed workflows with a local Ollama model and send triage reports to Discord

Diagnose failed workflows with a local Ollama model and send triage reports to Discord

Ready for 3.0

by Joey Townsend ✓ · 0 views · created 2026-10-14 · DevOps, AI Summarization

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.

Nodes used (10)

Discord

What it does

Quick overview This workflow captures failed n8n executions, fetches the execution and workflow details via the n8n API, redacts sensitive data, sends the failure context to a local Ollama chat model for diagnosis, and posts a formatted triage message to Discord while deduplicating repeat failures. How it works 1. Triggers when a workflow errors, when called by another workflow’s error handler, or when run manually with sample failure IDs. 2. Normalizes the failure payload and applies runtime settings such as Ollama URL, model name, editor URL, and deduplication window. 3. Skips excluded workflow IDs to prevent alert loops, then uses the n8n API to fetch the failed execution (if available) and the workflow definition. 4. Builds a compact context for analysis, including the failing node definition and an upstream input sample, while redacting secrets and personal data. 5. Checks a n8n Data Table for recent matching fingerprints and skips diagnosing failures already handled within the configured deduplication period. 6. Sends the redacted context to Ollama’s /api/chat endpoint for a schema-constrained JSON diagnosis. A Code node then checks the model’s own labels before formatting the message: a proposed fix without an exact value, or one that rewrites code, is downgraded to ‘needs a human’, and confidence is capped when context is thin. The model never writes the delivered message. 7. Posts the diagnosis to Discord via a webhook and records the fingerprint and metadata to the Data Table for future deduplication. 8. Read-only by design: it explains and suggests fixes, and never changes the failing workflow. Setup 1. Add an n8n API credential and ensure your n8n instance URL is reachable so the workflow can read executions and workflow definitions. 2. Install and run Ollama on a host reachable from n8n, pull your chosen model (for example qwen3:8b), and set ollamaurl and model in the configuration values. 3. Create a n8n Data Table (for example triagehistory) with columns for fingerprint, workflowid, workflowname, failednode, errormessage, executionid, fixtype, and diagnosedat, then select it in both Data Table steps. 4. Add a Discord webhook credential and set the target webhook for posting the triage message. 5. Set n8neditorurl to your editor base URL and optionally populate excludedworkflowids to exclude your error handler workflow and any other workflows you don’t want diagnosed. 6. Edit Sample Failures with a real failed execution ID from your Executions list, then run Test with Sample Failures. 7. Set this workflow as the Error workflow of the workflows you want covered, or call it from your error handler (companion template: Send workflow failure alerts to Discord and log them in data tables). Requirements - n8n with API access and Data Tables - Ollama with a model that supports JSON-schema structured output (tested with Qwen 3 models) - A Discord server where you can create a webhook Customization - Point ollamaurl at any Ollama host, or swap Diagnose Failure for another chat API that supports structured output. - Tune deduphours and maxcontextchars in Build Config. - Replace Discord with Slack, Telegram or email. - Extend the redaction patterns in Redact and Build Context for your own secret formats. Additional info Only sees runs that fail: an expression that reads a missing field returns empty and the run succeeds, so add data checks for those. Nodes referenced with $(): Skip Excluded Workflows, Get Failed Execution, Redact and Build Context, Skip Repeat Failures, Format Diagnosis. Don’t rename them without updating the references.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.