Error Handling¶
This workflow provides centralized error monitoring and notification for all n8n workflows in your system. When any workflow fails, it automatically notifies system administrators via Telegram, ensuring critical issues are addressed promptly.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
This workflow serves as a safety net for your entire n8n automation ecosystem. It captures errors from any workflow execution and immediately alerts administrators, enabling rapid response to system failures and maintaining operational reliability.
How It Works¶
- Error Detection: The workflow is triggered whenever any other workflow in your n8n instance encounters an error
- Environment Filtering: It checks if the error occurred in a production environment (excludes manual test runs)
- Admin Lookup: Retrieves a list of system administrators from the database
- Notification Distribution: Sends detailed error notifications to each administrator via Telegram
The notification includes the workflow name, error message, the node that failed, and a direct link to the execution for quick troubleshooting.
Mermaid 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 fails with an error. This is a system-level trigger that monitors all workflow executions.
Nodes Used¶
| Node | Type | Purpose |
|---|---|---|
| Error Trigger | Trigger | Detects workflow failures across the entire n8n instance |
| Filter Non Prod runs | Filter | Excludes manual test executions from notifications |
| Get Admins | Postgres | Retrieves administrator contact information from database |
| Split Out | Data Transformation | Separates admin records for individual notifications |
| Telegram | Communication | Sends error alerts to administrators |
External Services & Credentials Required¶
Telegram¶
- Credential:
telegramApi(Telegram account) - Purpose: Send error notifications to administrators
- Setup: Requires bot token and chat permissions
PostgreSQL Database¶
- Credential:
postgres(Postgres account) - Purpose: Access administrator contact information
- Requirements: Read access to
adminstable withtg_chat_idfield
Environment Variables¶
No environment variables are directly used in this workflow. Configuration is handled through:
- Database records in the admins table
- Telegram bot credentials
- n8n execution context (automatically provided)
Data Flow¶
Input¶
- Error information from failed workflow executions (automatically provided by Error Trigger)
- Execution context including workflow name, error message, and failed node
Processing¶
- Filters out manual test runs
- Retrieves administrator Telegram chat IDs from database
- Formats error message with workflow details and execution URL
Output¶
- Telegram messages sent to each administrator containing:
- Workflow name that failed
- Error message
- Last executed node
- Direct link to execution details
Error Handling¶
This workflow itself has minimal error handling since it's the primary error notification system. If this workflow fails: - No notifications will be sent for other workflow failures - The failure will be logged in n8n's execution history - Consider setting up external monitoring for this critical workflow
Known Limitations¶
- Depends on administrators having active Telegram accounts
- Requires database connectivity to retrieve admin list
- No retry mechanism if Telegram delivery fails
- Manual test runs are excluded from notifications (by design)
Related Workflows¶
This workflow monitors all other workflows in your n8n instance. No specific related workflows are defined in the current context.
Setup Instructions¶
-
Import the Workflow
- Copy the workflow JSON and import into your n8n instance
-
Configure Database Connection
- Set up PostgreSQL credentials with access to your database
- Ensure an
adminstable exists with at least atg_chat_idcolumn
-
Set Up Telegram Bot
- Create a Telegram bot via @BotFather
- Configure the Telegram API credentials in n8n
- Ensure the bot can send messages to administrator chats
-
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 ); -
Test the Setup
- Add admin records to the database with valid Telegram chat IDs
- Create a test workflow that intentionally fails
- Verify notifications are received
-
Activate the Workflow
- Ensure the workflow is set to "Active" status
- Monitor the execution history to confirm it's working properly
Important: This workflow should remain active at all times to ensure continuous error monitoring across your automation system.