Skip to content

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

  1. Phone Number Extraction: When triggered by another workflow, the system extracts and normalizes phone numbers from the input query using regex patterns
  2. Format Validation: Phone numbers are standardized to Kenyan format (+254) and validated
  3. Database Lookup: If a valid phone number is found, the workflow queries the youthEntrepreneursReal table to find matching records
  4. Data Processing: Retrieved records are processed to extract the business summary field
  5. 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 youthEntrepreneursReal table in public schema
  • 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

Output

  • Success Case: Object containing business_summary field 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

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

  1. Import Workflow: Import the workflow JSON into your n8n instance

  2. Configure PostgreSQL Credentials:

    • Create a new PostgreSQL credential named "Postgres account"
    • Configure connection to your database containing the youthEntrepreneursReal table
    • Ensure the credential has read access to the public.youthEntrepreneursReal table
  3. Database Schema Requirements:

    • Table: youthEntrepreneursReal
    • Required columns: phoneNumber (text), business_summary (text)
  4. Error Workflow Setup:

    • Ensure error workflow with ID cuHEGQjAfvuGwIOD exists or update the error workflow reference
  5. Testing:

    • Use the manual trigger to test database connectivity
    • Test phone number extraction with various formats using the Execute Workflow trigger
  6. Integration:

    • Configure calling workflows to pass data with a query field containing phone numbers
    • Ensure calling workflows can handle cases where this workflow returns no data