Tutorial

How to Build an Agency Prospecting Pipeline

Learn how to build an automated prospecting pipeline for digital marketing agencies that finds, qualifies, and scores local business leads.

Digital marketing agencies need a steady flow of qualified leads: local businesses that need websites, SEO, or digital marketing services. Manual prospecting on Google Maps takes 4-6 hours per session for 30-40 leads. This tutorial automates the pipeline: search for businesses in target niches and cities, evaluate their online presence, score them by opportunity, and export qualified leads for outreach.

Prerequisites

  • Python 3.8+ installed
  • requests library installed
  • A Scavio API key from scavio.dev
  • A list of target niches and cities

Walkthrough

Step 1: Define your target niches and cities

Set up the search matrix: which business types in which locations.

Python
NICHES = ['plumber', 'electrician', 'dentist', 'restaurant', 'auto repair']
CITIES = ['Austin TX', 'Denver CO', 'Portland OR', 'Nashville TN']
API_KEY = os.environ['SCAVIO_API_KEY']

Step 2: Search for businesses

Query Google for each niche-city combination to find local businesses.

Python
import requests, os
H = {'x-api-key': API_KEY}

def find_businesses(niche: str, city: str) -> list:
    resp = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
        json={'platform': 'google', 'query': f'{niche} {city}'}, timeout=10)
    return [{'name': r['title'], 'url': r.get('link', ''), 'snippet': r.get('snippet', '')}
            for r in resp.json().get('organic', [])[:10]]

Step 3: Score each lead by opportunity

Evaluate the lead's online presence to estimate how much they need your services.

Python
def score_lead(lead: dict) -> dict:
    url = lead.get('url', '')
    score = 5  # baseline
    # No website or directory listing only
    if 'yelp.com' in url or 'yellowpages' in url:
        score += 3  # high opportunity, no owned website
    # Check for reviews mention in snippet
    snippet = lead.get('snippet', '').lower()
    if 'no reviews' in snippet or 'be the first' in snippet:
        score += 2  # low online presence
    lead['opportunity_score'] = min(score, 10)
    return lead

# Score all leads
scored = [score_lead(l) for l in leads]

Step 4: Run the full pipeline and export

Iterate through all niche-city combinations, score leads, and export the top ones.

Python
import csv, time

def run_pipeline() -> list:
    all_leads = []
    for niche in NICHES:
        for city in CITIES:
            businesses = find_businesses(niche, city)
            for b in businesses:
                b['niche'] = niche
                b['city'] = city
                score_lead(b)
                all_leads.append(b)
            time.sleep(0.5)
    all_leads.sort(key=lambda x: x['opportunity_score'], reverse=True)
    with open('qualified_leads.csv', 'w', newline='') as f:
        w = csv.DictWriter(f, fieldnames=['name', 'niche', 'city', 'url', 'opportunity_score'])
        w.writeheader()
        w.writerows([{k: l[k] for k in ['name', 'niche', 'city', 'url', 'opportunity_score']} for l in all_leads[:50]])
    print(f'Exported top 50 of {len(all_leads)} leads')
    return all_leads

run_pipeline()

Python Example

Python
import requests, os
H = {'x-api-key': os.environ['SCAVIO_API_KEY']}

def prospect(niche, city):
    data = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
        json={'platform': 'google', 'query': f'{niche} {city}'}, timeout=10).json()
    return [{'name': r['title'], 'url': r.get('link', ''), 'directory_only': 'yelp' in r.get('link', '')}
            for r in data.get('organic', [])[:10]]

JavaScript Example

JavaScript
async function prospect(niche, city) {
  const data = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST', headers: {'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json'},
    body: JSON.stringify({platform: 'google', query: `${niche} ${city}`})
  }).then(r => r.json());
  return (data.organic || []).slice(0, 10).map(r => ({name: r.title, url: r.link}));
}

Expected Output

JSON
A CSV of qualified local business leads scored by opportunity, ready for import into outreach tools like Instantly or Smartlead.

Related Tutorials

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.8+ installed. requests library installed. A Scavio API key from scavio.dev. A list of target niches and cities. A Scavio API key gives you 500 free credits per month.

Yes. The free tier includes 500 credits per month, 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.

Start Building

Learn how to build an automated prospecting pipeline for digital marketing agencies that finds, qualifies, and scores local business leads.