Save Onboarding Baseline Tool (Testing)¶
This workflow saves and updates baseline business information for youth entrepreneurs during their onboarding process. It handles the storage of key business metrics like monthly fixed costs, business days per month, daily fixed costs, stock type, and preferred contact times in a PostgreSQL database.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
Based on the workflow structure, this appears to be part of a youth entrepreneurship program that collects and stores baseline business information from participants. The workflow ensures that essential business metrics are captured and can be updated as participants progress through their onboarding journey.
How It Works¶
- Input Sanitization: The workflow receives business data inputs and sanitizes them, removing empty or null values while preserving the phone number as the primary identifier
- Database Update: The cleaned data is used to update the youth entrepreneur's record in the database using an upsert operation (insert if new, update if exists)
- Response Formatting: The workflow formats a success/failure response indicating whether the baseline information was saved successfully
Workflow Diagram¶
graph TD
A[Trigger] --> B[Code in JavaScript]
B --> C[updateBaseline]
C --> D[formatResponse]
E[upsertBaseline] -.-> F[Disconnected]
G[upsertBaseline1] -.-> H[Disconnected]
I[formatResponse1] -.-> J[Disconnected]
Trigger¶
Execute Workflow Trigger: This workflow is designed to be called by other workflows with the following input parameters:
- phoneNumber (required) - Unique identifier for the youth entrepreneur
- preferredTime (optional) - Preferred contact time
- monthlyFixedCosts (optional) - Monthly fixed business costs
- businessDaysMonth (optional) - Number of business days per month
- dailyFixedCost (optional) - Daily fixed cost calculation
- stockType (optional) - Type of stock/inventory the business handles
Nodes Used¶
| Node Type | Node Name | Purpose |
|---|---|---|
| Execute Workflow Trigger | Trigger | Receives input parameters from calling workflows |
| Code | Code in JavaScript | Sanitizes input data, removing empty values while preserving phone number |
| Postgres | updateBaseline | Updates the youthEntrepreneursReal table with baseline information |
| Set | formatResponse | Creates a standardized response with success status and message |
| Postgres | upsertBaseline | (Disconnected) Legacy upsert operation |
| Postgres | upsertBaseline1 | (Disconnected) Alternative upsert operation |
| Set | formatResponse1 | (Disconnected) Alternative response formatter |
External Services & Credentials Required¶
- PostgreSQL Database: Requires connection to a PostgreSQL database containing the
youthEntrepreneursRealtable- Credential name:
kdpTestEnv - Database schema:
public - Required table:
youthEntrepreneursReal
- Credential name:
Environment Variables¶
No environment variables are explicitly used in this workflow. Database connection details are managed through n8n credentials.
Data Flow¶
Input¶
1 2 3 4 5 6 7 8 | |
Output¶
1 2 3 4 | |
Database Schema¶
The workflow updates the following fields in the youthEntrepreneursReal table:
- phoneNumber (TEXT) - Primary key for matching records
- preferredTime (TEXT) - Preferred contact time
- monthlyFixedCosts (NUMERIC) - Monthly fixed business costs
- businessDaysPerMonth (INTEGER) - Business days per month
- dailyFixedCost (NUMERIC) - Daily fixed cost
- stockType (TEXT) - Type of stock/inventory
- practiceBaselineAvg (NUMERIC) - Practice baseline average (not currently used)
Error Handling¶
The workflow includes basic error handling:
- The updateBaseline node continues execution even if database errors occur
- Response formatting checks if a phone number was returned to determine success
- Empty or null values are filtered out during input sanitization to prevent database constraint violations
Known Limitations¶
- The workflow contains several disconnected nodes (
upsertBaseline,upsertBaseline1,formatResponse1) that appear to be legacy implementations - Zero values are treated as empty and filtered out, which may not be appropriate for all numeric fields
- No validation is performed on input data types or ranges
- Error details are not captured or returned in the response
Related Workflows¶
No related workflows are specified in the current context.
Setup Instructions¶
-
Import the Workflow: Import this workflow into your n8n instance
-
Configure Database Credentials:
- Create a PostgreSQL credential named
kdpTestEnv - Ensure it has read/write access to the
youthEntrepreneursRealtable
- Create a PostgreSQL credential named
-
Database Table Setup: Ensure the
youthEntrepreneursRealtable exists with the required columns:1 2 3 4 5 6 7 8 9 10
CREATE TABLE IF NOT EXISTS "youthEntrepreneursReal" ( "phoneNumber" TEXT PRIMARY KEY, "preferredTime" TEXT, "monthlyFixedCosts" NUMERIC, "businessDaysPerMonth" INTEGER, "dailyFixedCost" NUMERIC, "stockType" TEXT, "practiceBaselineAvg" NUMERIC -- Additional columns as needed ); -
Test the Workflow: Execute with sample data to verify database connectivity and data flow
-
Integration: Call this workflow from other workflows using the Execute Workflow node with the required input parameters
-
Clean Up: Consider removing the disconnected nodes (
upsertBaseline,upsertBaseline1,formatResponse1) if they are no longer needed