An intelligent automation tool designed to discover, extract, and compile business leads from online directories and map services using natural language prompts.
The current project uses a Streamlit UI frontend in backend/app/ui/streamlit_app.py and an agent architecture built around backend/app/agent/runner.py, tool_registry.py, and browser scraping services.
The agent uses a ReAct-style loop to alternate between reasoning and tool execution. It asks the LLM to return only structured JSON actions, either calling a tool or returning a final answer. The loop continues until the task is complete.
Implemented in:
backend/app/agent/runner.py— core agent loop and tool orchestrationbackend/app/agent/prompt.py— system prompt and agent instruction templatesbackend/app/agent/tool_registry.py— tool registration, tool schemas, and handler lookupbackend/app/agent/llm.py— wrapper for the LLM interfacebackend/app/agent/real_llm.py— actuallangchain_groqLLM implementation
Tool implementations currently include:
backend/app/services/parser.py— prompt parsingbackend/app/services/browser.py— Google Maps scraping logicbackend/app/services/exporter.py— Excel export logicbackend/app/services/email_scraper.py— email scraping helper
The Leads Generation Agent automates the entire process of discovering and compiling business leads from a simple natural-language prompt.
- The user enters a conversational request like "coffee shops in America".
- The prompt parser extracts the business category and location.
- The agent uses browser automation to search Google Maps.
- It scrapes listings and extracts business details:
- Business Name
- Website
- Phone Number
- Address
- If a value is missing, the agent continues without failing.
- Collected leads are saved to an Excel file.
- The output path is configured using
OUTPUT_DIR. - The UI displays progress and provides a download link once complete.
- Python 3.8+
- pip
cd /home/user/Desktop/python/aiseason/session_4/LeadsGenerationAgent/backendpip install -r requirements.txtCreate a .env file in backend/ with values for the Groq API and output settings.
Example .env:
GROQ_API_KEY=your_groq_api_key_here
GROQ_MODEL=groq-1-512k
HEADLESS=True
OUTPUT_DIR=./output
DEBUG=False
HOST=127.0.0.1
PORT=8501Important variables:
| Variable | Description | Example |
|---|---|---|
GROQ_API_KEY |
Your Groq API key for the LLM | sk-... |
GROQ_MODEL |
Groq model name | groq-1-512k |
HEADLESS |
Run browser in headless mode (True/False) |
True |
OUTPUT_DIR |
Directory to save Excel files | ./output |
From the backend/ folder, start the Streamlit app:
python -m app.mainThis launches the Streamlit interface in your browser.
Enter a natural language query in the UI, such as:
pizza restaurants in Los Angelessoftware development companies in Londondentists near San Franciscohotels in Tokyo
The agent will parse the prompt, scrape leads, and export the results to Excel.
Excel files are saved to the directory specified by OUTPUT_DIR, typically:
backend/output/Files are named using the business category:
leads_[business_type].xlsxExamples:
leads_coffee_shops.xlsxleads_pizza_restaurants.xlsxleads_software_companies.xlsx
ls -la output/backend/
├── app/
│ ├── agent/
│ │ ├── llm.py
│ │ ├── memory.py
│ │ ├── prompt.py
│ │ ├── real_llm.py
│ │ ├── runner.py
│ │ └── tool_registry.py
│ ├── services/
│ │ ├── browser.py
│ │ ├── email_scraper.py
│ │ ├── exporter.py
│ │ ├── parser.py
│ │ ├── scraper.py
│ │ └── selectors.py
│ ├── ui/
│ │ ├── components.py
│ │ └── streamlit_app.py
│ ├── config.py
│ ├── main.py
│ └── models.py
├── output/
├── requirements.txt
└── .env
Make sure GROQ_API_KEY is set in backend/.env:
cat .envEnsure OUTPUT_DIR is configured and writable:
mkdir -p output/Install Playwright and the browser runtime:
pip install playwright
playwright install chromiumKey dependencies in requirements.txt:
langchainlangchain-groqlangchain-corestreamlitplaywrightopenpyxlpython-dotenv
This project is provided as-is for educational purposes.