Skip to content

Save Onboarding Baseline Tool

This workflow captures and stores essential business baseline information for youth entrepreneurs during their onboarding process. It accepts key business metrics like monthly fixed costs, business days per month, preferred contact times, and stock type, then safely updates the participant's record in the database.

Purpose

No business context provided yet — add a context.md to enrich this documentation.

How It Works

  1. Receive Input Data: The workflow accepts six key pieces of information about a youth entrepreneur's business setup
  2. Update Database Record: Uses the phone number as a unique identifier to update the participant's baseline business information in the PostgreSQL database
  3. Format Response: Returns a structured response indicating whether the save operation was successful

The workflow uses a simple update operation that matches records by phone number and updates the baseline business metrics without affecting other participant data.

Workflow Diagram

graph TD
    A[Trigger] --> B[updateBaseline]
    B --> C[formatResponse]

    D[upsertBaseline] 
    E[upsertBaseline1]
    F[formatResponse1]

    style A fill:#e1f5fe
    style B fill:#f3e5f5
    style C fill:#e8f5e8

Trigger

Execute Workflow Trigger - This workflow is designed to be called by other workflows or external systems. It expects the following input parameters:

  • phoneNumber - Participant's phone number (used as unique identifier)
  • preferredTime - Preferred contact time
  • monthlyFixedCosts - Monthly fixed business costs
  • businessDaysMonth - Number of business days per month
  • dailyFixedCost - Daily fixed cost calculation
  • stockType - Type of stock/inventory management

Nodes Used

Node Type Node Name Purpose
Execute Workflow Trigger Trigger Receives input parameters from calling workflow
PostgreSQL updateBaseline Updates participant record with baseline business data
Set formatResponse Formats the response with success status and message
PostgreSQL upsertBaseline (Unused) Alternative upsert implementation
PostgreSQL upsertBaseline1 (Unused) Alternative upsert with null handling
Set formatResponse1 (Unused) Alternative response formatter

External Services & Credentials Required

PostgreSQL Database

  • Credential Name: PostgresOnSupabase
  • Purpose: Stores youth entrepreneur participant data
  • Required Access: Read/Write access to youthEntrepreneursReal table
  • Connection: Supabase-hosted PostgreSQL instance

Environment Variables

No environment variables are directly used in this workflow. All configuration is handled through the PostgreSQL credential setup.

Data Flow

Input

1
2
3
4
5
6
7
8
{
  "phoneNumber": "+254712195324",
  "preferredTime": "19:00",
  "monthlyFixedCosts": "3000",
  "businessDaysMonth": "26",
  "dailyFixedCost": "115",
  "stockType": "daily"
}

Output

1
2
3
4
{
  "success": true,
  "message": "Baseline saved."
}

Database Impact

Updates the following fields in the youthEntrepreneursReal table: - preferredTime - monthlyFixedCosts - businessDaysPerMonth - dailyFixedCost - stockType

Error Handling

The workflow includes basic error handling:

  • Database Errors: The updateBaseline node continues execution even if errors occur
  • Success Validation: The response formatter checks if a phone number was returned to determine success
  • Graceful Degradation: If the update fails, returns success: false with an appropriate error message

Known Limitations

  • The workflow contains several unused nodes (upsertBaseline, upsertBaseline1, formatResponse1) that should be cleaned up
  • No input validation is performed on the received parameters
  • Error details are not exposed in the response - only success/failure status
  • The workflow assumes the participant record already exists (uses UPDATE, not INSERT)

This workflow is designed to be called by other workflows in the youth entrepreneur onboarding system. Check for workflows that handle the initial onboarding flow or participant registration.

Setup Instructions

  1. Import Workflow: Import the JSON into your n8n instance

  2. Configure PostgreSQL Credential:

    • Create a new PostgreSQL credential named "PostgresOnSupabase"
    • Configure connection to your Supabase PostgreSQL instance
    • Ensure the credential has read/write access to the youthEntrepreneursReal table
  3. Verify Database Schema: Ensure your database has the youthEntrepreneursReal table with these columns:

    • phoneNumber (TEXT, unique)
    • preferredTime (TEXT)
    • monthlyFixedCosts (NUMERIC)
    • businessDaysPerMonth (INTEGER)
    • dailyFixedCost (NUMERIC)
    • stockType (TEXT)
  4. Test the Workflow:

    • Use the provided pin data to test the workflow
    • Verify the database is updated correctly
    • Check that the response format matches expectations
  5. Clean Up (Optional):

    • Remove unused nodes (upsertBaseline, upsertBaseline1, formatResponse1)
    • This will simplify the workflow without affecting functionality
  6. Integration: Configure other workflows to call this one using the "Execute Workflow" node with the required input parameters