AI
LangChain Lead Gen
Turn any Google Maps search into a scored, enriched lead list — powered by a LangGraph agent.
A demonstration of Nimble Web Search Agents as LangChain tools inside a LangGraph ReAct agent. The agent receives a search query, calls Nimble’s Google Maps agent to find matching businesses, then visits every business website via Nimble Extract to pull contact emails, opening hours, and a short description. A scoring chain ranks every lead 1–10 on outreach potential. The full dataset is queryable via natural language chat.
Inputs
Outputs
What you get after a full run.
- Enriched lead list with email, opening hours, and description per business
- Score 1–10 and scoring reason per lead
- Full Google Maps attributes per business: categories, amenities, atmosphere tags, accessibility, dining options, and more
- Natural language chat over the complete dataset
- CSV export of the full enriched and scored list
How it works
A 6-phase pipeline. Read the blog here for a deeper explanation.
- Search The agent calls search_google_maps with the user’s query. Nimble’s Google Maps Web Search Agent returns up to 20 structured business records including website URLs. The agent receives the full business record including nested arrays for categories, amenities, atmosphere tags, accessibility, and dining options — not just the flat fields. These rich attributes are preserved through to the final dataset and are available in the chat tab.
- Filter The agent filters results to businesses with a website URL and sorts by rating. No application code sets this logic — it is defined in the system prompt and executed by the agent. Businesses without a website URL are dropped because there is nothing to extract in the next step. The sort-by-rating prioritization is a heuristic that tends to put established, well-documented businesses first, making the extraction step more reliable.
- Extract For each qualifying business, the agent calls nimble_extract with the website URL. Nimble renders the page and returns markdown. The agent makes one tool call per site, sequencing them across the ReAct loop. Nimble Extract handles JavaScript rendering, redirects, and bot detection automatically — the agent sees clean markdown regardless of how the underlying site is built.
- Enrich From each page’s markdown, the agent pulls the contact email, opening hours, and a one-to-two sentence description of the business. Fields not found on the page are set to null. The agent reads the raw markdown directly — there is no regex or DOM parsing layer. Fields that are genuinely absent from the page come back as null rather than a hallucinated value, because the prompt explicitly instructs the agent to return null when the field is not present.
- Score A separate LangChain chain — not an agent — scores all enriched leads in a single Claude call. Each lead gets a score from 1 to 10 and a one-sentence reason based on data completeness, ratings, and engagement signals. Using a chain instead of an agent for scoring is intentional: scoring is a deterministic transformation over a fixed dataset, not a multi-step reasoning task, so the agent loop’s overhead adds nothing. All leads are scored in one call to avoid per-lead latency and to let Claude calibrate scores relative to each other.
- Chat The full enriched dataset — including raw Google Maps attributes and extracted fields — is available as chat context. Ask any natural language question about the results. The dataset is injected into the chat prompt as a JSON block, so Claude has direct access to every field without needing a tool call. Questions like “which businesses have the highest ratings but lowest outreach scores?” or “show me only businesses in a specific zip code” are answered from the in-memory context.
Stack
Nimble primitives plus the full runtime stack.
APIS & AGENTS
What it does
- google_maps_search Returns structured business listings from Google Maps for any search query — name, address, rating, phone, website URL, and rich attribute arrays.
- Extract Renders any URL with a full browser and returns clean markdown — handles JavaScript, redirects, and anti-bot measures automatically.
RUNTIME STACK
Role
- langgraph-create_react_agent ReAct orchestration loop — the agent decides which tools to call, in what order, and when it has enough data to produce the final output.
- claude-sonnet-4-6 Anthropic Claude API — drives the ReAct loop, extracts structured fields from raw markdown, scores all leads in a single chain call, and answers chat questions over the full dataset.
- langchain-anthropic LangChain integration layer for Claude — ChatAnthropic model binding and ChatPromptTemplate for the scoring chain.
- langchain-core tool decorator — wraps Nimble API calls as LangChain-compatible tools the agent can discover and invoke.
- streamlit Live UI — card grid updates in real time as each extraction completes, followed by a results table, CSV export, and chat tab.
- python 3.9+ Agent logic, tool definitions, scoring chain, and streaming handler.
- MIT license Fork, modify, ship — no restrictions.

Reach out if you have any questions.
Talk to an Expert