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¶
- Schedule Check: Every 10 minutes, the workflow triggers automatically
- 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)
- Validation: Checks if any due follow-ups were found
- Batch Processing: Processes up to 50 follow-ups in batches to avoid overwhelming the system
- Message Composition: For each follow-up, builds a personalized message based on the follow-up type and debtor information
- Message Delivery: Calls the NudgeSender workflow to deliver the message via the appropriate channel
- 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:
sifaV4Devcredential required- Used for querying due follow-ups and updating their status
- NudgeSender Workflow: Workflow ID
SRUua3GiNudDV1XKmust 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 | |
Message Output to NudgeSender¶
1 2 3 4 5 6 7 8 9 10 | |
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
Related Workflows¶
- NudgeSender (
SRUua3GiNudDV1XK): Handles actual message delivery for all follow-up types
Setup Instructions¶
-
Import Workflow: Import the JSON into your n8n instance
-
Configure Database Credential:
- Create a PostgreSQL credential named
sifaV4Dev - Ensure it has read/write access to tables:
v4_creditpathFollowupv4_youthEntrepreneurs
- Create a PostgreSQL credential named
-
Verify NudgeSender Workflow:
- Ensure workflow
SRUua3GiNudDV1XKexists and is functional - Test that it can receive the expected message format
- Ensure workflow
-
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 -
Test the Workflow:
- Create test data with
followupFired = falseandscheduledFollowupAtin the past - Run manually to verify message generation and delivery
- Check that
followupFiredis updated totrue
- Create test data with
-
Activate: Enable the workflow to start automatic execution every 10 minutes