Save Onboarding Baseline Tool¶
This workflow saves baseline business information for youth entrepreneurs during their onboarding process. It accepts key business metrics like monthly costs, operating days, and stock type, then stores this data in a PostgreSQL database for later use in coaching and analysis.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
How It Works¶
- Receive Input: The workflow accepts baseline business data including phone number, preferred contact time, monthly fixed costs, business days per month, daily fixed cost, and stock type
- Clean Data: A JavaScript code node sanitizes the input by removing empty or null values while preserving the phone number as the primary identifier
- Update Database: The cleaned data is used to update the youth entrepreneur's record in the PostgreSQL database using an upsert operation
- Format Response: The workflow returns a success indicator and confirmation message based on whether the database operation completed successfully
Workflow Diagram¶
graph TD
A[Trigger] --> B[Code in JavaScript]
B --> C[updateBaseline]
C --> D[formatResponse]
E[upsertBaseline]
F[upsertBaseline1]
G[formatResponse1]
style A fill:#e1f5fe
style D fill:#e8f5e8
Trigger¶
Execute Workflow Trigger: This workflow is designed to be called by other workflows or external systems. It accepts the following input parameters:
- phoneNumber (required) - The youth entrepreneur's phone number as unique identifier
- preferredTime - Preferred time for contact
- monthlyFixedCosts - Monthly fixed business costs
- businessDaysMonth - Number of business days per month
- dailyFixedCost - Daily fixed cost calculation
- stockType - 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 by removing empty values |
| Postgres | updateBaseline | Updates the youth entrepreneur record in the database |
| Set | formatResponse | Formats the final response with success status and message |
| Postgres | upsertBaseline | (Unused) Alternative database operation node |
| Postgres | upsertBaseline1 | (Unused) Alternative database operation node |
| Set | formatResponse1 | (Unused) Alternative response formatting node |
External Services & Credentials Required¶
- PostgreSQL Database: Requires connection to the
kdpTablesdatabase- Credential name:
kdpTables - Database table:
youthEntrepreneursReal - Required permissions: INSERT, UPDATE, SELECT
- Credential name:
Environment Variables¶
No environment variables are explicitly used in this workflow. Database connection details are managed through n8n's credential system.
Data Flow¶
Input:
1 2 3 4 5 6 7 8 | |
Output:
1 2 3 4 | |
The workflow performs an upsert operation, meaning it will either insert a new record or update an existing one based on the phone number. Only non-empty values are included in the database operation.
Error Handling¶
The database nodes are configured with onError: "continueRegularOutput", which means the workflow will continue executing even if database operations fail. The response formatting logic checks for the presence of a returned phone number to determine success:
- If
phoneNumberis returned from the database operation:success: true - If no phone number is returned:
success: falsewith message "No rows returned — check upsert."
Known Limitations¶
No specific limitations documented in the provided context.
Related Workflows¶
No related workflows specified in the provided context.
Setup Instructions¶
-
Import the Workflow: Import the JSON workflow file 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 Table Requirements: Ensure your PostgreSQL database has a table named
youthEntrepreneursRealwith the following columns:phoneNumber(TEXT, primary key)preferredTime(TEXT)monthlyFixedCosts(NUMERIC)businessDaysPerMonth(INTEGER)dailyFixedCost(NUMERIC)stockType(TEXT)
-
Test the Workflow: Use the provided test data to verify the workflow functions correctly:
1 2 3 4 5 6 7 8
{ "phoneNumber": "+254116377439", "preferredTime": null, "monthlyFixedCosts": "200", "businessDaysMonth": "30", "dailyFixedCost": "7", "stockType": null } -
Integration: This workflow is designed to be called by other workflows using the "Execute Workflow" node, passing the required baseline data as parameters.