Skip to content

V4 - MiddayNudgeCron - Warenga

A daily automated workflow that sends midday check-in messages to active youth entrepreneurs at 2PM East Africa Time, prompting them to share how their business is progressing with a simple 3-option response system.

Purpose

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

How It Works

  1. Daily Trigger: Activates automatically at 11:00 UTC (2PM East Africa Time)
  2. Query Active Youth: Retrieves all active, non-paused youth entrepreneurs from the database, including their current micro-action status
  3. Validate Results: Checks if any youth records were found
  4. Process Each Youth: Loops through each youth entrepreneur individually
  5. Compose Message: Creates a personalized check-in message in Swahili asking about business progress
  6. Send Message: Calls the NudgeSender workflow to deliver the message via their preferred channel

Workflow Diagram

graph TD
    A["2PM EAT (11:00 UTC)<br/>Schedule Trigger"] --> B["Get Active Youth + Peer Tip<br/>PostgreSQL Query"]
    B --> C["Has Youth?<br/>Conditional Check"]
    C -->|Yes| D["Loop Over Youth<br/>Split in Batches"]
    D --> E["Compose Midday Msg<br/>JavaScript Code"]
    E --> F["Call NudgeSender<br/>Execute Workflow"]
    F --> D
    D -->|Complete| G[End]
    C -->|No| G

Trigger

  • Type: Schedule Trigger
  • Frequency: Daily at 11:00 UTC (2PM East Africa Time)
  • Status: Currently inactive

Nodes Used

Node Name Type Purpose
2PM EAT (11:00 UTC) Schedule Trigger Initiates the workflow daily at the specified time
Get Active Youth + Peer Tip PostgreSQL Queries database for active youth entrepreneurs and their micro-action status
Has Youth? If Condition Validates that youth records exist before processing
Loop Over Youth Split in Batches Processes each youth entrepreneur individually
Compose Midday Msg Code (JavaScript) Creates personalized check-in messages in Swahili
Call NudgeSender Execute Workflow Sends the composed message via external workflow

External Services & Credentials Required

Database

  • PostgreSQL: Connection to youth entrepreneur database
  • Credential ID: KG6Iw6AZuiJwopGr (sifaV4Dev)

Workflows

  • NudgeSender Workflow: ID SRUua3GiNudDV1XK for message delivery

Environment Variables

No environment variables are explicitly used in this workflow. All configuration is handled through node parameters and database credentials.

Data Flow

Input

  • Trigger: Time-based (no external input required)

Database Query Results

1
2
3
4
5
6
7
8
{
  "phoneNumber": "string",
  "firstName": "string", 
  "channel": "string",
  "businessOwned": "string",
  "current_micro_action": "string",
  "current_micro_action_type": "string"
}

Output to NudgeSender

1
2
3
4
5
6
7
8
9
{
  "phoneNumber": "string",
  "message": "Sasa [firstName]! Unaendeleaje na biz leo?\n\n1. Poa sana\n2. Iko Slow\n3. Iko kawaida tu",
  "nudge_step": "D1.2",
  "channel": "string",
  "template_sid": "",
  "nudge_type": "daily_midday",
  "firstName": "string"
}

Error Handling

The workflow includes basic error handling: - Conditional Check: Validates that youth records exist before attempting to process them - Fallback Values: Uses 'rafiki' as default firstName and 'whatsapp' as default channel if values are missing

No explicit error handling nodes are present for database connection failures or external workflow execution errors.

Known Limitations

  • The workflow is currently inactive and must be manually enabled
  • No error handling for database connection failures
  • No retry mechanism if the NudgeSender workflow fails
  • Limited to processing youth who are not emotionally paused
  • Message content is hardcoded in Swahili only
  • NudgeSender (ID: SRUua3GiNudDV1XK): Handles the actual message delivery to youth entrepreneurs

Setup Instructions

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

  2. Configure Database Credential:

    • Create a PostgreSQL credential named "sifaV4Dev"
    • Configure connection to the youth entrepreneur database
    • Ensure access to tables: v4_youthEntrepreneurs and v4_microaction_history
  3. Verify NudgeSender Workflow:

    • Ensure workflow ID SRUua3GiNudDV1XK exists and is properly configured
    • Test the NudgeSender workflow independently
  4. Database Schema Requirements:

    • Table v4_youthEntrepreneurs with columns: phoneNumber, firstName, channel, businessOwned, onboardingStatus, is_emotionally_paused
    • Table v4_microaction_history with columns: phonenumber, micro_action, micro_action_type, status
  5. Activate Workflow:

    • Enable the workflow in n8n
    • Verify the schedule trigger is set to 11:00 UTC
    • Monitor initial executions for any errors
  6. Test Execution:

    • Run a manual test execution to verify database connectivity
    • Check that messages are properly formatted and sent
    • Validate that the loop processes all active youth correctly