Skip to content

getSummary - Francis

This workflow extracts phone numbers from text queries and retrieves business summary information for youth entrepreneurs from a PostgreSQL database. It uses AI-powered information extraction to identify phone numbers, validates them, and returns corresponding business summaries when matches are found.

Purpose

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

How It Works

  1. Receives Input: The workflow is triggered by another workflow with a text query containing potential phone number information
  2. Extracts Phone Number: Uses AI to analyze the input text and extract any phone numbers (8+ digits)
  3. Validates Phone Number: Checks if a valid phone number was found (not "0")
  4. Database Lookup: If a phone number exists, searches the youthEntrepreneursReal table for matching records
  5. Returns Summary: Extracts and returns the business summary field from the database record
  6. Handles No Match: If no phone number is found, the workflow does nothing and ends

Workflow Diagram

graph TD
    A[When Executed by Another Workflow] --> B[Information Extractor]
    C[OpenRouter Chat Model] -.-> B
    B --> D[If Phone Number Valid?]
    D -->|Yes| E[Select rows from a table]
    D -->|No| F[No Operation, do nothing]
    E --> G[Edit Fields]

Trigger

Execute Workflow Trigger: This workflow is designed to be called by other workflows, not run independently. It expects input data with a query field containing text to analyze.

Nodes Used

Node Type Purpose
Execute Workflow Trigger Receives input from calling workflows
Information Extractor Uses AI to extract phone numbers from text
OpenRouter Chat Model Provides language model for information extraction
If Validates whether a phone number was successfully extracted
Postgres Queries the youth entrepreneurs database
Set (Edit Fields) Formats the output to return business summary
No Operation Handles cases where no phone number is found

External Services & Credentials Required

  • OpenRouter API: For AI-powered information extraction
    • Credential: OpenRouter account
    • Used for natural language processing to identify phone numbers
  • PostgreSQL Database: For storing and retrieving youth entrepreneur data
    • Credential: PostgresOnSupabase
    • Accesses the youthEntrepreneursReal table

Environment Variables

No environment variables are explicitly configured in this workflow. All external service connections use stored credentials.

Data Flow

Input:

1
2
3
{
  "query": "Contact John at +254794443378 for business inquiries"
}

Processing: - Extracts phone number: "+254794443378" - Searches database for matching phoneNumber - Retrieves business_summary field

Output (Success):

1
2
3
{
  "business_summary": "Description of the entrepreneur's business"
}

Output (No Phone Number Found): No output - workflow ends at No Operation node

Error Handling

The workflow includes basic error handling: - Invalid Phone Numbers: If no valid phone number is extracted (returns "0"), the workflow gracefully exits without database queries - No Database Match: If the phone number doesn't exist in the database, no error occurs but no output is generated

Known Limitations

  • Phone number extraction relies on AI interpretation and may not catch all formats
  • Only searches for exact matches in the database using LIKE operator
  • No fuzzy matching for similar phone numbers
  • Workflow is inactive and must be manually activated for use

This workflow is designed to be called by other workflows but no specific parent workflows are identified in the current configuration.

Setup Instructions

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

  2. Configure Credentials:

    • Set up OpenRouter API credentials with ID nyvOZDRjkDTKcdPt
    • Configure PostgreSQL credentials with ID Hw9XWerQ5RNHaVTk pointing to your Supabase instance
  3. Database Setup: Ensure your PostgreSQL database contains:

    • Table: youthEntrepreneursReal
    • Columns: phoneNumber, business_summary
  4. Activate Workflow: Enable the workflow in n8n

  5. Test: Call from another workflow with test data:

    1
    2
    3
    {
      "query": "Test phone number +254794443378"
    }
    

  6. Integration: Configure calling workflows to pass text queries containing phone numbers to this workflow for business summary retrieval