Skip to content

getSummary Workflow

This workflow extracts phone numbers from text queries and retrieves business summaries for youth entrepreneurs from a PostgreSQL database. It uses AI-powered information extraction to identify phone numbers and returns relevant business information when a match is 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 an AI-powered information extractor to identify and extract phone numbers from the input text (must be 8+ digits)
  3. Validates Phone Number: Checks if a valid phone number was found (not equal to "0")
  4. Database Lookup: If a phone number exists, queries the youthEntrepreneursReal table in PostgreSQL to find matching records
  5. Returns Business Summary: Extracts and returns the business summary field from the database record
  6. Handles No Match: If no phone number is found, the workflow takes no action

Workflow Diagram

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

Trigger

  • Type: Execute Workflow Trigger
  • Source: Called by another workflow
  • Input: Expects a JSON object with a query field containing text to analyze

Nodes Used

Node Type Purpose
Execute Workflow Trigger Receives input from calling workflow
Information Extractor Uses AI to extract phone numbers from text
OpenRouter Chat Model Provides AI language model for information extraction
If Conditional logic to check if phone number was found
Postgres Queries database for matching entrepreneur records
Set (Edit Fields) Formats output to return business summary
No Operation Handles cases where no phone number is found

External Services & Credentials Required

OpenRouter API

  • Purpose: Provides AI language model for information extraction
  • Credential Name: "OpenRouter account"
  • Required: API key for OpenRouter service

PostgreSQL Database

  • Purpose: Stores youth entrepreneur data including business summaries
  • Credential Name: "PostgresOnSupabase"
  • Required: Database connection details (host, port, database name, username, password)

Environment Variables

No environment variables are explicitly configured in this workflow. All external service connections use n8n credential management.

Data Flow

Input

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

Processing

  1. Extracts phone number: "+254794443378"
  2. Searches database for matching phone number
  3. Retrieves business summary from matching record

Output

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

Error Handling

The workflow includes basic error handling through conditional logic:

  • No Phone Number Found: If the AI extractor returns "0" (no valid phone number), the workflow routes to a no-operation node
  • No Database Match: If no records match the phone number, the workflow will complete without returning data

No explicit error handling is configured for API failures or database connection issues.

Known Limitations

  • Phone numbers must be 8 or more digits to be considered valid
  • Only searches the youthEntrepreneursReal table
  • Returns only the business summary field, not complete entrepreneur profiles
  • No validation of phone number format beyond digit count
  • Dependent on AI model accuracy for phone number extraction

This workflow is designed to be called by other workflows and does not directly reference any related workflows in its configuration.

Setup Instructions

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

  2. Configure OpenRouter Credentials:

    • Create new credential of type "OpenRouter API"
    • Name it "OpenRouter account"
    • Add your OpenRouter API key
  3. Configure PostgreSQL Credentials:

    • Create new credential of type "Postgres"
    • Name it "PostgresOnSupabase"
    • Configure connection details for your Supabase/PostgreSQL instance
  4. Verify Database Table:

    • Ensure the youthEntrepreneursReal table exists
    • Confirm it has phoneNumber and business_summary columns
  5. Test the Workflow:

    • Use the pinned test data or call from another workflow
    • Verify phone number extraction and database lookup work correctly
  6. Activate Workflow: Enable the workflow to make it available for execution by other workflows

The workflow is ready to use once credentials are configured and the database table is accessible.