An r/micro_saas post showed that the best LinkedIn replies reference specific company context. The problem: manually researching each prospect before replying takes too long. This tutorial builds an enrichment step that pulls company data from search before you craft a reply.
Prerequisites
- Scavio API key
- Python 3.8+
- LinkedIn messages or connection requests to respond to
Walkthrough
Step 1: Extract prospect info from LinkedIn message
Parse the company and person name from the conversation.
def parse_prospect(linkedin_message):
# In practice, you would extract from LinkedIn UI or API
return {
'name': linkedin_message.get('sender_name', ''),
'company': linkedin_message.get('company', ''),
'title': linkedin_message.get('title', ''),
'message': linkedin_message.get('text', '')
}Step 2: Enrich with search data
Search for the prospect's company and recent news.
import requests, os
H = {'x-api-key': os.environ['SCAVIO_API_KEY']}
def enrich_prospect(company, person_name):
# Company info
company_data = requests.post('https://api.scavio.dev/api/v1/search',
headers=H,
json={'platform': 'google', 'query': f'{company} company'}).json()
# Recent news
news = requests.post('https://api.scavio.dev/api/v1/search',
headers=H,
json={'platform': 'google', 'query': f'{company} news 2026'}).json()
# Person background
person = requests.post('https://api.scavio.dev/api/v1/search',
headers=H,
json={'platform': 'google', 'query': f'{person_name} {company}'}).json()
return {
'company_results': company_data.get('organic_results', [])[:3],
'news': news.get('organic_results', [])[:3],
'person': person.get('organic_results', [])[:3]
}Step 3: Generate reply context summary
Summarize the enrichment data into a brief context sheet.
def context_summary(enrichment):
summary = 'CONTEXT FOR REPLY:\n\n'
summary += 'Company:\n'
for r in enrichment['company_results']:
summary += f" - {r.get('title', '')}: {r.get('snippet', '')}\n"
summary += '\nRecent News:\n'
for r in enrichment['news']:
summary += f" - {r.get('title', '')}\n"
summary += '\nPerson Background:\n'
for r in enrichment['person']:
summary += f" - {r.get('title', '')}: {r.get('snippet', '')}\n"
return summaryStep 4: Draft an informed reply
Use the context to write a reply that shows you did your homework.
def draft_reply(prospect, context):
# In production, feed context to an LLM for drafting
# Here is a manual template approach
news_ref = context['news'][0].get('title', '') if context.get('news') else ''
reply = (f'Thanks for reaching out, {prospect["name"]}.\n\n')
if news_ref:
reply += f'I noticed {prospect["company"]} was recently covered -- '
reply += f'"{news_ref}" caught my eye.\n\n'
reply += 'Would love to explore how we might work together.'
return replyPython Example
import os, requests
H = {'x-api-key': os.environ['SCAVIO_API_KEY']}
def enrich_for_reply(company, person):
for q in [f'{company} company', f'{company} news 2026', f'{person} {company}']:
data = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
json={'platform': 'google', 'query': q}).json()
for r in data.get('organic_results', [])[:2]:
print(f" {r.get('title', '')}")
enrich_for_reply('Notion', 'Ivan Zhao')JavaScript Example
const enrichment = 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: `${company} news 2026`})
}).then(r => r.json());Expected Output
Context sheet with company overview, recent news, and person background. 3 search queries per prospect = $0.015. Use the context to write informed LinkedIn replies.