Error Handling¶
This workflow provides centralized error monitoring for n8n workflows by automatically notifying administrators via Telegram when any workflow fails in production environments. It acts as a safety net to ensure critical workflow failures don't go unnoticed.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
This workflow serves as a system-wide error monitoring solution that: - Captures errors from any n8n workflow in the system - Filters out manual test runs to avoid notification spam - Notifies all system administrators immediately when production workflows fail - Provides essential error details including workflow name, error message, failed node, and execution URL
How It Works¶
- Error Detection: The workflow automatically triggers whenever any other workflow in the system encounters an error
- Environment Filtering: It checks if the failed execution was a manual test run and skips notification for those cases
- Admin Lookup: Retrieves all administrator records from the database, specifically their Telegram chat IDs
- Message Distribution: Splits the admin list and sends individual error notifications to each administrator via Telegram
- Error Details: Each notification includes the workflow name, error message, failed node name, and a direct link to the execution
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. This is a system-level 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 system |
| Filter | Filter Non Prod runs | Excludes manual test runs from error notifications |
| Postgres | Get Admins | Retrieves administrator records with Telegram chat IDs |
| Split Out | Split Out | Separates admin records for individual message sending |
| Telegram | Telegram | Sends error notifications to each administrator |
External Services & Credentials Required¶
Telegram¶
- Credential:
Telegram account - Purpose: Send error notifications to administrators
- Requirements: Bot token with permission to send messages
PostgreSQL Database¶
- Credential:
Postgres account - Purpose: Access admin records with Telegram chat IDs
- Requirements: Read access to
adminstable inpublicschema
Environment Variables¶
No environment variables are used in this workflow. All configuration is handled through node parameters and database records.
Data Flow¶
Input¶
- Error trigger data containing:
- Workflow name and ID
- Error message and details
- Execution mode (manual, webhook, etc.)
- Failed node information
- Execution URL
Output¶
- Telegram messages sent to each administrator containing:
- Failed workflow name
- Error message
- Name of the node that failed
- Direct link to the failed execution
Database Schema Requirements¶
The admins table must include:
- tg_chat_id: Telegram chat ID for each administrator
Error Handling¶
This workflow itself has minimal error handling since it's designed to be the error handler for other workflows. If this workflow fails: - No notifications would be sent for subsequent errors - Manual monitoring of workflow executions would be required - Consider setting up external monitoring for this critical workflow
Known Limitations¶
- Relies on administrators having valid Telegram chat IDs in the database
- No retry mechanism if Telegram message delivery fails
- Manual test runs are filtered out, which may miss some legitimate testing scenarios
- No rate limiting - multiple rapid failures could spam administrators
Related Workflows¶
No related workflows specified in the context.
Setup Instructions¶
-
Import the Workflow
- Copy the workflow JSON and import it into your n8n instance
-
Configure Telegram Credentials
- Create a Telegram bot and obtain the bot token
- Set up the "Telegram account" credential with your bot token
-
Configure Database Credentials
- Set up the "Postgres account" credential with connection details
- Ensure the database contains an
adminstable withtg_chat_idcolumn
-
Prepare Admin Data
- Populate the
adminstable with administrator records - Each record must include a valid Telegram chat ID in the
tg_chat_idfield
- Populate the
-
Activate the Workflow
- Enable the workflow to start monitoring for errors
- Test by intentionally causing an error in another workflow (non-manual execution)
-
Verify Setup
- Check that administrators receive test notifications
- Confirm the error message format includes all necessary details