Skip to content

TEMP Stress Setup Workflow

This workflow provides a temporary testing utility for setting up and configuring user profiles in the profit coaching system. It accepts user data via webhook and performs comprehensive database operations to initialize or reset a user's coaching journey state.

Purpose

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

Based on the implementation, this appears to be a development/testing tool that allows quick setup of user profiles for the profit coaching program. It handles user registration, profile updates, and coaching state initialization in a single operation.

How It Works

  1. Webhook Reception: The workflow receives a POST request containing user setup data including phone number, business type, coaching step, attempt count, and optional fear description.

  2. Database Operations: A comprehensive SQL query performs multiple operations:

    • Creates a new user profile if one doesn't exist
    • Updates existing user profiles with new coaching parameters
    • Cleans up historical data (points ledger and profit path history)
    • Sets up or updates the profit path followup tracking
    • Returns the current coaching step for confirmation

Mermaid Diagram

graph TD
    A[Webhook: tmp-stress-setup] --> B[PostgreSQL Query]
    B --> C[Response: Current Step]

Trigger

Webhook: POST request to /tmp-stress-setup

The webhook expects a JSON payload with the following structure: - phone: User's phone number - business: Type of business owned - step: Current profit followup step - attempt: Attempt count for coaching - fear: Optional fear description

Nodes Used

Node Type Node Name Purpose
Webhook Hook Receives POST requests with user setup data
PostgreSQL Q Executes complex database operations for user setup

External Services & Credentials Required

  • PostgreSQL Database: Requires connection to the sifaV4Dev database
    • Credential ID: KG6Iw6AZuiJwopGr
    • Database tables accessed:
      • v4_youthEntrepreneurs
      • v4_pointsledger
      • v4_profitpathHistory
      • v4_profitpathFollowup

Environment Variables

No environment variables are explicitly used in this workflow. All configuration is handled through the PostgreSQL credentials and webhook path.

Data Flow

Input (via webhook POST body):

1
2
3
4
5
6
7
{
  "phone": "string",
  "business": "string", 
  "step": "string",
  "attempt": "number",
  "fear": "string (optional)"
}

Output:

1
2
3
{
  "step": "string"
}

The workflow returns the current profit followup step after all database operations are completed.

Error Handling

This workflow does not implement explicit error handling. Database errors or constraint violations will cause the workflow to fail and return an error response. The SQL uses conflict resolution (ON CONFLICT DO UPDATE) to handle duplicate phone numbers gracefully.

Known Limitations

  • This is marked as a temporary (TEMP) workflow, suggesting it's for development/testing purposes only
  • No input validation is performed on the webhook data
  • No authentication or authorization checks
  • Database operations are not wrapped in explicit transactions
  • Error responses are not customized for different failure scenarios

No related workflows are documented in the provided context.

Setup Instructions

  1. Import the Workflow:

    • Copy the workflow JSON
    • Import into your n8n instance
  2. Configure Database Connection:

    • Set up PostgreSQL credentials named "sifaV4Dev"
    • Ensure connection to database with required tables:
      • v4_youthEntrepreneurs
      • v4_pointsledger
      • v4_profitpathHistory
      • v4_profitpathFollowup
  3. Activate the Workflow:

    • The webhook will be available at: {your-n8n-url}/webhook/tmp-stress-setup
  4. Test the Setup:

    • Send a POST request with required JSON payload
    • Verify database records are created/updated correctly
    • Check that the response contains the expected step value

Note: This appears to be a temporary development tool. Consider implementing proper error handling, input validation, and authentication before using in production environments.