Call Center Youth Summary Generator¶
This workflow provides call center agents with comprehensive youth entrepreneur profiles by extracting phone numbers from queries and generating detailed summaries that include personal information, business performance, credit status, active alerts, and recent conversation history.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
This workflow serves call center agents who need quick access to complete youth entrepreneur profiles. When an agent receives a query containing a phone number, this workflow automatically retrieves and formats all relevant information about that youth, including their business performance trends, credit management status, any pending alerts, and recent AI conversation history. This enables agents to provide informed, personalized support without manually searching through multiple systems.
How It Works¶
- Query Processing: The workflow receives a text query from another workflow and uses AI to extract any phone number mentioned
- Phone Normalization: Converts the extracted phone number to standard Kenyan format (+254XXXXXXXXX)
- Validation: Checks if a valid phone number was found and provided
- Profile Lookup: Searches the youth entrepreneurs database for the normalized phone number
- Data Aggregation: If found, retrieves related data from multiple tables:
- Youth profile information (personal details, business info, current status)
- Recent profit tracking data (last 14 days of business performance)
- Credit management status and micro-actions
- Active alerts requiring attention
- Recent AI chat history
- Summary Generation: Formats all collected data into a comprehensive, readable summary
- Response: Returns either the complete summary or appropriate error messages
Workflow Diagram¶
graph TD
A[When Executed by Another Workflow] --> B[Information Extractor]
B --> C[Normalize Phone]
C --> D[If Phone Valid]
D -->|Valid| E[Query Youth Profile]
D -->|Invalid| F[Return No Phone]
E --> G[If User Found]
G -->|Found| H[Query Profit Data]
G -->|Not Found| I[Return Not Found]
H --> J[Query Credit Status]
J --> K[Query Active Alerts]
K --> L[Query Recent Chat]
L --> M[Format Summary]
M --> N[Return Summary]
F --> N
I --> N
O[OpenRouter Chat Model] -.->|AI Language Model| B
Trigger¶
Execute Workflow Trigger: This workflow is designed to be called by other workflows, receiving input data through the passthrough mode.
Nodes Used¶
| Node Type | Purpose |
|---|---|
| Execute Workflow Trigger | Receives input from calling workflows |
| Information Extractor (LangChain) | Uses AI to extract phone numbers from text queries |
| OpenRouter Chat Model | Provides AI language model for information extraction |
| Code (Normalize Phone) | Converts phone numbers to standard Kenyan format |
| If (Phone Valid) | Validates extracted phone number |
| If (User Found) | Checks if youth profile exists in database |
| Postgres (Multiple) | Queries various database tables for youth data |
| Code (Format Summary) | Processes and formats all data into readable summary |
| Set (Multiple) | Returns appropriate responses for different scenarios |
External Services & Credentials Required¶
OpenRouter API¶
- Credential Name:
call_center_get_summary(OpenRouter API) - Purpose: Powers the AI information extraction
- Required: API key for OpenRouter service
PostgreSQL Database¶
- Credential Name:
Postgres account - Purpose: Access to youth entrepreneur database
- Required: Database connection details (host, port, database name, username, password)
Environment Variables¶
No specific environment variables are configured in this workflow. All configuration is handled through n8n credentials.
Data Flow¶
Input¶
- Format: JSON object with
queryfield - Example:
{ "query": "Please get summary for youth with phone 0712345678" }
Output¶
- Format: JSON object with
summaryfield - Success Example: Detailed multi-section summary including youth profile, status, profit trends, credit status, alerts, and chat history
- Error Examples:
- "No phone number was provided. Please provide the youth's phone number to retrieve their summary."
- "No youth found with phone number +254712345678. Please verify the number and try again."
Error Handling¶
The workflow includes comprehensive error handling:
- Invalid Phone Numbers: Returns helpful message when no valid phone number is extracted
- User Not Found: Provides clear feedback when phone number doesn't match any youth profile
- Database Errors: All database queries use
alwaysOutputDataandcontinueRegularOutputto handle connection issues gracefully - Missing Data: The formatting logic handles null/empty values with fallbacks to "N/A"
Known Limitations¶
- Phone number extraction relies on AI and may occasionally miss numbers in complex text
- Database queries are limited to recent data (14 days for profit tracking, 10 messages for chat history)
- Summary formatting is optimized for English text and Kenyan phone number formats
- No caching mechanism - each request queries the database fresh
Related Workflows¶
This workflow is designed to be called by other workflows in the call center system. The calling workflow should pass queries containing phone numbers through the trigger.
Setup Instructions¶
-
Import Workflow: Import the JSON into your n8n instance
-
Configure Credentials:
- Set up OpenRouter API credential named
call_center_get_summary - Configure PostgreSQL credential named
Postgres accountwith access to:youthEntrepreneursRealtabledailyProfitTrackingtablecreditTrackingtableceaAlertstablen8n_chat_historiestable
- Set up OpenRouter API credential named
-
Database Requirements: Ensure your PostgreSQL database contains the required tables with the expected schema
-
Test the Workflow:
- Execute manually with test data:
{ "query": "Get summary for 0712345678" } - Verify database connections work
- Check that phone number normalization works for your region
- Execute manually with test data:
-
Integration: Call this workflow from other workflows using the Execute Workflow node, passing queries in the expected format
-
Monitoring: Monitor execution logs to ensure AI extraction and database queries perform as expected