HomeBlogAboutLog in

How to Automate Lead Generation With AI Coding Tools and Open-Source Scripts

Key takeaway

Automating lead generation paid off for a nine-person agency. The team replaced a $1,800-a-month lead database with a pipeline built around an AI coding assistant and an open-source scraper. A tight filter and a manual check of 50 rows did more for reply rates than the extra software.

The brief: 1,600 raw rows and a 4% reply rate

Maya ran a nine-person agency in Manchester. Her team sold websites and local SEO to independent clinics. The old database held 2,400 contacts. The reply rate sat at 4%. One new retainer came in six months.

Volume was fine. Fit was terrible. Half the list held NHS trusts and chains. Many rows sat outside the service area. The team spent more time deleting rows than writing emails.

Maya set a smaller goal. Build a list of 150 independent physiotherapy clinics within 30 miles. Use public business data. Keep tool costs under $100 and the first run under 15 hours.

The goal: a short list a salesperson can trust, with rows that hold up on a call.

Build the filter before you automate lead generation

The first script scraped 1,600 rows in an afternoon. It was useless. The script found dentists and gyms. It even found one pet grooming salon. Maya had automated the wrong job.

She wrote four yes or no rules. A clinic had to be independent, run its own website, offer online booking and show at least 20 Google reviews. A recent review helped. A stale page hurt.

Those rules became the filter. Claude Code turned them into a short script that read the CSV and added a score to each row. Maya checked the logic by hand on 50 records. She found two bugs in 20 minutes.

The score that cut 1,600 rows to 286

The score used four signals, each worth up to 25 points. A live booking page earned 25 points. The script gave 25 for a review posted in the last 60 days. Verified phone numbers added 25. A site that loaded in under two seconds took the last 25.

Below 50 went to a discard pile. Scores from 50 to 69 got a manual check. The 70 to 84 group went to a second review. Anything at 85 or higher entered outreach. That second review held 94 records. Two became clients.

score the buying signal and the data quality. A perfect fit with no working phone number wastes a row.

Where the data came from

The candidate URLs came from public map listings and a local trade directory. A GitHub scraper handled the repeat visits. Claude Code wrote the field extraction and cleaned company names. It flagged rows with missing websites.

No personal emails were collected. The team used each clinic’s public phone number and contact form. They checked site terms and kept request volume low. A lawyer reviewed the process before the first send.

That review matters. Scraping public data still has rules. Ignore them and the list becomes a liability.

What the AI did well

Claude Code was good at boring repairs. It renamed columns, fixed broken dates, merged duplicate rows and stripped stray spaces from phone numbers. It also wrote a checker that opened each site and confirmed the booking link worked.

The first run had 312 duplicate records from one chain. The cleanup script caught 298 of them. A person fixed the rest in 12 minutes.

Where it stumbled

The scraper broke on 18% of sites that used a booking widget inside an embedded frame. Claude guessed the wrong button twice. Maya stopped trusting the output until she spot-checked 30 rows by hand.

AI code needs a test sample. Pick 200 rows and verify them before you scale. This one habit saved the campaign.

a script that runs without errors can still produce a bad list. Check the data after every run.

The outreach test

The team split 200 qualified clinics into two groups. One got a generic note about growing the clinic. The other got a line about a specific page: an expired booking link or a service page last updated two years ago.

The generic note got 3 replies. The specific note got 19. Both groups got the same offer from the same sender. The observation did the work.

Maya’s team wrote the first line by hand. Claude helped draft the second paragraph and the follow-up. That mix kept the message human and cut writing time by about 70%.

the first line must earn the second. A scraped detail is useful only when it points to a real problem.

The result after two runs

The final list held 286 clinics. The team sent 286 first touches and one follow-up. They got 34 replies. Nine calls turned into 2 retainers at $2,500 a month.

The first run cost $41 in API credits and 14 hours of work. The old database cost $1,800 a month. The process removed the research drag. Sales skill still closed the deals.

Two clients proved the filter worked. That was the point of the small first run. The agency now runs the same process for dental clinics and private surveyors.

Keep in mind: the list is a starting point. A relevant first line still decides whether anyone replies.

What Maya would change

  • Start with 200 rows and verify them by hand. Scaling a broken filter only makes a bigger mess.
  • Keep the middle scores in a separate pile. The best prospect often sits at 70. Leave room for a human look.
  • Log every failed scrape. Those failures show which data source to drop.
  • Write the first sentence before you open the automation tool. The message sets the data you need.

The one move to copy

Automate lead generation in this order. Write four yes or no rules. Pull 200 rows that match. Verify every phone number and website yourself. Then let Claude Code handle the cleanup and scoring.

If the first 200 rows produce a reply rate above 8%, scale to 1,000. If they do not, fix the filter. Do not add more rows. The fit is the asset. Row count tells you very little.