Automation

How to Build an n8n Error Workflow with Slack Alerts

Discover step-by-step instructions to set up an n8n error workflow connected to Slack and Google Sheets.

5 min read

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

  1. Create an Error Workflow
    Open your n8n instance and create a new workflow. Name it Error Demo to keep things organized.

  2. Add the Error Trigger Node

    • Add the Error Trigger node 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.
  3. Connect Google Sheets

    • Add a Google Sheets node connected to the Error Trigger node.
    • 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 Trigger node.
      • Workflow ID, Error URL, and Error Message: Drag relevant fields from the trigger output.
  4. Add the Slack Node

    • Add a Slack node 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.
  5. Link Nodes
    Ensure the Error Trigger node connects to both the Google Sheets and Slack nodes. The execution flow should follow this sequence: Error Trigger → Google Sheets → Slack.

  6. 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

  1. Set Up a Test Workflow

    • Create a new workflow and name it Error Test.
    • Add a Schedule Trigger node (e.g., set to every 10 seconds).
    • Add a Code node with an invalid script, such as incomplete or incorrect JavaScript, to force an error.
  2. Connect the Test Workflow

    • In the Error Test workflow, open the settings menu (three dots in the top-right corner).
    • Assign the Error Workflow in the “Error Workflow” field and save changes.
  3. Activate and Test

    • Activate both workflows (Error Demo and Error Test).
    • Monitor the behavior when the Error Test workflow fails:
      • A Slack alert should be sent to the selected channel.
      • The error details should be appended to the Google Sheet.
  4. 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.