updateUserDataTool - Francis¶
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, second name, business ownership details, 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 phone number, first name, second name, and business ownership information from another workflow
- Validates User Existence: 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 profile information
- If user doesn't exist or multiple records found: Returns an error message
- Updates Database: Performs an upsert operation to update the user's profile fields
- Returns Confirmation: Provides a success message with the updated phone number
Workflow Diagram¶
graph TD
A[When Executed by Another Workflow] --> B[Execute a SQL query]
B --> C[If]
C -->|User exists| D[Execute a SQL query1]
C -->|User not found/multiple| 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 expects the following input parameters:
- phoneNumber: User's phone number (used as identifier)
- firstName: Updated first name
- secondName: Updated second name
- businessOwned: Updated business ownership information
Nodes Used¶
| Node Type | Node Name | Purpose |
|---|---|---|
| Execute Workflow Trigger | When Executed by Another Workflow | Receives input parameters from calling workflow |
| PostgreSQL | Execute a SQL query | Counts users with the provided phone number |
| If | If | Validates that exactly one user exists |
| PostgreSQL | Execute a SQL query1 | Retrieves the user ID for the phone number |
| PostgreSQL | Insert or update rows in a table | Updates user profile information |
| Set | Edit Fields | Returns error message for invalid users |
| Set | Edit Fields1 | Returns success confirmation message |
External Services & Credentials Required¶
- PostgreSQL Database: Requires connection to Supabase PostgreSQL instance
- Credential:
PostgresOnSupabase(ID: Hw9XWerQ5RNHaVTk) - Access needed to
youthEntrepreneursRealtable
- Credential:
Environment Variables¶
No environment variables are directly used in this workflow. Database connection details are managed 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 Validation: Checks that exactly one user exists with the provided phone number
- Error Path: If no user is found or multiple users exist, the workflow returns an error message instead of attempting to update
- Database Constraints: Uses upsert operation with ID matching to prevent duplicate records
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 messages are generic and don't specify the exact issue (no user vs. multiple users)
Related Workflows¶
This workflow is designed to be called by other workflows that need to update user profile information. No specific related workflows are identified in the current context.
Setup Instructions¶
- Import Workflow: Import the JSON into your n8n instance
- Configure Database Credential:
- Create a PostgreSQL credential named "PostgresOnSupabase"
- Configure connection to your Supabase PostgreSQL instance
- Ensure access to the
youthEntrepreneursRealtable
- Database Schema: Ensure your database has the
youthEntrepreneursRealtable with these columns:id(primary key)phoneNumber(string)firstName(string)secondName(string)businessOwned(string)channel(string)
- Test the Workflow: Use the Execute Workflow node from another workflow with sample data
- Integration: Call this workflow from other workflows that need to update user profiles
Note: This workflow is currently inactive and may need to be activated before use.