ScavioScavio
ProductPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Build a Cold Email Enrichment Pipeline
Tutorial

How to Build a Cold Email Enrichment Pipeline

Turn a company name into a personalized cold email opener using a search API. Extracts company info, recent news, and tech stack for a targeted first line.

Get Free API KeyAPI Docs

A cold email enrichment pipeline takes a company name, searches for recent company news and product info via the Scavio API, extracts relevant signals, and generates a personalized opening line using an LLM.

Prerequisites

  • Python 3.9+
  • Scavio API key
  • anthropic or openai SDK

Walkthrough

Step 1: Search for company signals

Run two searches per company: one for recent news, one for tech stack and product.

Python
import requests

API_KEY = "your-scavio-api-key"

def search_company(company: str) -> dict:
    signals = {}

    # Recent news
    r1 = requests.post(
        "https://api.scavio.dev/api/v1/search",
        json={"query": f"{company} news 2026", "num_results": 3},
        headers={"x-api-key": API_KEY}, timeout=15
    )
    signals["news"] = r1.json().get("organic_results", [])

    # Product and tech
    r2 = requests.post(
        "https://api.scavio.dev/api/v1/search",
        json={"query": f"{company} product features stack", "num_results": 3},
        headers={"x-api-key": API_KEY}, timeout=15
    )
    signals["product"] = r2.json().get("organic_results", [])

    return signals

Step 2: Extract snippets for the prompt

Combine news and product snippets into a compact context string.

Python
def extract_context(signals: dict, company: str) -> str:
    lines = [f"Company: {company}"]
    for result in signals.get("news", [])[:2]:
        lines.append(f"News: {result.get('title')} - {result.get('snippet', '')[:150]}")
    for result in signals.get("product", [])[:2]:
        lines.append(f"Product: {result.get('snippet', '')[:150]}")
    return "\n".join(lines)

Step 3: Generate the personalized opener

Send the context to an LLM and ask for a one-sentence opener.

Python
import anthropic

ANTHROPIC_KEY = "your-anthropic-key"

def generate_opener(company: str, recipient_role: str = "founder") -> str:
    signals = search_company(company)
    context = extract_context(signals, company)

    prompt = f"""Based on this company context, write ONE personalized first sentence for a cold email to their {recipient_role}. Be specific. No fluff. Max 25 words.

{context}

First sentence:"""

    client = anthropic.Anthropic(api_key=ANTHROPIC_KEY)
    msg = client.messages.create(
        model="claude-sonnet-4-6",
        max_tokens=100,
        messages=[{"role": "user", "content": prompt}]
    )
    return msg.content[0].text.strip()

opener = generate_opener("Retool", recipient_role="Head of Engineering")
print(opener)

Python Example

Python
import requests
import anthropic

SCAVIO_KEY = "your-scavio-api-key"
ANTHROPIC_KEY = "your-anthropic-key"

def get_company_signals(company: str) -> str:
    snippets = []
    for query in [f"{company} news 2026", f"{company} product"]:
        r = requests.post(
            "https://api.scavio.dev/api/v1/search",
            json={"query": query, "num_results": 3},
            headers={"x-api-key": SCAVIO_KEY}, timeout=15
        )
        for res in r.json().get("organic_results", [])[:2]:
            snippets.append(f"{res.get('title')}: {res.get('snippet','')[:120]}")
    return "\n".join(snippets)

def generate_opener(company: str, role: str = "founder") -> dict:
    context = get_company_signals(company)
    prompt = f"""Company context:\n{context}\n\nWrite ONE personalized cold email opening sentence for the {role}. Specific, no fluff, max 25 words."""
    client = anthropic.Anthropic(api_key=ANTHROPIC_KEY)
    msg = client.messages.create(
        model="claude-sonnet-4-6", max_tokens=100,
        messages=[{"role": "user", "content": prompt}]
    )
    return {"company": company, "opener": msg.content[0].text.strip(), "context": context}

def enrich_lead_list(companies: list, role: str = "founder") -> list:
    results = []
    for company in companies:
        try:
            result = generate_opener(company, role)
            print(f"{company}: {result['opener']}")
            results.append(result)
        except Exception as e:
            print(f"Error for {company}: {e}")
    return results

if __name__ == "__main__":
    companies = ["Retool", "Linear", "Vercel"]
    enriched = enrich_lead_list(companies, role="Head of Engineering")
    for e in enriched:
        print(f"\n{e['company']}:\n  {e['opener']}")

JavaScript Example

JavaScript
const SCAVIO_KEY = 'your-scavio-api-key';
const ANTHROPIC_KEY = 'your-anthropic-key';

async function getCompanySignals(company) {
  const queries = [`${company} news 2026`, `${company} product`];
  const snippets = [];
  for (const q of queries) {
    const res = await fetch('https://api.scavio.dev/api/v1/search', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json', 'x-api-key': SCAVIO_KEY },
      body: JSON.stringify({ query: q, num_results: 3 })
    });
    const data = await res.json();
    for (const r of (data.organic_results ?? []).slice(0, 2)) {
      snippets.push(`${r.title}: ${r.snippet?.slice(0, 120) ?? ''}`);
    }
  }
  return snippets.join('\n');
}

async function generateOpener(company, role = 'founder') {
  const context = await getCompanySignals(company);
  const prompt = `Context:\n${context}\n\nWrite ONE personalized cold email first sentence for the ${role}. Max 25 words.`;
  const res = await fetch('https://api.anthropic.com/v1/messages', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json', 'x-api-key': ANTHROPIC_KEY, 'anthropic-version': '2023-06-01' },
    body: JSON.stringify({ model: 'claude-sonnet-4-6', max_tokens: 100, messages: [{ role: 'user', content: prompt }] })
  });
  const msg = await res.json();
  return { company, opener: msg.content[0].text.trim() };
}

console.log(await generateOpener('Retool', 'Head of Engineering'));

Expected Output

JSON
Retool: Saw Retool just launched multiplayer editing for internal tools — curious how your team is handling access control at scale.
Linear: Linear's new Triage mode looks like it halves the noise in engineering standups — is that holding up in practice?
Vercel: Noticed Vercel added Fluid Compute for always-warm serverless — how much did that move the needle on cold start complaints?

Related Tutorials

  • How to Enrich Leads with a Search API in n8n
  • How to Build a Google Maps Lead List with an API
  • How to Verify Competitor Pricing Claims with SERP

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Python 3.9+. Scavio API key. anthropic or openai SDK. A Scavio API key gives you 50 free credits on signup.

Yes. The free tier includes 50 credits on signup, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Related Resources

Best Of

Best Lead Enrichment APIs for Cold Outreach in 2026

Read more
Best Of

Best Search API for Cold Email Enrichment in 2026

Read more
Solution

Enrich Sales Leads with Search Data Instead of Apollo

Read more
Use Case

One-Page Audit Cold Email Outreach

Read more
Use Case

Cold Email E-commerce Data Enrichment

Read more
Workflow

Cold Email Outreach with SERP Audit Personalization

Read more

Start Building

Turn a company name into a personalized cold email opener using a search API. Extracts company info, recent news, and tech stack for a targeted first line.

Get Free API KeyRead the Docs
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

  • Documentation
  • API Reference
  • Quickstart
  • MCP Integration
  • Python SDK

Alternatives

  • Tavily Alternative
  • SerpAPI Alternative
  • Firecrawl Alternative
  • Exa Alternative

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy