getSummary Workflow¶
This workflow retrieves business summary information for youth entrepreneurs by extracting phone numbers from queries and looking up corresponding records in a PostgreSQL database.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
How It Works¶
- Phone Number Extraction: When triggered by another workflow, the system extracts and normalizes phone numbers from the input query using regex patterns
- Format Validation: Phone numbers are standardized to Kenyan format (+254) and validated
- Database Lookup: If a valid phone number is found, the workflow queries the
youthEntrepreneursRealtable to find matching records - Data Processing: Retrieved records are processed to extract the business summary field
- Output Generation: The business summary is returned as the final output
The workflow includes a manual trigger path for testing that retrieves all records from the database without filtering.
Workflow Diagram¶
graph TD
A[When Executed by Another Workflow] --> B[Extract Phone Number]
B --> C{If Phone Number Valid}
C -->|Yes| D[Select rows from a table]
C -->|No| E[No Operation, do nothing]
D --> F[Edit Fields]
G[When clicking Execute workflow] --> H[Select rows from a table1]
Trigger¶
- Primary: Execute Workflow Trigger - Called by other workflows with input data containing a query string
- Secondary: Manual Trigger - For testing and development purposes
Nodes Used¶
| Node Type | Node Name | Purpose |
|---|---|---|
| Execute Workflow Trigger | When Executed by Another Workflow | Receives input from calling workflows |
| Code | Extract Phone Number | Extracts and normalizes phone numbers from query strings |
| If | If | Validates if a phone number was successfully extracted |
| Postgres | Select rows from a table | Queries database for entrepreneur records by phone number |
| Set | Edit Fields | Extracts business_summary field from database results |
| No Operation | No Operation, do nothing | Handles cases where no valid phone number is found |
| Manual Trigger | When clicking 'Execute workflow' | Manual testing trigger |
| Postgres | Select rows from a table1 | Testing query that retrieves all database records |
External Services & Credentials Required¶
PostgreSQL Database¶
- Credential Name: "Postgres account"
- Required Access: Read access to
youthEntrepreneursRealtable inpublicschema - Tables Used:
youthEntrepreneursReal - Required Columns:
phoneNumber,business_summary
Environment Variables¶
No environment variables are explicitly configured in this workflow. Database connection details are managed through n8n credentials.
Data Flow¶
Input¶
- Query String: Text containing a phone number in various formats:
- International:
+254707060397 - National:
254707060397 - Local:
0707060397 - Short:
707060397
- International:
Output¶
- Success Case: Object containing
business_summaryfield from matching database record - No Match Case: No output (workflow terminates at No Operation node)
- Invalid Phone Case: No output (workflow terminates at No Operation node)
Phone Number Normalization¶
The workflow handles multiple Kenyan phone number formats and normalizes them to +254XXXXXXXXX format.
Error Handling¶
- Invalid Phone Numbers: If no valid phone number is extracted, the workflow routes to a No Operation node and terminates gracefully
- Database Errors: The workflow is configured with an error workflow (ID:
cuHEGQjAfvuGwIOD) to handle database connection or query failures - Missing Data: If no matching records are found in the database, the workflow will return empty results
Known Limitations¶
- Phone number extraction is optimized for Kenyan phone numbers (+254 country code)
- Regex pattern may not capture all international phone number formats
- Database queries use LIKE operator which may have performance implications on large datasets
- No input validation for malformed query strings beyond phone number extraction
Related Workflows¶
This workflow is designed to be called by other workflows as indicated by the Execute Workflow Trigger. The specific calling workflows are not identified in the current configuration.
Setup Instructions¶
-
Import Workflow: Import the workflow JSON into your n8n instance
-
Configure PostgreSQL Credentials:
- Create a new PostgreSQL credential named "Postgres account"
- Configure connection to your database containing the
youthEntrepreneursRealtable - Ensure the credential has read access to the
public.youthEntrepreneursRealtable
-
Database Schema Requirements:
- Table:
youthEntrepreneursReal - Required columns:
phoneNumber(text),business_summary(text)
- Table:
-
Error Workflow Setup:
- Ensure error workflow with ID
cuHEGQjAfvuGwIODexists or update the error workflow reference
- Ensure error workflow with ID
-
Testing:
- Use the manual trigger to test database connectivity
- Test phone number extraction with various formats using the Execute Workflow trigger
-
Integration:
- Configure calling workflows to pass data with a
queryfield containing phone numbers - Ensure calling workflows can handle cases where this workflow returns no data
- Configure calling workflows to pass data with a