Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lead Marketer

An AI-powered B2B lead generation tool that discovers company employees on LinkedIn and automatically crafts personalized sales outreach messages using a large language model.

Overview

Lead Generator automates the top-of-funnel sales process by:

  1. Resolving a company's LinkedIn presence to fetch its employee roster
  2. Filtering employees by job title keywords (e.g., "Manager", "Director")
  3. Scraping each lead's public LinkedIn profile
  4. Passing the profile data to a GPT-powered LangChain agent that writes a targeted sales pitch

The built-in prompt is tuned for ERP software sales, but the pipeline is generic and can be adapted to any product vertical.

Architecture

main.py
  │
  ├── utils.py                          # LinkedIn API wrappers (RapidAPI)
  │     ├── get_company_id()            # Resolve company name → LinkedIn ID
  │     ├── get_company_employees()     # Fetch paginated employee list
  │     ├── fiter_employees()           # Filter by job title keyword
  │     └── scrape_linkedin_profile()   # Fetch individual profile data
  │
  ├── agents/
  │     └── linkedin_lookup_agent.py    # LangChain agent: name → LinkedIn URL
  │
  └── tools/
        └── search_tool.py              # Custom SerpAPI wrapper for Google search

Data Flow

Company Name + Search Term
        │
        ▼
  get_company_id()          ← RapidAPI LinkedIn API
        │
        ▼
  get_company_employees()   ← RapidAPI LinkedIn API
        │
        ▼
  fiter_employees()         ← keyword match on job title
        │
        ▼
  scrape_linkedin_profile() ← RapidAPI LinkedIn API
        │
        ▼
  LangChain + GPT-3.5       ← OpenAI API
        │
        ▼
  Personalized Sales Pitch

Tech Stack

Component Technology
Language Python 3.10+
LLM Orchestration LangChain
Language Model OpenAI GPT-3.5-turbo
LinkedIn Data RapidAPI — linkedin-api8.p.rapidapi.com
Profile URL Lookup SerpAPI (Google Search)
Environment Config python-dotenv

Prerequisites

  • Python 3.10 or higher
  • A RapidAPI account with access to the LinkedIn API (linkedin-api8)
  • An OpenAI API key
  • A SerpAPI API key (used by the LinkedIn lookup agent)

Installation

# Clone the repository
git clone <repo-url>
cd Lead_Generator

# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate        # macOS/Linux
# venv\Scripts\activate         # Windows

# Install dependencies
pip install -r requirements.txt

Configuration

Create a .env file in the project root:

RAPIDAI_API_KEY=your_rapidapi_key_here
OPENAI_API_KEY=your_openai_api_key_here
SERPAPI_API_KEY=your_serpapi_api_key_here

Security note: Never commit your .env file or hardcode API keys in source files.

Usage

from main import lead_gen

# Find all "Manager" employees at Adidas and generate sales pitches
results = lead_gen(company_name="adidas", search_term="Manager")
print(results)

Or run directly:

python main.py

LinkedIn Profile Lookup by Name

The agents/linkedin_lookup_agent.py module can resolve a person's LinkedIn username from their full name alone, using a LangChain agent backed by Google Search:

from agents.linkedin_lookup_agent import look_up

username = look_up("Jane Doe")

Project Structure

Lead_Generator/
├── main.py                         # Entry point and LLM chain orchestration
├── utils.py                        # RapidAPI LinkedIn utility functions
├── requirements.txt                # Python dependencies
├── .env                            # API keys (not committed)
├── agents/
│   ├── __init__.py
│   └── linkedin_lookup_agent.py    # LangChain agent for profile URL discovery
├── third_parties/
│   ├── __init__.py
│   └── linkedIn.py                 # Alternate LinkedIn API module
└── tools/
    ├── __init__.py
    └── search_tool.py              # Custom SerpAPI Google search wrapper

Switching LLM Models

The project uses LangChain's model-agnostic interface, so you can swap the underlying LLM without changing any pipeline logic. Only the model instantiation line needs to change.

OpenAI (default)

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(model="gpt-3.5-turbo-0125", temperature=0.5)

Other OpenAI models you can drop in:

Model Notes
gpt-3.5-turbo-0125 Default — fast and cost-effective
gpt-4o Higher quality output, better reasoning
gpt-4-turbo Stronger reasoning, larger context window

Anthropic Claude

pip install langchain-anthropic
from langchain_anthropic import ChatAnthropic

llm = ChatAnthropic(model="claude-3-5-sonnet-20241022", temperature=0.5)

Set your API key in .env:

ANTHROPIC_API_KEY=your_anthropic_api_key_here

Google Gemini

pip install langchain-google-genai
from langchain_google_genai import ChatGoogleGenerativeAI

llm = ChatGoogleGenerativeAI(model="gemini-1.5-pro", temperature=0.5)

Set your API key in .env:

GOOGLE_API_KEY=your_google_api_key_here

Ollama (local, no API key required)

Run models locally using Ollama:

pip install langchain-ollama
ollama pull llama3
from langchain_ollama import ChatOllama

llm = ChatOllama(model="llama3", temperature=0.5)

For the full list of supported providers and models, see the LangChain Chat Models documentation.


Sales Prompt

The LLM is given the following role and instructions when generating outreach:

You are a sales representative for a new ERP company. Given a person's LinkedIn profile, create:

  1. A short summary of the person
  2. A personalized sales pitch that relates the ERP product to their role and industry

The prompt template lives in main.py and can be edited to target any product, tone, or persona.

Dependencies

langchain
langchain-openai
google-search-results   # SerpAPI Python client
openai==1.37.2
python-dotenv
pandas

Known Limitations

  • The RapidAPI LinkedIn endpoints are subject to rate limits and terms of service — ensure your usage complies with LinkedIn's data policies.
  • The fiter_employees filter performs a simple substring match on job titles; complex role hierarchies may require more nuanced filtering logic.
  • The current pipeline processes one lead at a time; for bulk campaigns, consider batching API calls and adding retry logic.

License

MIT

About

AI-powered B2B lead generation tool that discovers company employees on LinkedIn and automatically crafts personalized sales outreach messages using LLM

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages