Skip to content

Alerts-V2-Testing

This workflow provides automated SMS alerting for system errors by monitoring n8n workflow failures and immediately notifying a predefined list of team members via Africa's Talking SMS service. When any workflow in the system encounters an error, this workflow triggers automatically and sends detailed error information to key stakeholders.

Purpose

No business context provided yet — add a context.md to enrich this documentation.

This workflow serves as a critical monitoring and notification system for n8n workflow failures. It ensures that when automated processes fail, the right people are immediately informed with actionable details including error messages, execution IDs, and direct links to logs for quick troubleshooting.

How It Works

  1. Error Detection: The workflow automatically triggers whenever any other workflow in the n8n instance encounters an error
  2. Recipient Processing: A JavaScript code node processes the error data and creates individual records for each team member who should be notified
  3. SMS Delivery: For each recipient, an SMS is sent via Africa's Talking containing the error details, execution ID, timestamp, and a direct link to the execution logs

The SMS format includes: - Clear "SYSTEM ALERT" header - Error message details - Execution ID for tracking - Timestamp of the failure - Direct URL to view logs in n8n

Workflow Diagram

graph TD
    A[Error Trigger] --> B[Code in JavaScript]
    B --> C[Send SMS via Africa's Talking]

    style A fill:#ff6b6b
    style B fill:#4ecdc4
    style C fill:#45b7d1

Trigger

Error Trigger: This workflow uses n8n's built-in Error Trigger node, which automatically activates whenever any other workflow in the same n8n instance fails or encounters an error. No manual intervention or scheduling is required.

Nodes Used

Node Type Node Name Purpose
Error Trigger Error Trigger Automatically detects workflow failures across the n8n instance
Code (JavaScript) Code in JavaScript Processes error data and creates individual records for each SMS recipient
HTTP Request Send SMS via Africa's Talking Sends SMS notifications using Africa's Talking API

External Services & Credentials Required

Africa's Talking SMS Service

  • Service: Africa's Talking SMS API
  • Endpoint: https://api.africastalking.com/version1/messaging
  • Required Credentials:
    • API Key (currently hardcoded in workflow - should be moved to environment variables)
    • Username: toll_free_sms_ke
    • Sender ID: Educate

Security Note: The API key is currently hardcoded in the workflow. For production use, this should be stored as an environment variable or n8n credential.

Environment Variables

Currently, no environment variables are used. The following should be configured for better security:

  • AFRICAS_TALKING_API_KEY: API key for Africa's Talking service
  • AFRICAS_TALKING_USERNAME: Username for the SMS service
  • SMS_SENDER_ID: Sender identifier for SMS messages

Data Flow

Input

The Error Trigger automatically provides: - execution.error.message: Details of the error that occurred - execution.id: Unique identifier for the failed execution - execution.url: Direct link to view the execution in n8n - Additional execution metadata

Processing

The JavaScript code node: - Takes the error data from the trigger - Creates a recipient list with 7 team members (names and phone numbers) - Generates individual output records for each recipient

Output

Each SMS contains: - System alert header - Error message - Execution ID - Formatted timestamp - Direct URL to execution logs

Error Handling

This workflow does not include explicit error handling mechanisms. If the SMS sending fails, there is no retry logic or alternative notification method. Consider adding: - Retry logic for failed SMS sends - Fallback notification methods (email, Slack, etc.) - Error logging for the alerting system itself

Known Limitations

  • API key is hardcoded in the workflow (security risk)
  • No retry mechanism if SMS delivery fails
  • Fixed recipient list requires workflow modification to update
  • No rate limiting or duplicate alert prevention
  • Workflow is currently inactive ("active": false)

No related workflows specified in the current context.

Setup Instructions

  1. Import the Workflow

    • Copy the workflow JSON
    • Import into your n8n instance via the workflow import function
  2. Configure Africa's Talking

    • Sign up for Africa's Talking SMS service
    • Obtain API credentials
    • Replace the hardcoded API key in the HTTP Request node with your credentials
  3. Update Recipients

    • Modify the recipients array in the JavaScript code node
    • Add or remove team members as needed
    • Ensure phone numbers are in international format (+254...)
  4. Security Improvements

    • Move the API key to n8n credentials or environment variables
    • Update the HTTP Request node to use credential references instead of hardcoded values
  5. Activate the Workflow

    • Set the workflow status to active
    • Test by intentionally causing an error in another workflow
  6. Verify Setup

    • Create a test workflow that fails
    • Confirm SMS alerts are received by all recipients
    • Check that links and formatting are correct

Important: This workflow will trigger for ALL workflow errors in your n8n instance. Ensure your recipient list is appropriate for your organization's alerting needs.