See llms.txt for all machine-readable content.

Back to Templates

Diagnose failed workflows with OpenAI and send throttled Telegram alerts

Quick overview

This workflow triggers on n8n workflow failures, fingerprints and throttles duplicate errors, uses an OpenAI chat model to generate a structured diagnosis, and sends formatted Telegram alerts that notify loudly for high/critical issues and silently for lower-severity ones.

How it works

  1. Triggers whenever a connected n8n workflow execution fails via the Error Trigger.
  2. Builds an error fingerprint from the workflow, failing node, and normalized error message, then throttles repeats during a configurable cooldown window using workflow static data.
  3. If the error is not throttled, sends the failure context (message, description, truncated stack trace, and metadata) to an OpenAI chat model to return a structured diagnosis.
  4. Formats an HTML-safe Telegram message including severity, likely cause, suggested fix, fix steps, and the number of suppressed repeats (or falls back to raw error details if the AI step fails).
  5. Routes the alert by severity and sends it to Telegram as a normal notification for critical/high issues or as a silent message for medium/low issues.
  6. If the error is throttled, records that a duplicate was suppressed and skips sending a Telegram message.

Setup

  1. Add an OpenAI credential to the OpenAI Chat Model node and confirm the selected model is available for your account.
  2. Create a Telegram bot with @BotFather, add a Telegram credential in n8n, and ensure both Telegram send nodes use it.
  3. In the Configuration step, set your target telegramChatId, adjust cooldownMinutes, maxStackLines, and instanceLabel as needed.
  4. Activate this workflow, then in each workflow you want monitored set Settings → Error Workflow to this workflow so failures are forwarded here.

Requirements

  • An OpenAI API key (or swap in any other chat model sub-node)
  • A Telegram bot token from @BotFather and your chat ID

Customization

  • Change cooldownMinutes in Configuration to mute repeats for longer or shorter
  • Replace the Telegram nodes with Slack, Discord or email; the alert text is in $json.message
  • Edit the AI system prompt to describe your own stack for sharper diagnoses

Additional info

Throttling uses workflow static data, which only persists in active (production) runs, so manual test runs always send an alert.