Skip to content

Error Handling

A global error monitoring and alerting system that automatically captures workflow failures across your n8n instance and immediately notifies administrators via Telegram. This workflow serves as a safety net, ensuring no critical errors go unnoticed and enabling rapid response to system issues.

Purpose

No business context provided yet — add a context.md to enrich this documentation.

From a technical perspective, this workflow provides centralized error monitoring for all n8n workflows. When any workflow fails, this system automatically captures the error details, filters out manual test runs, retrieves admin contact information from the database, and sends immediate alerts via Telegram. This ensures administrators can quickly respond to production issues and maintain system reliability.

How It Works

  1. Error Detection: The Error Trigger automatically fires whenever any workflow in the n8n instance encounters an error
  2. Environment Filtering: The system checks if the error occurred during a manual test run and filters these out to avoid spam
  3. Admin Lookup: Retrieves all administrator records from the PostgreSQL database, including their Telegram chat IDs
  4. Message Distribution: Splits the admin list to send individual notifications to each administrator
  5. Alert Delivery: Sends formatted error messages to each admin via Telegram, including workflow name, error details, failed node, and execution URL

The alert message format includes: [Workflow Name]: [Error Message] [Failed Node] [Execution URL]

Workflow Diagram

graph TD
    A[Error Trigger] --> B[Filter Non Prod runs]
    B --> C[Get Admins]
    C --> D[Split Out]
    D --> E[Telegram]

Trigger

Error Trigger: Automatically activates when any workflow in the n8n instance encounters an error or failure. This is a global trigger that monitors all workflow executions.

Nodes Used

Node Type Node Name Purpose
Error Trigger Error Trigger Captures error events from any workflow in the instance
Filter Filter Non Prod runs Excludes manual test runs to prevent alert spam
Postgres Get Admins Retrieves administrator records from the database
Split Out Split Out Separates admin records for individual message delivery
Telegram Telegram Sends error alerts to administrators

External Services & Credentials Required

PostgreSQL Database

  • Credential: "Postgres Waringa"
  • Purpose: Stores administrator information including Telegram chat IDs
  • Required Table: admins table with tg_chat_id field

Telegram Bot

  • Credential: "Waringa" Telegram API
  • Purpose: Delivers error notifications to administrators
  • Requirements: Bot token and admin chat IDs configured in database

Environment Variables

No specific environment variables are required. The workflow uses: - Database connection details (stored in PostgreSQL credential) - Telegram bot token (stored in Telegram credential) - Admin chat IDs (retrieved from database)

Data Flow

Input

  • Error data from failed workflows (automatically provided by Error Trigger)
  • Execution context including workflow name, error message, failed node, and execution URL

Processing

  • Filters out manual execution errors
  • Retrieves admin contact information from database
  • Formats error messages for Telegram delivery

Output

  • Telegram messages sent to each administrator
  • Message format: [Workflow]: [Error] [Node] [URL]

Error Handling

This workflow itself serves as the error handling mechanism for the entire n8n instance. If this workflow fails: - Errors would not be captured or reported - Consider setting up external monitoring for this critical workflow - Ensure database and Telegram credentials remain valid

Known Limitations

  • Only filters out manual runs; all other execution modes trigger alerts
  • Requires administrators to have Telegram chat IDs stored in the database
  • No rate limiting - multiple rapid failures could flood Telegram notifications
  • No error categorization or severity levels
  • Telegram message length limits may truncate very long error messages

No related workflows specified in the context.

Setup Instructions

  1. Import the Workflow

    • Import the JSON into your n8n instance
    • Activate the workflow to enable global error monitoring
  2. Configure PostgreSQL Connection

    • Create credential named "Postgres Waringa"
    • Ensure database contains admins table with tg_chat_id field
    • Populate admin records with valid Telegram chat IDs
  3. Set Up Telegram Bot

    • Create a Telegram bot and obtain the API token
    • Create credential named "Waringa" with the bot token
    • Ensure bot can send messages to admin chat IDs
  4. Database Schema

    1
    2
    3
    4
    5
    CREATE TABLE admins (
      id SERIAL PRIMARY KEY,
      tg_chat_id VARCHAR(255) NOT NULL,
      -- other admin fields as needed
    );
    

  5. Test the Setup

    • Create a test workflow with an intentional error
    • Run it in production mode (not manual)
    • Verify Telegram alerts are received
  6. Verify Activation

    • Ensure this workflow is activated and running
    • Monitor for any configuration issues in the execution log