Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/vrashmanyu605-eng/Agentic_Sales-Markerting/llms.txt

Use this file to discover all available pages before exploring further.

The lead research agent transforms a bare company name into a rich intelligence dossier. For each lead the supervisor dispatches, the agent searches for the company online, scrapes its website, locates LinkedIn profiles of decision-makers, synthesizes possible contact email addresses, and asks the LLM to analyze everything into a structured research report. The results are stored in lead_research (a JSON string) and enriched_leads (a list of contacts with email candidates).

State inputs

company_name
string
required
The name of the company to research. Set by the supervisor when it pops a lead from pending_leads.

State outputs

lead_research
string
required
A JSON string containing the LLM’s structured analysis of the company. See output schema for the full field list.
enriched_leads
object[]
required
A list of enriched contact objects built from LinkedIn profiles found for the company.

What it does

1

Search for the company

The agent calls search_company(company_name), which returns a dict containing search_results (a list of web result objects), website_url (the company’s homepage URL), and website_content (pre-scraped text from the homepage).
2

Find LinkedIn profiles

The agent calls find_linkedin_profiles(company_name) to retrieve a list of LinkedIn profile objects for people associated with the company. Each object includes a title field (name and job title) and a linkedin_url.
3

Extract the company domain

The agent parses website_url using a regex to extract the root domain (e.g., acme.com). This domain is used as the base for email generation.
4

Generate possible email addresses

For each LinkedIn profile, the agent splits the title on - to isolate the person’s name, then calls generate_possible_emails(first_name, last_name, domain). The resulting email candidates are combined with the contact’s name and LinkedIn URL into an enriched_leads entry.
5

Analyze with the LLM

The agent passes company_results, website_content, and the full enriched_leads list to the LLM. The LLM returns a structured JSON analysis of the company including pain points, lead quality, recommended contacts, and outreach strategy.

Tools used

search_company

Searches for the company by name and returns web results, the website URL, and pre-scraped homepage content.

website_scraper

Scrapes a company’s website and returns its text content for LLM analysis.

linkedin_finder

Finds LinkedIn profiles for decision-makers at the target company.

email_generator

Generates a list of likely email address formats given a first name, last name, and company domain.

Output schema

The LLM is prompted to return structured JSON only. The expected structure is:
{
  "company_summary": "Brief description of what the company does.",
  "industry": "Manufacturing",
  "likely_pain_points": [
    "Outdated ERP system",
    "No real-time inventory tracking"
  ],
  "lead_quality": "High",
  "best_decision_makers": [
    "CTO",
    "VP of Operations"
  ],
  "outreach_strategy": "Lead with operational efficiency gains from modern ERP integration.",
  "recommended_contacts": [
    {
      "name": "Jane Smith",
      "role": "CTO",
      "linkedin": "https://linkedin.com/in/jane-smith"
    }
  ]
}
lead_research is stored as a raw JSON string so that downstream agents (ICP matching, outreach generation) can pass it directly to the LLM without re-serializing.

Source code

from llm import llm

from tools.search_tool import search_company
from tools.website_scraper import scrape_website
from tools.linkedin_finder import find_linkedin_profiles
from tools.email_generator import generate_possible_emails

import json
import re


def extract_domain(url):

    if not url:
        return None

    match = re.search(
        r"https?://(?:www\.)?([^/]+)",
        url
    )

    if match:
        return match.group(1)

    return None


def lead_research_agent(state):

    company_name = state["company_name"]


    search_data = search_company(
        company_name
    )

    company_results = search_data.get("search_results", [])

    website_url = search_data.get("website_url")

    website_content = search_data.get("website_content", "")

    linkedin_profiles = find_linkedin_profiles(
        company_name
    )

    domain = extract_domain(website_url)

    leads = []

    for profile in linkedin_profiles:

        title = profile.get("title", "")

        name_parts = title.split("-")[0].strip().split()

        if len(name_parts) >= 2:

            first_name = name_parts[0]

            last_name = name_parts[-1]

            possible_emails = []

            if domain:

                possible_emails = generate_possible_emails(
                    first_name,
                    last_name,
                    domain
                )

            leads.append({

                "name": f"{first_name} {last_name}",

                "linkedin": profile.get(
                    "linkedin_url"
                ),

                "possible_emails": possible_emails
            })

    response = llm.invoke(
        f"""
        You are a Lead Research Agent.

        Analyze the company and leads.

        Company Search Results:
        {json.dumps(company_results, indent=2)}

        Website Content:
        {website_content}

        LinkedIn Profiles:
        {json.dumps(leads, indent=2)}

        Extract:
        - company_summary
        - industry
        - likely_pain_points
        - lead_quality
        - best_decision_makers
        - outreach_strategy
        - recommended_contacts

        Return structured JSON only.
        """
    )

    return {

        "lead_research": response.content,

        "enriched_leads": leads
    }

Build docs developers (and LLMs) love