Skip to content

[RECOVERY] 2026-04-19 Samahani Reprocessing

This workflow sends personalized apology messages to users affected by a system issue on April 19, 2026, delivering context-aware follow-ups via WhatsApp and SMS to resume interrupted conversations.

Purpose

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

Based on the workflow structure and message content, this appears to be a recovery workflow for the Sifa coaching program that sends apology messages in Swahili to participants who experienced service disruption. The messages acknowledge the technical issue ("Samahani kwa tatizo kidogo mapema leo") and attempt to resume conversations where they left off, with different message types based on each user's previous interaction state.

How It Works

  1. Webhook Trigger: The workflow starts when triggered via a POST request to a specific recovery endpoint
  2. Message Preparation: A hardcoded list of 23 users is prepared, each with personalized messages in Swahili addressing their specific conversation state
  3. Batch Processing: Users are processed one by one through a loop to avoid overwhelming the messaging services
  4. Channel Routing: Each message is routed to either WhatsApp or SMS based on the user's preferred channel
  5. Message Delivery: Messages are sent via Twilio (WhatsApp) or Africa's Talking (SMS)
  6. Conversation Logging: All sent messages are logged to a PostgreSQL database for chat history tracking
  7. Loop Continuation: The process continues until all users have been contacted

Workflow Diagram

graph TD
    A[Trigger] --> B[Build Payloads]
    B --> C[Loop]
    C --> D[Is WhatsApp?]
    D -->|Yes| E[Send WhatsApp]
    D -->|No| F[Send SMS]
    E --> G[Log to Chat History]
    F --> G[Log to Chat History]
    G --> C

Trigger

Type: Webhook (POST) - Path: recovery-2026-04-19-c885bdcc - Method: POST - Purpose: Manual trigger for initiating the recovery message broadcast

Nodes Used

Node Type Node Name Purpose
Webhook Trigger Receives POST requests to start the recovery process
Code Build Payloads Creates hardcoded list of 23 users with personalized messages
Split in Batches Loop Processes users one at a time to manage API rate limits
If Is WhatsApp? Routes messages based on preferred communication channel
Twilio Send WhatsApp Delivers messages via WhatsApp using Twilio API
HTTP Request Send SMS Sends SMS messages via Africa's Talking API
Postgres Log to Chat History Records all sent messages in the database

External Services & Credentials Required

Twilio (WhatsApp)

  • Credential: twilioApi (ID: dEOy4AckE29MTkk3)
  • Purpose: WhatsApp message delivery
  • From Number: +254203892316

Africa's Talking (SMS)

  • Credential: httpHeaderAuth (ID: qkTdbp6iyC0rwCMB)
  • Purpose: SMS message delivery
  • Username: toll_free_sms_ke
  • Short Code: 24436

PostgreSQL Database

  • Credential: postgres (ID: EJPqF6MDH1ZwAzyv)
  • Purpose: Chat history logging
  • Table: n8n_chat_histories

Environment Variables

No environment variables are explicitly used in this workflow. All configuration is handled through n8n credentials and hardcoded values.

Data Flow

Input

  • Trigger: Empty POST request to webhook endpoint
  • Processing: Hardcoded array of 23 user objects, each containing:
    • phoneNumber: Kenyan phone number (+254...)
    • firstName: User's first name
    • channel: "WhatsApp" or "SMS"
    • message: Personalized Swahili message

Output

  • WhatsApp/SMS: Personalized messages delivered to users
  • Database: Chat history records with message content and metadata
  • Logging: Each message tagged with source: 'recovery_2026_04_19'

Error Handling

  • SMS Node: Configured with "Continue on Error" to prevent single SMS failures from stopping the entire workflow
  • Loop Structure: Ensures processing continues even if individual message deliveries fail
  • Database Logging: Attempts to log all messages regardless of delivery success

Known Limitations

  • Hardcoded Recipients: User list is embedded in the code node, making it inflexible for reuse
  • No Delivery Confirmation: Workflow doesn't verify message delivery success
  • Single Execution: Designed for one-time use on April 19, 2026
  • Language Specific: All messages are in Swahili, limiting reusability
  • No Retry Logic: Failed messages are not automatically retried

No related workflows identified from the provided context.

Setup Instructions

  1. Import Workflow: Import the JSON into your n8n instance

  2. Configure Credentials:

    • Set up Twilio API credentials for WhatsApp messaging
    • Configure Africa's Talking API credentials for SMS
    • Set up PostgreSQL database connection
  3. Database Setup: Ensure the n8n_chat_histories table exists with columns:

    • session_id (text)
    • message (jsonb)
    • created_time (timestamp)
  4. Verify Phone Numbers: Confirm all hardcoded phone numbers are valid and properly formatted

  5. Test Messaging Services: Verify both Twilio and Africa's Talking credentials work correctly

  6. Activate Workflow: Enable the workflow to make the webhook endpoint available

  7. Execute: Send a POST request to the webhook URL to trigger the recovery messages

Note: This workflow contains hardcoded user data and is designed for a specific recovery scenario. Modify the "Build Payloads" node to adapt it for different use cases.