n8n tutorial - Lesson 20: Error Handling in n8n: Build a Production Error Workflow
Hi everyone, in this session of the n8n Workflow Automation Tutorial series, we cover n8n error handling — specifically how to build a centralized Error Handler workflow that sends automatic Telegram alerts whenever any of your production workflows fail. This is a must-have pattern before you scale beyond a handful of active workflows.
How to do:
Step 1 — Create the Error Handler Workflow
Build a new workflow namedT6-B1-Error-Handler with 3 nodes connected in sequence.
- Create a new workflow and name it
T6-B1-Error-Handler. - Add the Error Trigger node — this is an n8n built-in node that automatically receives the execution context whenever a linked workflow fails.
- The Error Trigger provides four key fields from the failed execution:
workflow.name— name of the failed workflowexecution.lastNodeExecuted— the node where execution stoppedexecution.error.message— the error message textexecution.url— direct link to the failed execution in your n8n instance
Step 2 — Add a Code Node to Format the Error Message
Add a Code node after the Error Trigger to build a clean, readable Markdown message for Telegram.- Add a Code node and name it
Format Error Message. - Extract the four fields from the error context:
workflow.name,execution.lastNodeExecuted,execution.error.message, andexecution.url. - Truncate the error message if it exceeds 400 characters — long error strings break Telegram message formatting.
- Build the output as a Markdown legacy string with this structure:
- A header line (e.g.,
⚠️ Workflow Failed) - Workflow name
- Last node that failed
- Timestamp
- Truncated error message
- Clickable execution URL link
- A header line (e.g.,
Tip — Use Markdown legacy mode in Telegram (not MarkdownV2). MarkdownV2 requires escaping many special characters that commonly appear in error messages, which causes send failures in production.
Step 3 — Add the Telegram Send Node
Add a Telegram node as the final step to deliver the alert.- Add a Telegram node connected after
Format Error Message. - Set Resource to
Messageand Operation toSend Message. - Set the Text field to reference the formatted message output from the Code node.
- Set Parse Mode to
Markdown(legacy format). - Ensure Append Attribution is turned OFF — attribution adds extra text to the message that pollutes alert readability.
- Make sure the workflow is set to Active — the Error Handler must be active to receive triggered events from other workflows.
Step 4 — Apply the Error Workflow Setting to Your Production Workflows
Link each of your production workflows toT6-B1-Error-Handler through their individual settings.
- Open each workflow you want to protect (in this session: 8 workflows from Week 5 —
T5-B2,T5-B2b,T5-B3,T5-B3b,T5-B4,T5-B5,T5-B6,T5-B7). - Click the Settings ⚙️ icon inside the workflow editor.
- Find the Error Workflow dropdown and select
T6-B1-Error-Handler. - Click Save.
- Repeat for all 8 workflows — this setting works for both Active workflows and Manual workflows.
Tip — You only need one shared Error Handler workflow for all your workflows. You do not need a separate error handler per workflow. This centralized pattern keeps alert management simple and consistent.
Step 5 — Test the Error Workflow with a Production Execution
Testing the Error Workflow requires a production execution — the standard test UI will not trigger it.- Create a temporary test workflow named
T6-B1-Test-Trigger-Error. - Do NOT use a Manual Trigger for this test — manually running a workflow via the Execute Workflow button (the flask 🧪 icon) runs in test mode, which does not trigger the Error Workflow.
- Instead, use a Schedule Trigger set to run every 1 minute.
- Deliberately build the workflow so it will fail (e.g., reference a node that does not exist or misconfigure a required field).
- Set the test workflow to Active.
- Wait up to 1 minute for the Schedule Trigger to fire a production execution.
- Confirm the failure appears in Executions without the flask 🧪 icon — no flask means it was a production execution.
- Verify the Telegram alert arrives with the correct workflow name, failed node, error message, and execution URL.
- After the test passes, toggle the test workflow Active OFF or delete it to prevent repeated alerts every minute.
Production tip — In the n8n Executions list, executions with a flask 🧪 icon are test executions and will never trigger the Error Workflow. Executions without that icon are production executions and will trigger it. Always check for the flask icon when debugging why your Error Workflow is not firing.
Key Lessons from This Session
- Error Workflow only fires on production executions. Test mode (flask 🧪 icon, triggered via the Execute Workflow UI button) does not trigger the Error Workflow — only Schedule Triggers, Webhooks, or other external production triggers do.
- One Error Handler covers all workflows. You apply the same
T6-B1-Error-Handlerto as many source workflows as needed via Settings ⚙️ → Error Workflow — no duplication required. - Truncate long error messages in code. Cap error message text at 400 characters before sending to Telegram — raw error messages can be very long and break message formatting.
- Use Markdown legacy, not MarkdownV2, for Telegram alerts. Error messages contain special characters that MarkdownV2 requires escaping, which causes frequent send failures.
- The Error Handler workflow must be Active. If the Error Handler workflow is inactive, it will not receive any triggered events regardless of how many source workflows are linked to it.
- Clean up test workflows after verification. A Schedule-triggered test workflow set to every 1 minute will keep firing and generating alerts — always toggle it off or delete it immediately after the test passes.
- The Error Trigger node provides all execution context automatically. You do not need to pass data manually —
workflow.name,execution.url,execution.error.message, andexecution.lastNodeExecutedare all available directly in the node output.
Conclusion:
In this n8n tutorial, we built a production-grade error handling pattern using a 3-node Error Handler workflow — Error Trigger, Code formatter, and Telegram alert — and applied it to 8 active production workflows through the Settings → Error Workflow option. The most important insight from this session is the distinction between test executions and production executions: the Error Workflow will only fire in production, so always validate it with a Schedule Trigger rather than the manual Execute button. This error handling setup is now the safety net for the entire n8n workflow automation system built across Week 5, and the next session moves on to the Sub-workflow pattern using the Execute Workflow node.
If you have any questions, feel free to leave a comment below. Thank you!
Tags: n8n error handling, n8n tutorial, n8n workflow automation, n8n error trigger, n8n telegram alert, n8n production workflow, n8n error workflow setup, workflow monitoring n8n
Maybe you are interested!
- Getting Started with n8n: Interface & Your First Manual Trigger
- n8n HTTP Request Node: Connect Any API Without Code
- Branching Workflows: IF, Switch & Merge Nodes in n8n
- n8n Expressions & Built-in Variables: The Complete Guide
- Comparing AI Models in n8n: Claude vs Gemini vs ChatGPT
- Connect Gmail to n8n: OAuth Setup & Reading Emails
- Build an AI Email Classifier with n8n
- Automated Email Digest to Telegram with n8n
- Google Sheets Automation with n8n: 4 Key Operations
- Auto-Generate Google Docs from Data with n8n