Skip to content

getSummary_testing

This workflow extracts phone numbers from query strings, normalizes them to Kenyan format (+254), and retrieves business summary information for youth entrepreneurs from a PostgreSQL database.

Purpose

No business context provided yet — add a context.md to enrich this documentation.

How It Works

  1. Trigger: The workflow starts when executed by another workflow, receiving input data with a query string
  2. Phone Number Extraction: A JavaScript code node parses the query string to extract phone numbers using regex patterns
  3. Phone Number Normalization: The extracted phone number is converted to standard Kenyan format (+254XXXXXXXXX)
  4. Validation Check: An IF condition verifies that a valid phone number was extracted (not equal to "0")
  5. Database Lookup: If valid, the workflow queries the youthEntrepreneursReal table to find matching records
  6. Data Processing: The business summary field is extracted and formatted for output
  7. Error Handling: If no valid phone number is found, the workflow takes a no-operation path

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 passthrough input
  • Secondary: Manual Trigger - For testing 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 Parses and normalizes phone numbers from query strings
IF If Validates extracted phone number
Postgres Select rows from a table Queries youth entrepreneur database
Set Edit Fields Formats business summary output
No Operation No Operation, do nothing Handles invalid phone number cases
Manual Trigger When clicking 'Execute workflow' Manual testing trigger
Postgres Select rows from a table1 Testing database query

External Services & Credentials Required

  • PostgreSQL Database:
    • Credential: kdpTestEnv
    • Access to youthEntrepreneursReal table in public schema
    • Required permissions: SELECT

Environment Variables

No environment variables are explicitly used in this workflow.

Data Flow

Input

  • Query string containing a phone number in various formats:
    • +254707060397
    • 254707060397
    • 0707060397
    • 707060397

Processing

  • Phone number extraction and normalization to +254 format
  • Database lookup by normalized phone number
  • Business summary field extraction

Output

  • business_summary: String containing the business summary for the matched entrepreneur

Error Handling

  • Invalid Phone Number: If no valid phone number is extracted, the workflow routes to a no-operation node
  • No Database Match: The workflow continues even if no matching records are found in the database
  • Regex Fallback: Returns phone number "0" if no valid pattern is matched

Known Limitations

  • Only supports Kenyan phone number formats (+254)
  • Relies on regex pattern matching which may not catch all edge cases
  • No explicit error handling for database connection failures
  • Testing components (manual trigger and secondary database query) are mixed with production logic

This workflow is designed to be called by other workflows but no specific related workflows are documented.

Setup Instructions

  1. Import Workflow: Import the JSON into your n8n instance
  2. Configure Database Credential:
    • Create a PostgreSQL credential named kdpTestEnv
    • Ensure access to the youthEntrepreneursReal table
  3. Database Schema: Verify the target table has these columns:
    • phoneNumber (for matching)
    • business_summary (for output)
  4. Test the Workflow:
    • Use the manual trigger with sample data
    • Verify phone number extraction works with various formats
    • Confirm database connectivity and data retrieval
  5. Integration: Call this workflow from other workflows, passing query strings containing phone numbers