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¶
- Daily Trigger: Activates automatically at 11:00 UTC (2PM East Africa Time)
- Query Active Youth: Retrieves all active, non-paused youth entrepreneurs from the database, including their current micro-action status
- Validate Results: Checks if any youth records were found
- Process Each Youth: Loops through each youth entrepreneur individually
- Compose Message: Creates a personalized check-in message in Swahili asking about business progress
- 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
SRUua3GiNudDV1XKfor 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 | |
Output to NudgeSender¶
1 2 3 4 5 6 7 8 9 | |
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
Related Workflows¶
- NudgeSender (ID:
SRUua3GiNudDV1XK): Handles the actual message delivery to youth entrepreneurs
Setup Instructions¶
-
Import Workflow: Import the JSON configuration into your n8n instance
-
Configure Database Credential:
- Create a PostgreSQL credential named "sifaV4Dev"
- Configure connection to the youth entrepreneur database
- Ensure access to tables:
v4_youthEntrepreneursandv4_microaction_history
-
Verify NudgeSender Workflow:
- Ensure workflow ID
SRUua3GiNudDV1XKexists and is properly configured - Test the NudgeSender workflow independently
- Ensure workflow ID
-
Database Schema Requirements:
- Table
v4_youthEntrepreneurswith columns: phoneNumber, firstName, channel, businessOwned, onboardingStatus, is_emotionally_paused - Table
v4_microaction_historywith columns: phonenumber, micro_action, micro_action_type, status
- Table
-
Activate Workflow:
- Enable the workflow in n8n
- Verify the schedule trigger is set to 11:00 UTC
- Monitor initial executions for any errors
-
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