Automated Prospecting with AI Agents
Build an agent that takes a list of target companies, finds decision-makers, enriches their profiles, researches them on LinkedIn, and generates personalised outreach—all autonomously.
Overview
Traditional prospecting is a grind: research a company, find the right person, dig up their email, stalk their LinkedIn, write a message, repeat. An AI agent can do the entire loop in seconds.
This guide walks through building a Python agent that uses ABM.dev APIs to automate the full workflow—from a list of company domains to personalised LinkedIn messages sitting in your prospect’s inbox.
The Workflow
// end-to-end prospecting flow
Step 1: Define Target Companies
Start with a simple list of company domains. Your agent will use these as the starting point for the entire pipeline.
# target_companies.py
targets = [
"acme.com",
"globex.io",
"initech.co",
"umbrella-corp.com",
]
# Titles to target at each company
target_titles = [
"VP of Sales",
"Head of Revenue",
"CRO",
"Director of Business Development",
]
You can also pull these dynamically from your CRM or an ICP filter. The format is just a list of domain strings—the enrichment API handles the rest.
Step 2: Enrich Contacts
For each contact you find, fire an enrichment request. The API pulls data from 10+ sources and returns a unified profile.
# enrich each contact via ABM.dev
import requests
API_KEY = "abm_live_..."
BASE_URL = "https://api.abm.dev/v1"
def enrich_contact(email: str, company_domain: str) -> dict:
response = requests.post(
f"{BASE_URL}/enrichments",
headers={"Authorization": f"Bearer {API_KEY}"},
json={"email": email,"company_domain": company_domain},
)
response.raise_for_status()
return response.json()
Step 3: Research on LinkedIn
Once a contact is enriched, pull their LinkedIn profile for deeper context—recent posts, job history, mutual connections.
# pull LinkedIn profile for personalisation
def get_linkedin_profile(linkedin_id: str) -> dict:
response = requests.get(
f"{BASE_URL}/linkedin/profile/{linkedin_id}",
headers={"Authorization": f"Bearer {API_KEY}"},
)
response.raise_for_status()
return response.json()
Step 4: Generate Personalised Messages
Combine enrichment data with LinkedIn context in a prompt template. Feed it to your favourite LLM to generate a message that feels human.
# prompt template for personalised outreach
PROMPT_TEMPLATE = """
You are a sales development representative.
Write a short, personalised LinkedIn message to {name}.
About them:
- Title: {title} at {company}
- Recent LinkedIn post: {recent_post}
- Background: {background}
Rules:
- Reference their recent post naturally
- Keep it under 300 characters
- No pitching in first message — just start a conversation
"""
def generate_message(enrichment: dict, linkedin: dict) -> str:
prompt = PROMPT_TEMPLATE.format(
name=enrichment["full_name"],
title=enrichment["title"],
company=enrichment["company"],
recent_post=linkedin.get("recent_posts", [])[0].get("text", "N/A"),
background=linkedin.get("headline", ""),
)
# Call your LLM of choice here
return call_llm(prompt)
Step 5: Send via LinkedIn
Use the LinkedIn messages endpoint to send. The API automatically routes through the team member with the closest connection to the prospect.
# send via closest team connection
def send_linkedin_message(linkedin_id: str, message: str) -> dict:
response = requests.post(
f"{BASE_URL}/linkedin/messages",
headers={"Authorization": f"Bearer {API_KEY}"},
json={
"recipient_linkedin_id": linkedin_id,
"text": message,
},
)
response.raise_for_status()
return response.json()
Complete Agent Code
Here’s the full script tying everything together. Drop in your API key and target list, and let it run.
# prospecting_agent.py
import requests
import time
API_KEY = "abm_live_..."
BASE = "https://api.abm.dev/v1"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
targets = ["acme.com", "globex.io", "initech.co"]
titles = ["VP of Sales", "CRO", "Head of Revenue"]
def find_contacts(domain, titles):
r = requests.post(f"{BASE}/people-finder", headers=HEADERS,
json={"domain": domain, "titles": titles})
return r.json()["contacts"]
def enrich(email, domain):
r = requests.post(f"{BASE}/enrichments", headers=HEADERS,
json={"email": email, "company_domain": domain})
return r.json()
def research(linkedin_id):
r = requests.get(f"{BASE}/linkedin/profile/{linkedin_id}", headers=HEADERS)
return r.json()
def send_message(linkedin_id, text):
r = requests.post(f"{BASE}/linkedin/messages", headers=HEADERS,
json={"recipient_linkedin_id": linkedin_id, "text": text})
return r.json()
# --- Main loop ---
for domain in targets:
contacts = find_contacts(domain, titles)
for contact in contacts:
enrichment = enrich(contact["email"], domain)
profile = research(enrichment["linkedin_id"])
message = generate_message(enrichment, profile)
send_message(enrichment["linkedin_id"], message)
print(f"Sent to {contact['email']}")
time.sleep(2) # respect rate limits
Ready to build your own prospecting agent? Grab an API key and start with the enrichment endpoint.