An r/ArtificialInteligence post documented an end-to-end AI visibility audit pipeline: 100 leads/day from Google Maps, scored 0-100 on AI visibility, personalized outreach, full GEO audit on reply. This tutorial reconstructs the data layer using Scavio.
Prerequisites
- Python 3.10+
- Scavio API key
- Anthropic API key (or any LLM)
Walkthrough
Step 1: Daily lead pull from Google Maps
Local-pack query per city + niche.
def daily_leads(city, niche, n=100):
out = []
page = 0
while len(out) < n:
r = requests.post('https://api.scavio.dev/api/v1/search',
headers={'x-api-key': API_KEY},
json={'query': f'{niche} {city}', 'search_type': 'local', 'start': page*20}).json()
out += r.get('local_results', [])
page += 1
if len(r.get('local_results', [])) < 20: break
return out[:n]Step 2: Score each lead 0-100 on AI visibility
SERP query for brand + AI Overviews citations.
def score(lead):
if not lead.get('website'): return 0
domain = lead['website'].split('/')[2]
r = requests.post('https://api.scavio.dev/api/v1/search',
headers={'x-api-key': API_KEY},
json={'query': f'{lead["name"]} reviews', 'include_ai_overview': True}).json()
cited = any(domain in c for c in (r.get('ai_overview') or {}).get('citations', []))
organic = sum(1 for o in r.get('organic_results', [])[:10] if domain in o.get('link',''))
return min(100, organic * 10 + (50 if cited else 0))Step 3: Classify visibility band
Strong / Visible / Weak.
def band(score):
return 'Strong' if score >= 80 else 'Visible' if score >= 40 else 'Weak'Step 4: Generate personalized opener with LLM
Claude writes a 60-word opener using the score.
import anthropic
client = anthropic.Anthropic()
def opener(lead, score):
msg = client.messages.create(model='claude-sonnet-4-6', max_tokens=120,
messages=[{'role':'user','content':f'Write a 60-word cold email opener for {lead["name"]} ({lead["website"]}). Their AI visibility score is {score}/100. Reference one specific gap.'}])
return msg.content[0].textStep 5: Full GEO audit on engaged reply
Deeper Reddit + YouTube + AI Overview pull.
def audit(domain):
return {
'serp': requests.post('https://api.scavio.dev/api/v1/search', headers={'x-api-key': API_KEY}, json={'query': domain, 'include_ai_overview': True}).json(),
'reddit': requests.post('https://api.scavio.dev/api/v1/reddit/search', headers={'x-api-key': API_KEY}, json={'query': domain}).json(),
'youtube': requests.post('https://api.scavio.dev/api/v1/youtube/search', headers={'x-api-key': API_KEY}, json={'query': domain}).json(),
}Python Example
# See steps for full daily pipeline.
leads = daily_leads('Austin TX', 'dentist')
for lead in leads:
s = score(lead)
if s < 40: print('WEAK candidate:', lead['name'], opener(lead, s))JavaScript Example
// Same pattern in TS — POST to /api/v1/search with search_type:'local', then per-lead score query.Expected Output
About 100 leads/day with AI visibility scores, opener drafts, and full audits available on demand. Daily cost: ~300 credits = $1.30 on Scavio Project tier.