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, validates them, and returns corresponding business summary data.

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
  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 Business Summary: Extracts and returns the business summary field from the database results
  6. Handles No Match: If no phone number is found, the workflow does nothing and exits

Workflow Diagram

graph TD
    A[When Executed by Another Workflow] --> B[Information Extractor]
    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[OpenRouter Chat Model] -.->|AI Model| B

Trigger

Execute Workflow Trigger: This workflow is designed to be called by other workflows, not run independently. It accepts input data through the passthrough configuration.

Nodes Used

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

External Services & Credentials Required

  • OpenRouter API: For AI-powered text analysis and information extraction
    • Credential: OpenRouter KDP
  • PostgreSQL Database: For storing and retrieving youth entrepreneur data
    • Credential: kdpTables

Environment Variables

No environment variables are explicitly used in this workflow. All configuration is handled through node parameters and credentials.

Data Flow

Input: - query (string): Text containing potential phone number information

Processing: - Extracts phone number using AI (must be 8+ digits) - Searches database table youthEntrepreneursReal using the phone number - Retrieves matching business summary data

Output: - business_summary (string): The business summary for the matched youth entrepreneur - No output if no valid phone number is found or no database match exists

Error Handling

The workflow includes basic error handling through conditional logic: - Invalid Phone Numbers: If no phone number is extracted or it equals "0", the workflow exits gracefully through the "No Operation" node - Database Errors: Standard PostgreSQL node error handling applies - AI Extraction Failures: The Information Extractor will return "0" for phone numbers if extraction fails

Known Limitations

  • Phone numbers must be 8 or more digits to be considered valid
  • Only searches for exact matches in the database using LIKE operator
  • Returns only the business summary field, not complete entrepreneur records
  • Depends on external AI service availability (OpenRouter)

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

Setup Instructions

  1. Import the Workflow

    • Copy the workflow JSON and import it into your n8n instance
  2. Configure Credentials

    • Set up OpenRouter API credentials with the name "OpenRouter KDP"
    • Configure PostgreSQL credentials with the name "kdpTables"
  3. Database Requirements

    • Ensure the youthEntrepreneursReal table exists in your PostgreSQL database
    • Table must have columns: phoneNumber and business_summary
  4. Test the Workflow

    • Call this workflow from another workflow with a query parameter containing text with phone numbers
    • Verify the AI extraction and database lookup are working correctly
  5. Integration

    • Use the "Execute Workflow" node in other workflows to call this one
    • Pass text data through the query parameter
    • Handle the returned business_summary data as needed