Discover step-by-step instructions to set up an n8n error workflow connected to Slack and Google Sheets. By the end of this guide, you’ll have a fully operational workflow that sends Slack alerts and logs errors in Google Sheets for better visibility and accountability.
Prerequisites for Setting Up an n8n Error Workflow
To successfully follow this guide, ensure that the following requirements are met:
prerequisites
- Active n8n Environment: An operational instance of n8n, either self-hosted or in the cloud.
- Slack Credentials: Access to a Slack workspace and a bot token (via the Slack API) for sending messages.
Step-by-Step Workflow Creation
Follow these steps to create an error-handling workflow in n8n that logs errors to Google Sheets and sends notifications to Slack.
steps
Create an Error Workflow
Open your n8n instance and create a new workflow. Name itError Demoto keep things organized.Add the Error Trigger Node
- Add the
Error Triggernode to your workflow as its starting point. - No configurations are required for this node.
- Test the node by executing it and observe the sample error details that appear.
- Add the
Connect Google Sheets
- Add a
Google Sheetsnode connected to theError Triggernode. - Configure the Google Sheets node to use the "Append Row" operation.
- Authorize your Google account through the OAuth2 option (if not done already).
- Select your prepared Google Sheet and its corresponding sheet.
- Map required fields:
- Workflow Name: Use the output of the
Error Triggernode. - Workflow ID, Error URL, and Error Message: Drag relevant fields from the trigger output.
- Workflow Name: Use the output of the
- Add a
Add the Slack Node
- Add a
Slacknode and set its operation to "Post Message". - Connect your Slack credentials (ensure your bot has adequate permissions).
- Configure the message format:
Error in {{ $node["Error Trigger"].json["workflow.name"] }} Workflow ID: {{ $node["Error Trigger"].json["workflow.id"] }} Error Node: {{ $node["Error Trigger"].json["error.nodeLabel"] }} Message: {{ $node["Error Trigger"].json["error.message"] }} Description: {{ $node["Error Trigger"].json["error.description"] }} - Choose the Slack channel where alerts will be sent.
- Add a
Link Nodes
Ensure theError Triggernode connects to both theGoogle SheetsandSlacknodes. The execution flow should follow this sequence: Error Trigger → Google Sheets → Slack.Save the Workflow
Save your workflow to prevent losing progress.
Important Notes on Workflow Activation
Testing the Error Workflow
Testing is essential to verify that your error workflow works as intended.
steps
Set Up a Test Workflow
- Create a new workflow and name it
Error Test. - Add a
Schedule Triggernode (e.g., set to every 10 seconds). - Add a
Codenode with an invalid script, such as incomplete or incorrect JavaScript, to force an error.
- Create a new workflow and name it
Connect the Test Workflow
- In the
Error Testworkflow, open the settings menu (three dots in the top-right corner). - Assign the
Error Workflowin the “Error Workflow” field and save changes.
- In the
Activate and Test
- Activate both workflows (
Error DemoandError Test). - Monitor the behavior when the
Error Testworkflow fails:- A Slack alert should be sent to the selected channel.
- The error details should be appended to the Google Sheet.
- Activate both workflows (
Refine the Workflow
If required, adjust message formatting, error descriptions, or field mappings in both the Google Sheets and Slack nodes.
Takeaways from Building an n8n Error Workflow
FAQ
What is an n8n error workflow?
An n8n error workflow is a special type of automation that detects and handles errors occurring in other workflows. It allows for error logging and alerting mechanisms, such as via Slack notifications or Google Sheets.
Why is my n8n error workflow not triggering?
Ensure that the workflow it is monitoring is active. Error workflows rely on triggers from active workflows; if the monitored workflow is inactive, no errors will be passed to the error workflow.
Can I use alternatives to Slack for alerts?
Yes, you can replace the Slack node with other notification systems such as email, Discord, or Microsoft Teams by configuring the respective nodes in your error workflow.
What kind of errors can an error workflow detect?
An error workflow can capture any failed executions in n8n, such as node misconfigurations, missing data, or script errors from nodes like the Code module.
Official reference: n8n documentation.