Create Business Summary for Youth¶
This workflow generates comprehensive business performance summaries for youth entrepreneurs by analyzing their chat history, business data, and profile information. It uses AI to create manager-friendly reports that help field staff quickly understand each youth's business progress, engagement levels, and key opportunities or risks.
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 where: - Young entrepreneurs receive business coaching through an AI assistant - They track daily sales, costs, and business activities - Field managers need regular summaries to monitor progress and provide targeted support - The system maintains detailed records of interactions and business performance
How It Works¶
- Input Validation: The workflow receives a phone number and validates it exists and is not empty
- Youth Data Retrieval: Looks up the youth's profile information from the database using their phone number
- Chat History Collection: Retrieves the last 30 chat messages between the youth and the 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 an AI model to analyze all data and generate a comprehensive business summary
- Summary Validation: Checks that the AI generated a valid response
- Database Update: Saves the generated summary back to the youth's profile for future reference
Workflow Diagram¶
graph TD
A[When Executed by Another Workflow] --> B[If: Phone Number Valid?]
B -->|Yes| C[get_chat_history]
B -->|No| D[No Operation, do nothing]
C --> E[get_youth_data]
E --> F[If1: Youth Found?]
F -->|Yes| G[set_yout_data]
F -->|No| D
G --> H[get_chat_history1]
H --> I[aggregate_chat_history]
I --> J[get_business_data]
J --> K[aggregate_business_data]
K --> L[generate_Summary]
M[OpenRouter Chat Model] --> L
L --> N[If2: Summary Generated?]
N -->|Yes| O[summary]
N -->|No| D
O --> P[add_business_summary]
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 response at multiple stages |
| No Operation | get_chat_history, No Operation do nothing | Placeholder and termination nodes |
| Postgres | get_youth_data, get_chat_history1, get_business_data, add_business_summary | Database operations for retrieving and updating youth information |
| Set | set_yout_data, summary | Data transformation and preparation |
| Aggregate | aggregate_chat_history, aggregate_business_data | Combines multiple database records into single objects |
| Chain LLM | generate_Summary | AI-powered analysis and summary generation |
| OpenRouter Chat Model | OpenRouter Chat Model | Language model for generating business summaries |
External Services & Credentials Required¶
Database¶
- PostgreSQL: Stores youth profiles, chat histories, and business tracking data
- Credential:
kdpTables- Database connection for accessing youth entrepreneur data
AI Service¶
- OpenRouter API: Provides access to language models for summary generation
- Credential:
OpenRouter KDP- API key for OpenRouter service
Environment Variables¶
No specific environment variables are configured in this workflow. All external connections use stored credentials.
Data Flow¶
Input¶
phoneNumber(string): The youth entrepreneur's phone number used as identifier
Processing Data¶
- Youth profile data (name, ward, business type, previous summary)
- Chat history (last 30 messages with timestamps)
- Business tracking data (sales, costs, micro-actions)
- Current date for context
Output¶
- Comprehensive business summary (approximately 300 words)
- Manager quick brief (5-6 bullet points)
- Timeline of key events
- Business health assessment with recommendations
- Updated youth profile with new summary
Error Handling¶
The workflow includes several validation checkpoints:
- Input Validation: Stops execution if phone number is missing or empty
- Youth Data Validation: Terminates if no youth record is found for the phone number
- AI Response Validation: Ensures the AI generated a valid summary before saving
- Database Error Handling: The
get_youth_datanode is configured to continue on error
Failed executions route to "No Operation, do nothing" nodes to prevent workflow crashes.
Known Limitations¶
- Limited to analyzing the last 30 chat messages and business records
- Requires existing youth profile in the database
- Dependent on external AI service availability
- Summary quality depends on the completeness of input data
- No retry mechanism for failed AI generation
Related Workflows¶
This workflow is designed to be called by other workflows in the youth entrepreneurship system, likely: - Scheduled summary generation workflows - Manager dashboard update processes - Alert or notification systems
Setup Instructions¶
-
Import the Workflow
- Copy the workflow JSON
- Import into your n8n instance
-
Configure Database Credentials
- Set up PostgreSQL credential named
kdpTables - Ensure access to tables:
youthEntrepreneursReal,n8n_chat_histories,dailyProfitTracking
- Set up PostgreSQL credential named
-
Configure AI Service
- Set up OpenRouter API credential named
OpenRouter KDP - Ensure sufficient API credits for language model usage
- Set up OpenRouter API credential named
-
Database Schema Requirements
youthEntrepreneursReal: Youth profiles with phoneNumber, firstName, youthWard, businessOwned, business_summary fieldsn8n_chat_histories: Chat records with session_id, message, created_time fieldsdailyProfitTracking: Business data with phoneNumber, dateOfBusiness, sales, costs, and micro-actions
-
Test the Workflow
- Execute with a valid phone number from your database
- Verify the generated summary is saved to the youth's profile
- Check that all database connections work properly
-
Integration
- Call this workflow from other workflows using the Execute Workflow node
- Pass the
phoneNumberparameter in the input data