Skip to content

V4 - EveningNudgeCron - Warenga

This workflow automatically sends daily evening check-in messages to active youth entrepreneurs who haven't submitted their daily business data yet. It runs every evening at 7 PM East Africa Time, sending a friendly Swahili greeting to prompt users to share how their day went.

Purpose

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

Based on the workflow implementation, this appears to be part of a youth entrepreneurship program that tracks daily business activities. The evening nudge serves as a gentle reminder for participants to log their daily progress, ensuring consistent data collection and engagement with the program.

How It Works

  1. Daily Trigger: Every day at 7 PM EAT (4 PM UTC), the workflow automatically starts
  2. Query Active Youth: Retrieves all active youth entrepreneurs who haven't submitted today's business data
  3. Filter Results: Checks if any youth need to be contacted
  4. Process Each Youth: Loops through each youth individually
  5. Compose Message: Creates a personalized Swahili greeting: "Niaje {firstName}! Siku yako imekuwa aje?" (Hey {name}! How has your day been?)
  6. Send Message: Calls the NudgeSender workflow to deliver the message via WhatsApp or SMS
  7. Continue Loop: Processes the next youth until all are contacted

Workflow Diagram

graph TD
    A[7PM EAT Trigger] --> B[Get Youth Without Today Data]
    B --> C{Has Youth?}
    C -->|Yes| D[Loop Over Youth]
    C -->|No| E[End]
    D --> F[Compose Evening Msg]
    F --> G[Call NudgeSender]
    G --> D
    D -->|All Processed| H[End]

Trigger

  • Type: Schedule Trigger
  • Frequency: Daily at 16:00 UTC (7:00 PM East Africa Time)
  • Status: Currently inactive (active: false)

Nodes Used

Node Type Purpose
7PM EAT (16:00 UTC) Schedule Trigger Starts the workflow daily at the specified time
Get Youth Without Today Data Postgres Queries database for active youth missing today's data
Has Youth? If Condition Checks if any youth were found in the query
Loop Over Youth Split in Batches Processes each youth individually
Compose Evening Msg Code (JavaScript) Creates personalized message with youth's name
Call NudgeSender Execute Workflow Sends the message via another workflow

External Services & Credentials Required

  • PostgreSQL Database: Stores youth entrepreneur data and daily tracking records
    • Credential: sifaV4Dev (ID: KG6Iw6AZuiJwopGr)
  • NudgeSender Workflow: Handles actual message delivery (Workflow ID: SRUua3GiNudDV1XK)

Environment Variables

No environment variables are directly used in this workflow. Configuration is handled through: - Database connection credentials - Workflow references for the NudgeSender

Data Flow

Input: None (triggered by schedule)

Database Query Returns: - phoneNumber: Contact number for the youth - firstName: Youth's first name for personalization - channel: Communication channel (WhatsApp/SMS) - businessOwned: Business information - current_micro_action: Current program step - current_micro_action_type: Type of current action - credit_module_active: Whether credit tracking is enabled

Output to NudgeSender: - phoneNumber: Recipient's phone number - message: Personalized Swahili greeting - nudge_step: Set to 'D1.3' - channel: Communication channel - nudge_type: Set to 'daily_evening' - firstName: Youth's first name

Error Handling

The workflow includes basic error handling: - Empty Results: The "Has Youth?" condition prevents processing when no youth are found - Missing Data: The compose step handles missing first names by defaulting to 'rafiki' (friend) - Channel Fallback: Defaults to 'whatsapp' if no channel is specified

Known Limitations

  • The workflow is currently inactive and needs to be manually enabled
  • No retry mechanism if the NudgeSender workflow fails
  • Limited error logging for debugging failed message deliveries
  • Hard-coded message text in Swahili may not be suitable for all users
  • NudgeSender (ID: SRUua3GiNudDV1XK): Handles the actual message delivery to youth entrepreneurs

Setup Instructions

  1. Import Workflow: Import the JSON into your n8n instance
  2. Configure Database Credential:
    • Create a PostgreSQL credential named sifaV4Dev
    • Connect to your youth entrepreneur database
  3. Verify NudgeSender Workflow: Ensure workflow SRUua3GiNudDV1XK exists and is properly configured
  4. Test Database Query: Run the workflow manually to verify the database query returns expected results
  5. Activate Workflow: Enable the workflow to start daily execution
  6. Monitor Execution: Check execution logs to ensure messages are being sent successfully

Database Requirements: - Tables: v4_youthEntrepreneurs, v4_dailyProfitTracking, v4_creditTracking - Required columns as referenced in the SQL query - Proper indexes for performance on daily queries