updateUserDataTool¶
A utility workflow that updates user profile information in the youth entrepreneurs database. This workflow validates user existence by phone number and updates their first name, last name, business ownership status, and communication channel preferences.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
How It Works¶
- Receives Input Parameters: The workflow accepts user data including phone number, first name, second name, business ownership status, and channel information
- Validates User Existence: Queries the database to check if a user with the provided phone number exists
- Conditional Processing: If exactly one user is found, proceeds with the update; otherwise returns an error
- Retrieves User ID: Fetches the internal user ID using the phone number
- Updates User Record: Performs an upsert operation to update the user's profile information
- Returns Success Confirmation: Provides feedback confirming the update was completed
Workflow 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 the following input parameters:
- phoneNumber - User's phone number for identification
- firstName - Updated first name
- secondName - Updated last name
- businessOwned - Business ownership status
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 existing users with the provided phone number |
| If | If | Validates that exactly one user exists before proceeding |
| Postgres | Execute a SQL query1 | Retrieves the user ID for the phone number |
| Postgres | Insert or update rows in a table | Updates user profile information |
| Set | Edit Fields | Returns error message when user validation fails |
| Set | Edit Fields1 | Returns success confirmation message |
External Services & Credentials Required¶
- PostgreSQL Database: Requires connection to the youth entrepreneurs database
- Credential:
kdpTables(PostgreSQL connection) - Database table:
youthEntrepreneursReal
- 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 5 6 | |
Output (Success):
1 2 3 | |
Output (Error):
1 2 3 | |
Error Handling¶
The workflow includes validation to ensure data integrity:
- User Existence Check: Verifies exactly one user exists with the provided phone number
- Conditional Branching: Routes to error handling if user validation fails
- Error Response: Returns a clear error message when updates cannot be performed
Known Limitations¶
- Only updates specific fields (firstName, secondName, businessOwned, channel)
- Requires exact phone number match for user identification
- No validation of input data format or business rules
- Error handling is basic - doesn't distinguish between different failure scenarios
Related Workflows¶
This workflow is designed to be called by other workflows that need to update user profile information. Check for workflows that reference this workflow by name.
Setup Instructions¶
-
Import the Workflow
- Copy the workflow JSON and import it into your n8n instance
-
Configure Database Credentials
- Create a PostgreSQL credential named
kdpTables - Configure connection to your youth entrepreneurs database
- Ensure access to the
youthEntrepreneursRealtable
- Create a PostgreSQL credential named
-
Verify Database Schema
- Confirm the target table has the required columns:
id(primary key)phoneNumber(for user lookup)firstName,secondName,businessOwned,channel(updateable fields)
- Confirm the target table has the required columns:
-
Test the Workflow
- Execute with test data to verify database connectivity
- Confirm both success and error paths work correctly
-
Integration
- Call this workflow from other workflows using the Execute Workflow node
- Pass the required parameters: phoneNumber, firstName, secondName, businessOwned