SIFA V4 Test Forms¶
A comprehensive testing utility workflow that provides form-based interfaces for managing test data across SIFA's four main user paths: Onboarding, Credit Path, Profit Path, and Organic Path. This workflow enables team members to reset user states, add new test accounts, and clean up test data without requiring direct database access.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
This workflow serves as a centralized testing hub for the SIFA V4 system, allowing developers and QA team members to: - Reset user onboarding data to test the complete user journey from scratch - Manage credit path test accounts with configurable debtor scenarios - Set up and reset profit path testers with customizable business types and micro-actions - Clear organic path data to simulate completely new users - Maintain clean test environments without manual database operations
How It Works¶
- Path Selection: Users access a master form that presents four testing paths (Onboarding, Credit, Profit, Organic)
- Path Routing: The workflow routes to the appropriate sub-workflow based on the selected path
- Action-Specific Forms: Each path presents relevant actions (reset, add, delete) with appropriate form fields
- Data Validation: Phone numbers are normalized and validated, with error handling for invalid formats
- Database Operations: Performs targeted SQL operations to reset, create, or delete test data
- Confirmation: Users receive success/error messages with next steps for testing
Onboarding Path¶
- Reset: Clears all onboarding progress while preserving the user record
- Add: Creates new test users with basic profile information
Credit Path¶
- Reset: Restores debtor balances and reactivates the primary conversation
- Add: Creates new testers with three configurable debtors
- Delete: Permanently removes all credit-related data
Profit Path¶
- Reset: Clears progress history while maintaining assigned micro-actions
- Add/Setup: Creates or updates profit testers with business type and micro-action configuration
Organic Path¶
- Reset: Completely removes user from registered systems to simulate new user experience
Workflow Diagram¶
graph TD
A[On Form Submission] --> B[Route by Path]
B -->|Onboarding| C[Onb: Reason Form]
B -->|Credit Path| D[Cr: Action Form]
B -->|Profit Path| E[Pr: Action Form]
B -->|Organic Path| F[Og: Action Form]
C --> G{Onb: If3}
G -->|Reset| H[Onb: Form3]
G -->|Add| I[Onb: Form4]
H --> J[Onb: Edit Fields]
I --> K[Onb: Edit Fields1]
J --> L{Onb: If}
K --> M{Onb: If4}
L -->|Valid| N[Onb: delete_chat]
L -->|Invalid| O[Onb: Form]
N --> P{Onb: If6}
P -->|Success| Q[Onb: delete_chat_history]
P -->|Error| R[Onb: Form1]
Q --> S{Onb: If1}
S -->|Success| T[Onb: update_user_data]
S -->|Error| R
T --> U{Onb: If2}
U -->|Success| V[Onb: Form2]
U -->|Error| R
D --> W{Cr: Is Add?}
W -->|Yes| X[Cr: Add Details Form]
W -->|No| Y{Cr: Is Delete?}
Y -->|Yes| Z[Cr: Delete Confirm Form]
Y -->|No| AA[Cr: Validate Input]
X --> AA
Z --> AA
AA --> BB{Cr: Has Error?}
BB -->|Yes| CC[Cr: Build Validation Error]
BB -->|No| DD{Cr: Is Reset?}
DD -->|Yes| EE[Cr: Lookup Phone]
DD -->|No| FF{Cr: Is Delete Action?}
EE --> GG{Cr: Is Authorized?}
GG -->|Yes| HH[Cr: Reset Debtors]
GG -->|No| II[Cr: Build Reset Denied]
FF -->|Yes| JJ[Cr: Delete Tester]
FF -->|No| KK[Cr: Check Duplicate]
E --> LL[Pr: Normalize]
LL --> MM{Pr: Is Reset?}
MM -->|Yes| NN[Pr: Reset Data]
MM -->|No| OO[Pr: Add & Seed]
F --> PP[Og: Normalize]
PP --> QQ[Og: Reset]
Trigger¶
Form Trigger: The workflow is triggered by form submissions to the path /v4-testing. Users access a master form that allows them to select which testing path they want to work with.
Nodes Used¶
| Node Type | Count | Purpose |
|---|---|---|
| Form Trigger | 1 | Main entry point for path selection |
| Form | 15 | Collect user input and display results |
| Switch | 1 | Route execution based on selected path |
| If | 15 | Conditional logic for validation and flow control |
| Code | 8 | Data validation, normalization, and response building |
| Postgres | 8 | Database operations for user data management |
| Set | 2 | Data transformation and field mapping |
External Services & Credentials Required¶
Database Connection¶
- PostgreSQL:
sifaV4Devcredential required - Tables accessed:
v4_youthEntrepreneurs- Main user recordsv4_chatLog- Chat conversation historyv4_creditpathFollowup- Credit path debtor managementv4_creditpathHistory- Credit path interaction historyv4_profitpathFollowup- Profit path user statev4_profitpathHistory- Profit path interaction historyv4_organic_leads- Organic path lead trackingv4_organic_chat_history- Organic path conversationsn8n_chat_histories- General chat historyv4_ceaalerts- CEA alert system datav4_pointsledger- Points tracking system
Environment Variables¶
No specific environment variables are required. The workflow relies on database credentials configured in n8n's credential management system.
Data Flow¶
Input¶
- Path Selection: Dropdown choice (Onboarding, Credit Path, Profit Path, Organic Path)
- Phone Numbers: E.164 format (+254...) or local format (07...)
- User Details: Names, business types, debtor information
- Action Confirmations: Validation text for destructive operations
Output¶
- Success Messages: Confirmation of completed operations with next steps
- Error Messages: Validation failures and troubleshooting guidance
- Status Updates: Current state of test accounts after operations
Data Transformations¶
- Phone number normalization (0712345678 → +254712345678)
- Input sanitization for SQL injection prevention
- Default value assignment for optional fields
Error Handling¶
The workflow includes comprehensive error handling:
- Phone Number Validation: Rejects invalid formats with clear error messages
- Database Error Recovery: Continues execution on non-critical database failures
- Authorization Checks: Prevents unauthorized operations on non-test accounts
- Confirmation Gates: Requires explicit confirmation for destructive operations
- Duplicate Prevention: Checks for existing records before creating new ones
- Input Sanitization: Prevents SQL injection and data corruption
Known Limitations¶
- Phone number format must be Kenyan (+254 prefix)
- Credit path operations require admin privileges on the target phone number
- Organic path testing requires using different phone numbers than profit/credit paths
- Some operations may leave orphaned data in related tables not explicitly cleaned
- Form responses are static and don't provide real-time status updates
Related Workflows¶
This workflow is part of the SIFA V4 ecosystem and likely integrates with: - Main SIFA WhatsApp bot workflows - Onboarding journey workflows - Credit path management workflows - Profit path coaching workflows - Organic lead nurturing workflows
Setup Instructions¶
- Import Workflow: Import the JSON into your n8n instance
- Configure Database Credential:
- Create a PostgreSQL credential named
sifaV4Dev - Configure connection to the SIFA V4 database
- Create a PostgreSQL credential named
- Activate Workflow: Enable the workflow to make forms accessible
- Access Forms: Navigate to
https://your-n8n-instance.com/form/v4-testing - Test Access: Verify form loads and path selection works
- Database Permissions: Ensure the database user has appropriate permissions for all referenced tables
- Webhook Configuration: Confirm all form webhooks are properly registered
First-Time Usage¶
- Start with the Onboarding path to create a test user
- Use the Credit path to set up debtor scenarios
- Configure Profit path testers with relevant business types
- Test Organic path with completely new phone numbers