updateUserStatusTool¶
A utility workflow that updates the onboarding status of youth entrepreneurs in the database based on their phone number. This workflow validates user existence before performing updates and provides clear feedback on the operation's success or failure.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
How It Works¶
- Input Validation: Receives a phone number and new onboarding status from another workflow
- User Verification: Queries the database to check if exactly one user exists with the provided phone number
- Conditional Processing:
- If user exists: Retrieves their ID and updates their onboarding status
- If user doesn't exist or multiple users found: Returns an error message
- Status Update: Updates the user's onboarding status in the database using their ID
- Response Generation: Returns a success message with the phone number or an error message
Mermaid Diagram¶
graph TD
A[When Executed by Another Workflow] --> B[Execute a SQL query]
B --> C[If]
C -->|User Found| D[Execute a SQL query1]
C -->|User Not Found| E[Edit Fields - Error]
D --> F[Insert or update rows in a table]
F --> G[Edit Fields1 - Success]
Trigger¶
Execute Workflow Trigger: This workflow is designed to be called by other workflows, not triggered directly. It accepts two input parameters:
- phoneNumber: The phone number of the user to update
- onboardingStatus: The new onboarding status to set
Nodes Used¶
| Node Type | Node Name | Purpose |
|---|---|---|
| Execute Workflow Trigger | When Executed by Another Workflow | Receives input parameters from calling workflow |
| Postgres | Execute a SQL query | Counts users with the provided phone number |
| If | If | Validates that exactly one user exists |
| Postgres | Execute a SQL query1 | Retrieves the user ID for the phone number |
| Postgres | Insert or update rows in a table | Updates the user's onboarding status |
| Set | Edit Fields | Returns error message when user validation fails |
| Set | Edit Fields1 | Returns success message after successful update |
External Services & Credentials Required¶
- PostgreSQL Database: Requires access to the
youthEntrepreneursRealtable- Credential:
kdpTables(PostgreSQL connection) - Permissions needed: SELECT and UPDATE on
youthEntrepreneursRealtable
- Credential:
Environment Variables¶
No environment variables are used in this workflow. All configuration is handled through n8n credentials.
Data Flow¶
Input:
1 2 3 4 | |
Output (Success):
1 2 3 | |
Output (Error):
1 2 3 | |
Error Handling¶
The workflow includes validation to ensure data integrity:
- User Validation: Checks that exactly one user exists with the provided phone number
- Error Path: If validation fails (no user found or multiple users found), the workflow returns an error message instead of attempting the update
- Database Errors: Any database connection or query errors will cause the workflow to fail with n8n's standard error handling
Known Limitations¶
- The workflow only updates the
onboardingStatusfield; other user fields cannot be modified - Phone number matching is case-sensitive and requires exact matches
- No validation is performed on the
onboardingStatusvalue format - The workflow assumes phone numbers are unique in the database
Related Workflows¶
This is a utility workflow designed to be called by other workflows that need to update user onboarding status. No specific related workflows are documented.
Setup Instructions¶
-
Import the Workflow:
- Copy the workflow JSON
- Import into your n8n instance
-
Configure Database Credentials:
- Create a PostgreSQL credential named
kdpTables - Configure connection to your database containing the
youthEntrepreneursRealtable
- Create a PostgreSQL credential named
-
Database Requirements:
- Ensure the
youthEntrepreneursRealtable exists with these required columns:id(number, primary key)phoneNumber(string)onboardingStatus(string)
- Ensure the
-
Test the Workflow:
- Call from another workflow with valid test data
- Verify the database update occurs correctly
- Test error scenarios (non-existent phone numbers)
-
Integration:
- Use the "Execute Workflow" node in other workflows
- Pass the required
phoneNumberandonboardingStatusparameters - Handle the returned success/error messages appropriately