DEV Community

Cover image for How can you find your target market if you don't know what your product is.
Mushood Hanif
Mushood Hanif

Posted on

How can you find your target market if you don't know what your product is.

Most people try to find customers before they understand what they’re actually selling.

That’s backwards.

Context changes everything.

This simple philosophy completely changes how we think about automated sales agents. Instead of blasting generic outreach, we let context define who to target, what to say, and why it matters.

In this article, I’ll walk through a 4-part n8n workflow that builds an autonomous, context-aware sales system—from raw product knowledge to hyper-personalized outreach.

The Big Idea

We start by creating a knowledge base that acts as persistent context across the entire workflow.

This context:

  • Guides AI agents
  • Improves lead quality
  • Enables real market research based on what the product actually offers

Think of it as giving your sales agent a memory—because amnesia is bad for revenue.

Use Case

Lead generation for product-based sales

Tech Required

All tools used either have free tiers or are generously priced.

  • Neon DB – Store research and lead data (Google Sheets works too, but rate limits will eventually ruin your day)
  • Google Serper – Web search for AI agents
  • Google Drive – Knowledge base document storage
  • Pinecone – Vector database for contextual retrieval
  • Hunter.io – Email discovery for outreach
  • Email Client – Gmail or any SMTP-capable service
  • Gemini – Our LLM powering the agents

Good to Know

This entire workflow is:

  • Low-cost
  • Scalable
  • Fully automated
  • Slightly terrifying (for traditional sales teams)

How It Works (High Level)

  1. Convert your knowledge base into embeddings
  2. Use that context to generate targeted search queries
  3. Research companies and identify decision-makers
  4. Send hyper-personalized outreach emails

Four workflows. One autonomous sales machine.

Step 1 – Context Creation

RAG Pipeline + State Management

This workflow synchronizes documents from Google Drive into Pinecone while preventing redundant processing using Google Sheets as a record manager.

1. File Discovery & Filtering

  • Trigger: Manual or scheduled
  • Google Drive Integration: Scans a specific folder
  • Validation:

    • IF Node checks whether the item is a folder or a file
    • Folders are ignored
    • Files move forward for processing

2. Change Detection (State Management)

To save time, tokens, and money:

  • Hashing:

    • Generate a SHA256 hash of the file contents
  • Record Lookup:

    • Check Google Sheets for existing file IDs and hashes
  • Switch Logic:

    • New file → Process & store
    • Hash changed → Re-process & update
    • Hash unchanged → Skip

Efficiency is the real growth hack.

3. Data Ingestion & Vectorization

  • Data Loading:

    • Download file and extract text
  • Text Splitting:

    • Recursive Character Splitter
    • 1000 characters per chunk
    • 10-character overlap
  • Embedding:

    • Google Gemini Embedding Model converts chunks into vectors

4. Vector Storage

  • Pinecone:

    • Upserts embeddings + metadata (file name, ID)
  • Namespacing:

    • Clears namespace to ensure updated docs replace old ones

This workflow runs once, or whenever new documents are added.

Step 2 – Lead Generation

AI-Powered Market Discovery

This workflow turns product knowledge into qualified company leads—not random internet noise.

1. Strategy Generation (The “Brain”)

  • Trigger: Scheduled (daily or weekly)
  • Lead Criteria Agent:

    • Gemini analyzes the Pinecone knowledge base
  • Output:

    • Structured JSON defining:
    • Ideal industries (e.g., FinTech, HealthTech)
    • Company size
    • High-intent Google search queries
    • Queries are optimized to find company websites, not blogs

2. Automated Web Research

  • Loop: Iterates through generated queries
  • Google Serper:

    • Executes live searches
    • Uses negative operators (-site:medium.com, -site:linkedin.com, etc.)

No listicles. No influencers. Just businesses.

3. Data Parsing & Scoring

  • Code Node (JavaScript):

    • Removes “Top 10” list pages
    • Identifies real company homepages
    • Scores results based on:
    • /products or /solutions pages
    • Extracts:
    • Clean company name
    • Domain

4. Database Integration & De-duplication

  • Postgres Check:

    • Pulls existing companies
  • Filtering:

    • Discards duplicates
  • Insert:

    • Saves only new, high-quality leads into the search table

Step 3 – Contact Generation

Deep Research & Lead Enrichment

Now we turn companies into actual humans you can email.

1. Lead Retrieval & Throttling

  • Trigger: Daily
  • Database Query:

    • Fetch up to 5 unprocessed companies
  • Wait Nodes:

    • Throttle API calls to avoid rate limits

Patience is cheaper than API overages.

2. Deep Company Research (AI Analyst)

  • Company Research Agent (Gemini):

    • Uses:
    • Google Serper (news, competitors, challenges)
    • Pinecone (product-feature matching)
  • Output:

    • Structured JSON with:
    • Industry pain points
    • Custom use cases
    • Why this company needs your product

3. Contact Enrichment (Finding the “Who”)

  • Hunter.io:

    • Finds emails and LinkedIn profiles
  • Decision Maker Filtering:

    • Extracts:
    • Names
    • Titles
    • Verified emails
    • Removes null or generic results

4. Final Data Storage

  • Validation:

    • Ensure at least one valid email exists
  • Insert:

    • Save enriched leads into the leads table
  • Status Update:

    • Mark company as processed to avoid repeats

Step 4 – Outreach

Hyper-Personalized Email Engine

This is where everything comes together.

1. Lead Selection

  • Trigger: Daily at 2 AM
  • Database Query:

    • Fetch up to 5 leads with no sent_date
  • Batching:

    • Process leads one by one for quality

2. AI Copywriting (The Personalization Agent)

  • Context Injection:

    • Prospect name & title
    • Deep company research
    • Product knowledge (via Pinecone)
  • Prompt Instructions:

    • 150–200 words
    • Professional, friendly tone
    • Written as the CEO
    • References:
    • Specific company news
    • Industry challenges
    • Relevant product features

No “Hope this email finds you well.”

3. Automated Sending (Gmail)

  • Parser:

    • Ensures clean JSON:
    • Subject
    • HTML body
    • CTA
  • Gmail Integration:

    • Sends email directly from your account

4. Closing the Loop

  • Database Update:

    • Save sent_date
    • Store full email_content
  • Result:

    • No duplicate outreach
    • Full audit trail for sales

The End-to-End Result

You’ve built a fully autonomous sales department:

  • Workflow 1: Syncs product knowledge
  • Workflow 2: Finds companies that need it
  • Workflow 3: Identifies decision-makers
  • Workflow 4: Sends personalized outreach emails

All driven by context.
All running on autopilot.

Sales, but make it intelligent.

Top comments (0)