Create Business Summary for Youth¶
This workflow generates comprehensive business performance reports for youth entrepreneurs by analyzing their chat history, business data, and profile information using AI. It creates detailed summaries that help field managers quickly understand each youth's business progress, engagement level, and areas needing attention.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
Based on the workflow implementation, this appears to be part of a youth entrepreneurship program that: - Monitors business performance of young entrepreneurs - Provides AI-powered coaching and support - Tracks daily sales, expenses, and profit data - Generates management reports for field staff oversight - Helps identify successful business patterns and intervention needs
How It Works¶
- Input Validation: The workflow receives a phone number and validates it exists and is not empty
- Data Retrieval: Fetches youth profile data from the database using the phone number
- Chat History Collection: Retrieves the last 30 chat messages between the youth and AI assistant
- Business Data Gathering: Pulls recent business tracking data including sales, costs, and micro-actions
- 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: Saves the generated summary back to the youth's profile in the database
The AI generates a detailed report including business performance trends, engagement analysis, timeline of key events, and actionable recommendations for field managers.
Workflow Diagram¶
graph TD
A[When Executed by Another Workflow] --> B[If - Validate Phone Number]
B -->|Valid| C[get_chat_history - NoOp]
B -->|Invalid| D[No Operation, do nothing]
C --> E[get_youth_data - PostgreSQL Query]
E --> F[If1 - Validate Youth Data]
F -->|Valid| G[set_yout_data - Set Variables]
F -->|Invalid| D
G --> H[get_chat_history1 - PostgreSQL Query]
H --> I[aggregate_chat_history - Combine Messages]
I --> J[get_business_data - PostgreSQL Query]
J --> K[aggregate_business_data - Combine Business Data]
K --> L[generate_Summary - AI Analysis]
M[OpenRouter Chat Model] --> L
L --> N[If2 - Validate Summary]
N -->|Valid| O[summary - Set Summary Text]
N -->|Invalid| D
O --> P[add_business_summary - Update Database]
Trigger¶
Execute Workflow Trigger: This workflow is designed to be called by other workflows, receiving a phoneNumber parameter as input.
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 input data and AI output at multiple stages |
| 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 reading youth data and storing results |
| Set | set_yout_data, summary | Data transformation and variable assignment |
| Aggregate | aggregate_chat_history, aggregate_business_data | Combines multiple database records into structured data |
| Chain LLM | generate_Summary | AI-powered analysis and report generation |
| OpenRouter Chat Model | OpenRouter Chat Model | GPT-5.2 language model for business analysis |
External Services & Credentials Required¶
PostgreSQL Database¶
- Credential:
PostgresOnSupabase - Purpose: Stores youth profiles, chat histories, and business tracking data
- Tables Used:
youthEntrepreneursReal- Youth profile and summary datan8n_chat_histories- Chat conversation logsdailyProfitTracking- Business performance metrics
OpenRouter API¶
- Credential:
OpenRouter account - Purpose: 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 connections use stored credentials.
Data Flow¶
Input¶
phoneNumber(string): Phone number identifying the youth entrepreneur
Processing Data¶
- Youth profile data (name, ward, business type, previous summary)
- Chat history (last 30 messages with timestamps)
- Business data (sales, costs, micro-actions, dates)
- Current date for context
Output¶
- Comprehensive business summary text stored in the youth's database profile
- Analysis includes performance trends, engagement assessment, timeline of events, and management recommendations
Error Handling¶
The workflow includes multiple validation points:
- Input Validation: Checks if phone number exists and is not empty
- Data Validation: Verifies youth data was found in database
- Output Validation: Ensures AI generated a valid summary before saving
- Database Error Handling:
get_youth_datanode configured to continue on error withalwaysOutputDataenabled
Failed validations route to a "No Operation" termination node, preventing incomplete data processing.
Known Limitations¶
- Limited to last 30 chat messages and business records
- Requires existing youth profile in database
- AI analysis quality depends on data completeness
- No retry mechanism for failed AI generation
- Database update node is currently disabled in the workflow
Related Workflows¶
This workflow is designed to be called by other workflows in the youth entrepreneurship program system. The trigger suggests it's part of a larger automation pipeline for monitoring and reporting.
Setup Instructions¶
-
Import Workflow: Import the JSON configuration into your n8n instance
-
Configure Database Credentials:
- Create PostgreSQL credential named "PostgresOnSupabase"
- Ensure access to required tables:
youthEntrepreneursReal,n8n_chat_histories,dailyProfitTracking
-
Configure AI Credentials:
- Create OpenRouter API credential named "OpenRouter account"
- Ensure access to GPT-5.2 model
-
Database Schema Requirements:
- Youth table must have
phoneNumber,firstName,youthWard,businessOwned,business_summarycolumns - Chat history table needs
session_id,message,created_timecolumns - Business tracking table requires
phoneNumber,dateOfBusiness,sales,stockingCost,transportCost,otherCost,Micro actionscolumns
- Youth table must have
-
Enable Database Updates:
- Remove the "disabled" flag from the
add_business_summarynode if you want summaries saved to the database
- Remove the "disabled" flag from the
-
Test Execution:
- Use the pinned test data with phone number "+254794443378"
- Verify all database connections and AI model access
- Check that summary generation completes successfully
-
Integration:
- Call this workflow from other workflows using the Execute Workflow node
- Pass the
phoneNumberparameter to trigger analysis