Onboarding Nudge - Francis Testing¶
This workflow automatically sends daily nudge messages to new youth entrepreneurs who haven't completed their onboarding process, using different messaging strategies based on whether they originally signed up via WhatsApp or other channels.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
Based on the workflow implementation, this appears to be designed to re-engage new users who have registered for a youth entrepreneurship program but haven't yet completed their onboarding. The system sends personalized nudge messages via WhatsApp or SMS to encourage users to continue with the setup process.
How It Works¶
- Query New Users: The workflow starts by finding all youth entrepreneurs with phone numbers who have "new" onboarding status, excluding call center and internal team entries
- Filter Active Users: Only processes users who aren't already marked as "active" to avoid sending nudges to completed users
- Route by Channel: Splits users into two paths based on their original signup channel:
- WhatsApp Users: Checks their recent chat history and sends appropriate messages
- Non-WhatsApp Users: Sends SMS nudges directly
- WhatsApp Logic: For WhatsApp users, the system:
- Looks up their most recent chat log entry
- If they've been active in the last 24 hours, sends a WhatsApp message
- If not active recently (or no chat history), sends an SMS with WhatsApp invitation link
- Message Logging: All sent messages are logged to the chat history database for tracking
- Batch Processing: Users are processed in batches to manage system load
Workflow Diagram¶
graph TD
A[Schedule Trigger/Manual Trigger] --> B[getUserRecord]
B --> C[skipIfAlreadyOnboarded]
C --> D[If - Check Channel]
D -->|WhatsApp| E[Loop Over Items]
D -->|Other| F[Loop Over Items1]
E --> G[Execute SQL Query - Get Chat Log]
G --> H[checkIfWeFindAChatlogRecord]
H -->|Found| I[ifLessThen24hrsPassed]
H -->|Not Found| J[setNudgeMessage1]
I -->|< 24hrs| K[Send WhatsApp via Twilio]
I -->|> 24hrs| J[setNudgeMessage1]
J --> L[Send SMS via Africa's Talking2]
L --> M[getUserRecord5 - Log Message]
F --> N[setNudgeMessage]
N --> O[Send SMS via Africa's Talking]
O --> P[getUserRecord4 - Log Message]
K --> E
M --> E
P --> F
Trigger¶
- Schedule Trigger: Runs daily at 10:30 AM (currently disabled)
- Manual Trigger: Can be executed manually for testing
Nodes Used¶
| Node Type | Node Name | Purpose |
|---|---|---|
| Postgres | getUserRecord | Query youth entrepreneurs with "new" onboarding status |
| If | skipIfAlreadyOnboarded | Filter out users who are already active |
| If | If | Route users based on signup channel (WhatsApp vs other) |
| Split In Batches | Loop Over Items | Process WhatsApp users in batches |
| Split In Batches | Loop Over Items1 | Process non-WhatsApp users in batches |
| Postgres | Execute a SQL query | Get recent chat history for WhatsApp users |
| If | checkIfWeFindAChatlogRecord | Check if user has any chat history |
| If | ifLessThen24hrsPassed | Check if user was active in last 24 hours |
| Twilio | Send WhatsApp response via Twilio1 | Send WhatsApp messages to active users |
| Set | setNudgeMessage | Create SMS message for non-WhatsApp users |
| Set | setNudgeMessage1 | Create SMS message with WhatsApp invitation |
| HTTP Request | Send SMS via Africa's Talking | Send SMS to non-WhatsApp users |
| HTTP Request | Send SMS via Africa's Talking2 | Send SMS with WhatsApp link |
| Postgres | getUserRecord4 | Log SMS messages to chat history |
| Postgres | getUserRecord5 | Log SMS messages with WhatsApp links |
External Services & Credentials Required¶
Twilio¶
- Credential:
twilioApi(Iganga Coach) - Purpose: Send WhatsApp messages
- Required: Account SID, Auth Token
Africa's Talking¶
- Credential:
httpHeaderAuth(AT Header Auth) - Purpose: Send SMS messages
- Required: API Key for header authentication
PostgreSQL Database¶
- Credential:
postgres(kdpTestEnv) - Purpose: Query user data and log messages
- Required: Database connection string, username, password
Environment Variables¶
No explicit environment variables are used in this workflow. All configuration is handled through n8n credentials.
Data Flow¶
Input¶
- Youth entrepreneur records from
youthEntrepreneursRealtable - Chat history from
chatLogtable
Processing¶
- Filters users by onboarding status and channel
- Checks recent activity for WhatsApp users
- Generates personalized nudge messages
Output¶
- WhatsApp messages via Twilio
- SMS messages via Africa's Talking
- Message logs in
n8n_chat_historiestable
Error Handling¶
The workflow includes basic error handling: - Continue on Error: Twilio WhatsApp sending and database logging operations are set to continue on error - Always Output Data: SQL query node always outputs data even if no results found - Fallback Paths: If WhatsApp sending fails, the workflow continues to the next iteration
Known Limitations¶
- Schedule trigger is currently disabled, requiring manual execution
- No retry mechanism for failed message sends
- Limited error reporting - failures may go unnoticed
- Hard-coded phone numbers and message templates
- No rate limiting for external API calls
Related Workflows¶
No related workflows identified from the current context.
Setup Instructions¶
-
Import Workflow: Import the JSON into your n8n instance
-
Configure Credentials:
- Set up PostgreSQL connection (
kdpTestEnv) - Configure Twilio API credentials (
Iganga Coach) - Set up Africa's Talking HTTP header authentication (
AT Header Auth)
- Set up PostgreSQL connection (
-
Database Setup: Ensure these tables exist:
youthEntrepreneursRealwith columns:phoneNumber,onboardingStatus,channel,intr01_uuid,firstNamechatLogwith columns:userPhone,channel,created_atn8n_chat_historieswith columns:session_id,message
-
Enable Schedule:
- Enable the Schedule Trigger node if you want automatic daily execution
- Adjust the time (currently 10:30 AM) as needed
-
Test Configuration:
- Use the Manual Trigger to test the workflow
- Verify message sending and database logging work correctly
- Check that user filtering logic works as expected
-
Production Deployment:
- Enable the Schedule Trigger
- Monitor error outputs and message delivery
- Set up alerting for failed executions