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¶
- Input Validation: Receives a phone number and validates it exists and is not empty
- Youth Data Retrieval: Looks up the youth entrepreneur's profile information from the database
- Chat History Collection: Gathers the last 30 chat messages between the youth and the AI coaching system
- Business Data Gathering: Retrieves recent business performance data including sales, costs, and profits
- Data Aggregation: Combines chat history and business data into structured formats
- AI Analysis: Uses GPT-5.2 to analyze all data and generate a comprehensive business summary
- 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 profilesn8n_chat_histories- Chat conversation logsdailyProfitTracking- 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
continueRegularOutputandalwaysOutputDatato 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
Related Workflows¶
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¶
-
Import Workflow: Import the JSON configuration into your n8n instance
-
Configure Database Connection:
- Set up PostgreSQL credential named
PostgresOnSupabase - Ensure access to tables:
youthEntrepreneursReal,n8n_chat_histories,dailyProfitTracking
- Set up PostgreSQL credential named
-
Configure AI Service:
- Create OpenRouter API credential named
OpenRouter account - Ensure access to GPT-5.2 model
- Create OpenRouter API credential named
-
Database Schema Requirements:
youthEntrepreneursRealmust have:phoneNumber,firstName,youthWard,businessOwned,business_summaryn8n_chat_historiesmust have:session_id,message,created_timedailyProfitTrackingmust have:phoneNumber,dateOfBusiness,sales,stockingCost,transportCost,otherCost
-
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
- Use the pinned test data with phone number
-
Integration:
- Call this workflow from other automations using the Execute Workflow node
- Pass the
phoneNumberparameter for the youth to analyze