Skip to content

getSummary

This workflow extracts phone numbers from text queries and retrieves business summaries for youth entrepreneurs from a PostgreSQL database. It serves as a lookup service that can be called by other workflows to find entrepreneur profiles based on phone number identification.

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 a phone number
  2. Extracts Phone Number: Uses AI-powered information extraction to identify and extract phone numbers from the input text
  3. Validates Phone Number: Checks if a valid phone number (not "0") was found
  4. Database Lookup: If a valid phone number exists, queries the youthEntrepreneursReal table to find matching records
  5. Returns Summary: Extracts and returns the business summary field from the found entrepreneur record
  6. Handles No Match: If no phone number is found, the workflow ends without performing a database lookup

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. It expects input data with a query field containing text that may include a phone number.

Nodes Used

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

External Services & Credentials Required

  • OpenRouter API: For AI-powered text analysis and phone number extraction
    • Credential: OpenRouter account
  • PostgreSQL Database: For storing and querying youth entrepreneur data
    • Credential: PostgresOnSupabase

Environment Variables

No environment variables are explicitly configured in this workflow. All external service connections are managed through n8n credentials.

Data Flow

Input:

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

Output (Success):

1
2
3
{
  "business_summary": "Tech startup focusing on mobile payment solutions for rural communities"
}

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

Error Handling

The workflow includes basic error handling through conditional logic:

  • Invalid Phone Number: If the Information Extractor returns "0" (indicating no phone number found), the workflow routes to a No Operation node instead of attempting a database query
  • Database Errors: Standard PostgreSQL node error handling applies if the database is unavailable or the query fails

Known Limitations

  • Phone number extraction relies on AI interpretation, which may not be 100% accurate for all text formats
  • The workflow only extracts the first phone number found in the input text
  • Database queries use LIKE matching, which may return multiple results if phone numbers are stored in different formats
  • No validation of phone number format or length beyond the AI extraction

This workflow is designed to be called by other workflows that need to look up entrepreneur information based on phone numbers found in text.

Setup Instructions

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

  2. Configure Credentials:

    • Set up OpenRouter API credentials with your API key
    • Configure PostgreSQL credentials for your Supabase database
  3. Verify Database Schema: Ensure your PostgreSQL database has a table named youthEntrepreneursReal with columns:

    • phoneNumber (for matching)
    • business_summary (for output)
  4. Test the Workflow:

    • Use the pinned test data or create a test execution
    • Verify the Information Extractor correctly identifies phone numbers
    • Confirm database connectivity and query results
  5. Integration: Call this workflow from other workflows using the Execute Workflow node, passing data with a query field containing text that includes phone numbers.