Skip to main content

Building an AI startup?

You might be eligible for our Startup Program. Get fully funded access to the infrastructure you’re reading about right now (up to $20K value).
Build an AI agent that automatically researches and extracts structured data using LangGraph and Bright Data.
This cookbook gets you from zero to a working AI enrichment agent in under 10 minutes.

What You’ll Build

An AI agent that:
  1. Takes a research topic and a JSON schema as input (e.g., “B2B enterprise CTOs from New York”, “Stripe payments company”, “history of renewable energy technologies”)
  2. Searches the web using Bright Data SERP API (real search results, geo-targeting)
  3. Scrapes websites using Bright Data Web Unlocker (bypasses anti-bot measures)
  4. Uses an LLM to extract and structure the data
  5. Validates and returns structured JSON matching your schema

Prerequisites


Step 1: Install Dependencies


Step 2: Set Environment Variables

Get your API keys:

Step 3: Create the Enrichment Agent

Create a file called enrichment_agent.py and build it in three parts:

3.1: Imports and State Definition

Define the agent’s state to track the research topic, schema, messages, and extracted info.

3.2: Tool Definitions

Configure Bright Data tools for web search and content scraping.

3.3: Agent Graph and Execution

Build the LangGraph workflow that orchestrates search → scrape → extract.

Step 4: Run the Agent

Expected output:

How It Works

  1. Agent receives topic and schema, decides what to search
  2. Search uses Bright Data SERP API for real search results
  3. Scrape uses Bright Data Web Unlocker to get page content
  4. Agent analyzes content and either continues researching or submits info
  5. Output is structured JSON matching your schema

How to customize the agent

Different Extraction Schema

How to target by geography

Use OpenAI Instead of Anthropic


Next Steps

LinkedIn Scraping

Add LinkedIn profile enrichment

LangChain Integration

Full langchain-brightdata documentation

Where to find the source code

GitHub Repository

Full source code and additional examples
You now have an AI-powered data enrichment agent! Customize the schema to extract any structured data you need.