Skip to content

V4 - CreditFollowupCron - Warenga

An automated credit follow-up system that monitors scheduled reminders for youth entrepreneurs and sends personalized messages to encourage debt collection activities. This workflow runs every 10 minutes to ensure timely follow-ups are delivered without manual intervention.

Purpose

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

How It Works

  1. Schedule Check: Every 10 minutes, the workflow triggers automatically
  2. Query Due Followups: Searches the database for credit follow-ups that are due (not yet fired, scheduled time has passed, and youth is not emotionally paused)
  3. Validation: Checks if any due follow-ups were found
  4. Batch Processing: Processes up to 50 follow-ups in batches to avoid overwhelming the system
  5. Message Composition: For each follow-up, builds a personalized message based on the follow-up type and debtor information
  6. Message Delivery: Calls the NudgeSender workflow to deliver the message via the appropriate channel
  7. Status Update: Marks the follow-up as fired in the database to prevent duplicate sends

Workflow Diagram

graph TD
    A[Every 10 Minutes] --> B[Find Due Followups]
    B --> C{Has Due?}
    C -->|Yes| D[Loop Over Followups]
    C -->|No| E[End]
    D --> F[Build Followup Message]
    F --> G[Call NudgeSender]
    G --> H[Mark Followup Fired]
    H --> D
    D -->|Complete| I[End]

Trigger

  • Type: Schedule Trigger
  • Frequency: Every 10 minutes (*/10 * * * *)
  • Status: Currently inactive

Nodes Used

Node Type Purpose
Every 10 Minutes Schedule Trigger Triggers the workflow every 10 minutes
Find Due Followups Postgres Queries for credit follow-ups that are due to be sent
Has Due? IF Checks if any due follow-ups were found
Loop Over Followups Split in Batches Processes follow-ups one by one
Build Followup Message Code Creates personalized follow-up messages based on type
Call NudgeSender Execute Workflow Sends the message via another workflow
Mark Followup Fired Postgres Updates the database to mark follow-up as sent

External Services & Credentials Required

  • PostgreSQL Database: sifaV4Dev credential required
    • Used for querying due follow-ups and updating their status
  • NudgeSender Workflow: Workflow ID SRUua3GiNudDV1XK must exist
    • Handles the actual message delivery

Environment Variables

No specific environment variables are required for this workflow. All configuration is handled through: - Database credentials - Workflow references - Hardcoded cron schedule

Data Flow

Input

  • Triggered automatically by schedule (no external input required)

Database Query Results

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
  "followup_id": "string",
  "phoneNumber": "string", 
  "debtorName": "string",
  "debtorBalance": "number",
  "scheduledFollowupAt": "datetime",
  "followupType": "string",
  "followupMessage": "string",
  "firstName": "string",
  "channel": "string"
}

Message Output to NudgeSender

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
  "phoneNumber": "string",
  "message": "string",
  "nudge_step": "credit_followup",
  "channel": "string",
  "nudge_type": "credit_followup", 
  "template_sid": "",
  "firstName": "string",
  "followup_id": "string"
}

Error Handling

The workflow includes basic error handling through: - Conditional Logic: Only processes when due follow-ups exist - Batch Limiting: Processes maximum 50 records per run to prevent timeouts - Database Constraints: Prevents duplicate sends by checking followupFired status

No explicit error handling nodes are present, so failures will stop execution and require manual investigation.

Known Limitations

  • Batch Size: Limited to 50 follow-ups per 10-minute cycle
  • No Retry Logic: Failed messages are not automatically retried
  • Single Database: Only works with the configured PostgreSQL instance
  • Dependency: Requires NudgeSender workflow to be available and functional
  • No Error Notifications: Failures are not automatically reported
  • NudgeSender (SRUua3GiNudDV1XK): Handles actual message delivery for all follow-up types

Setup Instructions

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

  2. Configure Database Credential:

    • Create a PostgreSQL credential named sifaV4Dev
    • Ensure it has read/write access to tables:
      • v4_creditpathFollowup
      • v4_youthEntrepreneurs
  3. Verify NudgeSender Workflow:

    • Ensure workflow SRUua3GiNudDV1XK exists and is functional
    • Test that it can receive the expected message format
  4. Database Schema Requirements:

    1
    2
    3
    4
    5
    6
    -- Ensure these columns exist in v4_creditpathFollowup
    id, phoneNumber, debtorName, debtorBalance, scheduledFollowupAt, 
    followupType, followupMessage, followupFired, updatedAt
    
    -- Ensure these columns exist in v4_youthEntrepreneurs  
    phoneNumber, firstName, channel, is_emotionally_paused
    

  5. Test the Workflow:

    • Create test data with followupFired = false and scheduledFollowupAt in the past
    • Run manually to verify message generation and delivery
    • Check that followupFired is updated to true
  6. Activate: Enable the workflow to start automatic execution every 10 minutes