Skip to content

Business Summary Generator for Youth Entrepreneurs

This workflow generates comprehensive business performance summaries for youth entrepreneurs by analyzing their chat history, business data, and profile information. It creates detailed reports that help field managers quickly understand each youth's business progress, engagement levels, and areas needing attention.

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: - Tracks daily business performance of young entrepreneurs - Provides AI-powered business coaching through chat interactions - Generates regular business summaries for program managers - Monitors engagement and business health across participants

The workflow serves field managers who need quick, actionable insights about their youth entrepreneurs without manually reviewing chat logs and business data.

How It Works

  1. Input Validation: Receives a phone number and validates it exists and is not empty
  2. Youth Data Retrieval: Looks up the youth entrepreneur's profile information from the database
  3. Chat History Collection: Gathers the last 30 chat messages between the youth and the AI coaching system
  4. Business Data Gathering: Retrieves recent business performance data including sales, costs, and profits
  5. Data Aggregation: Combines chat history and business data into structured formats
  6. AI Analysis: Uses GPT-5.2 to analyze all data and generate a comprehensive business summary
  7. Summary Storage: Updates the youth's profile with the new business summary for future reference

The AI generates a detailed report including business performance trends, engagement levels, key events timeline, and actionable recommendations for field managers.

Workflow Diagram

graph TD
    A[When Executed by Another Workflow] --> B[If - Phone Number Valid?]
    B -->|Yes| C[get_chat_history - NoOp]
    B -->|No| D[No Operation, do nothing]
    C --> E[get_youth_data - PostgreSQL Query]
    E --> F[If1 - Youth Data Exists?]
    F -->|Yes| G[set_yout_data - Store Youth Info]
    F -->|No| D
    G --> H[get_chat_history1 - Get Recent Messages]
    H --> I[aggregate_chat_history - Combine Messages]
    I --> J[get_business_data - Get Sales/Costs]
    J --> K[aggregate_business_data - Combine Business Data]
    K --> L[generate_Summary - AI Analysis]
    M[OpenRouter Chat Model - GPT-5.2] --> L
    L --> N[If2 - Summary Generated?]
    N -->|Yes| O[summary - Extract Text]
    N -->|No| D
    O --> P[add_business_summary - Update Database]

Trigger

Execute Workflow Trigger: This workflow is designed to be called by another workflow, receiving a phoneNumber parameter as input. It's not triggered directly by external events but rather invoked programmatically as part of a larger automation process.

Nodes Used

Node Type Node Name Purpose
Execute Workflow Trigger When Executed by Another Workflow Receives phone number input from calling workflow
If If, If1, If2 Validates phone number, youth data existence, and summary generation
No Operation get_chat_history, No Operation do nothing Placeholder and termination nodes
PostgreSQL get_youth_data, get_chat_history1, get_business_data, add_business_summary Database operations for retrieving and storing data
Set set_yout_data, summary Data transformation and variable assignment
Aggregate aggregate_chat_history, aggregate_business_data Combines multiple database records into single objects
Chain LLM generate_Summary AI-powered analysis using structured prompts
OpenRouter Chat Model OpenRouter Chat Model GPT-5.2 language model for generating summaries

External Services & Credentials Required

PostgreSQL Database

  • Credential: PostgresOnSupabase
  • Purpose: Stores youth profiles, chat histories, and business tracking data
  • Tables Used:
    • youthEntrepreneursReal - Youth entrepreneur profiles
    • n8n_chat_histories - Chat conversation logs
    • dailyProfitTracking - Business performance data

OpenRouter API

  • Credential: OpenRouter account
  • Purpose: Provides access to GPT-5.2 model for AI analysis
  • Model: openai/gpt-5.2

Environment Variables

No specific environment variables are configured in this workflow. All external service connections use stored credentials.

Data Flow

Input

  • phoneNumber (string): Phone number of the youth entrepreneur to analyze

Processing Data

  • Youth profile data (name, ward, business type, previous summary)
  • Last 30 chat messages with timestamps
  • Recent business data (sales, costs, dates, micro-actions)
  • Current date for context

Output

  • Comprehensive business summary (300+ words) stored in database
  • Analysis includes:
    • Business performance trends
    • Engagement assessment
    • Key events timeline
    • Manager recommendations
    • Risk and opportunity identification

Error Handling

The workflow includes several error handling mechanisms:

  • Input Validation: Multiple If nodes check for valid phone numbers and data existence
  • Graceful Degradation: NoOp nodes handle cases where data is missing or invalid
  • Database Error Handling: PostgreSQL nodes are configured with continueRegularOutput and alwaysOutputData to handle query failures
  • Conditional Processing: If nodes ensure the workflow only proceeds when required data is available

Known Limitations

  • Limited to analyzing the last 30 chat messages and business records
  • Requires existing youth profile in the database to function
  • Dependent on OpenRouter API availability for summary generation
  • No retry mechanism for failed AI analysis
  • Summary quality depends on the completeness of input data

This workflow is designed to be called by other workflows in the youth entrepreneurship program, likely: - Scheduled summary generation workflows - Manager dashboard refresh processes - Reporting automation systems

Setup Instructions

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

  2. Configure Database Connection:

    • Set up PostgreSQL credential named PostgresOnSupabase
    • Ensure access to tables: youthEntrepreneursReal, n8n_chat_histories, dailyProfitTracking
  3. Configure AI Service:

    • Create OpenRouter API credential named OpenRouter account
    • Ensure access to GPT-5.2 model
  4. Database Schema Requirements:

    • youthEntrepreneursReal must have: phoneNumber, firstName, youthWard, businessOwned, business_summary
    • n8n_chat_histories must have: session_id, message, created_time
    • dailyProfitTracking must have: phoneNumber, dateOfBusiness, sales, stockingCost, transportCost, otherCost
  5. Test the Workflow:

    • Use the pinned test data with phone number +254794443378
    • Verify database connections and AI model access
    • Check that summaries are generated and stored correctly
  6. Integration:

    • Call this workflow from other automations using the Execute Workflow node
    • Pass the phoneNumber parameter for the youth to analyze