V4 - helpKeywordHandler¶
This workflow responds to "help" keyword requests by sending users the SIFA helpline number (0800-SIFA-00) via their preferred communication channel (WhatsApp or SMS) and logs the interaction for tracking purposes.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
Based on the workflow structure, this appears to handle help requests from users by providing them with a toll-free helpline number and tracking these interactions in a database.
How It Works¶
- Receives Input: Another workflow triggers this one, passing youth phone number and preferred channel
- Prepares Message: Creates a standardized help message containing the SIFA helpline number
- Routes by Channel: Determines whether to send via WhatsApp or SMS based on user preference
- Sends Message: Delivers the help information through the appropriate channel
- Logs Interaction: Records the help request event in the database for tracking and analytics
Workflow Diagram¶
graph TD
A[When Executed by Another Workflow] --> B[Build Message]
B --> C{Channel?}
C -->|WhatsApp| D[Send WhatsApp]
C -->|SMS| E[Send SMS]
D --> F[Log Event WA]
E --> G[Log Event SMS]
Trigger¶
Execute Workflow Trigger: This workflow is called by other workflows in the system. It expects to receive:
- youthPhone: The recipient's phone number
- channel: Communication preference ("whatsapp" or "sms")
Nodes Used¶
| Node Type | Node Name | Purpose |
|---|---|---|
| Execute Workflow Trigger | When Executed by Another Workflow | Receives calls from other workflows |
| Set | Build Message | Prepares the help message and extracts input parameters |
| Switch | Channel? | Routes execution based on communication channel preference |
| Twilio | Send WhatsApp | Sends help message via WhatsApp |
| HTTP Request | Send SMS | Sends help message via SMS using Africa's Talking API |
| Postgres | Log Event (WA) | Records WhatsApp help requests in database |
| Postgres | Log Event (SMS) | Records SMS help requests in database |
External Services & Credentials Required¶
Twilio (WhatsApp)¶
- Credential ID: f1rV52vb9Dkb4f1K
- Purpose: Sending WhatsApp messages
- Required: Account SID, Auth Token, WhatsApp-enabled phone number
Africa's Talking (SMS)¶
- Purpose: Sending SMS messages via toll-free shortcode
- Required: API key, username (toll_free_sms_ke)
- Shortcode: 24436
PostgreSQL Database¶
- Credential IDs: 80LHOtylhMnmLKKV, HW3SZAbtOnuQRQ9x
- Purpose: Logging help request events
- Required: Database connection details
Environment Variables¶
No environment variables are explicitly used in this workflow. All configuration is handled through: - Hardcoded phone numbers and shortcodes - Credential-stored API keys and connection strings
Data Flow¶
Input¶
1 2 3 4 | |
Processing¶
- Message body: "0800-SIFA-00 - free from any phone - 8am-8pm"
- WhatsApp sender: +254203892316
- SMS sender: 24436 (shortcode)
Output¶
- Message delivered to user via specified channel
- Database record created in
surfacing_eventstable with:youth_phone: Recipient's phone numbersurfacing_event_type: "help_keyword"channel: "whatsapp" or "sms"
Error Handling¶
This workflow does not implement explicit error handling. Failed message deliveries or database insertions will cause the workflow to stop with an error. Consider adding: - Try-catch blocks around external API calls - Retry logic for failed deliveries - Fallback notification mechanisms
Known Limitations¶
- No error handling for failed message deliveries
- Hardcoded message content (not configurable)
- No validation of phone number format
- No rate limiting or duplicate request prevention
- Database logging uses different credential IDs for WhatsApp vs SMS events
Related Workflows¶
This workflow is designed to be called by other workflows that detect help keyword usage. No specific related workflows are identified in the current documentation.
Setup Instructions¶
-
Import Workflow: Import the JSON into your n8n instance
-
Configure Credentials:
- Set up Twilio credentials for WhatsApp messaging
- Configure Africa's Talking API credentials for SMS
- Set up PostgreSQL database connections
-
Database Setup: Ensure the
surfacing_eventstable exists with columns:1 2 3 4 5 6
CREATE TABLE surfacing_events ( youth_phone VARCHAR, surfacing_event_type VARCHAR, channel VARCHAR, created_at TIMESTAMP DEFAULT NOW() ); -
Test Configuration:
- Verify WhatsApp number (+254203892316) is properly configured in Twilio
- Confirm SMS shortcode (24436) is active with Africa's Talking
- Test database connectivity and write permissions
-
Integration: Configure calling workflows to pass the required
youthPhoneandchannelparameters -
Monitoring: Set up monitoring for failed executions and message delivery failures