Education

AI Agents for Beginners – From Architecture to a Working Sales & Lead Enrichment Agent

by freeCodeCamp.org

Share:

Export

⬇ Markdown PDF 🔒

📚 Main topics

  • What AI agents doAn AI agent combines an LLM with a goal, tools, and the autonomy to use them in a loop. Unlike a basic chatbot, it can gather information, take actions, and work toward completing a task. 2:36
  • Agents and agentic AIAn AI agent is a focused autonomous worker; agentic AI describes a broader system that may coordinate multiple specialized agents. 4:41
  • Core architectureAgents are built around a model, clear instructions, memory, and tools. Together, these components let an agent interpret a goal, use tools, keep track of results, and produce an output. 7:47
  • Live web dataTraining data can be stale, while basic HTTP requests may fail on JavaScript-rendered or protected websites and return messy HTML. The course uses Oxylabs Web API for live search and scraping into structured results or clean Markdown. 12:20
  • Building the lead-enrichment workflowThe n8n workflow starts from a new Google Sheets row, researches the company, scores its fit, generates talking points and a personalized email, then writes structured results back to the sheet. 21:15
  • Python implementationThe Python version uses the same tools, prompts, and agent loop as the visual workflow, showing how the underlying architecture maps to code. 33:44

✨ Key takeaways

  • A practical agent loopThe model decides what information it needs, calls a tool, observes the result, and repeats until it can return a final answer. 10:49
  • Instructions matterClear system instructions should define the agent’s role, product, ideal customer profile, research process, scoring rubric, and output format. 9:18
  • Use structured outputsA JSON schema helps ensure downstream steps receive the fields they expect, such as lead score, qualification tier, research summary, and outreach email. 31:07
  • Test whether the agent can say noThe example workflow gives an irrelevant local bakery a low fit score and a disqualification, rather than treating every lead as a good prospect. 38:26

🧠 Lessons learned

  • Limit agent iterationsSet a maximum number of steps so the agent cannot loop indefinitely or waste tokens. 39:29
  • Manage the amount of scraped contentClean Markdown, targeted extraction, and limits on returned text can reduce token use and latency. 34:15
  • Keep people in the loopDraft emails for review instead of automatically sending external communications, especially before validating the workflow. 40:01
  • Plan for errorsEnable retries for temporary website timeouts and log failures so the workflow is more reliable in production. 40:32

✨ Conclusion/next steps

  • Build and validateThe course demonstrates a working sales and lead-enrichment agent in both n8n and Python, using live web search and scraping to research and qualify leads. 42:39
  • Explore agent standardsMCP can provide agents with discoverable tools, while agent skills can guide how agents use those tools. 41:03

Transcript excerpt

0:00 Hey everyone. In this video, I will explain what an AI agent is and how to build one that actually does useful work in the real world. I'm Bo Carnes with freecodecamp.org. In this course, we're going to go from zero to a fully working real-world AI agent. We'll start with the fundamentals and architecture so you genuinely understand how agents think, loop, and use tools under the hood. And then we're going to build a sales

0:30 and lead enrichment AI agent step by step. Here's what our agent is going to do by the end of this video. Whenever a new company comes in, like through a form or a Google sheet, our agent is automatically going to one, search the live web for what that company builds, who they serve, and any recent news or product launches. Two, scrape their actual website pages into clean, structured text so it's not guessing from outdated training data.

1:01 Three, score the lead against our ideal customer profile. It's going to summarize concrete talking points for a sales call and draft a genuinely personalized outreach email. We're going to build this visually in n8n so you can follow along even if you're brand new to AI workflows. And I'll also walk you through the Python code that implements the exact same agent loop so you can see how the visual workflow maps directly to real code.

🔒 The full, searchable transcript is available with Pro.

🔒 Unlock Premium Features

This is a premium feature. Upgrade to unlock unlimited Q&A, transcripts, mindmaps, and translations.

Questions & Answers

Common questions about this video

What is an AI agent, and how does it differ from a standard chatbot?

An AI agent is an LLM given a goal, tools, and the autonomy to decide which tools to use in a loop until the goal is complete. Unlike a standard chatbot that responds in one turn, an agent can reason, call tools, observe the results, and iterate toward its goal. 2:36

What are the four core building blocks of an AI agent?

The four building blocks are the model, instructions, memory, and tools. The model reasons, instructions define the job and rules, memory keeps track of information, and tools let the agent interact with external systems. 8:18

Why does the sales and lead enrichment agent use live web search and scraping?

An LLM’s training data can be out of date, while basic HTTP requests may fail to render JavaScript-heavy sites, get blocked, or return messy HTML. A web data API can provide current search results and clean, readable page content for the agent. 12:20

What does the sales and lead enrichment workflow do?

When a new company is added to a Google Sheet, the agent searches the web, scrapes relevant pages, evaluates the lead against an ideal customer profile, and produces structured results such as a score, talking points, and a personalized outreach email. It then writes those results back to the sheet. 21:15

How does the agent decide what to search for and which pages to scrape?

The search query and scrape URL are defined by the agent, allowing the model to choose queries and relevant pages at runtime. The workflow uses search for discovery and scraping to read selected pages as markdown. 28:02

What reliability practices does the video recommend for production agents?

Cap the maximum number of iterations, enforce structured outputs such as a JSON schema, control token size by limiting or structuring scraped content, keep a human in the loop for external actions like sending emails, and log and handle errors with retries. 39:29

What are MCP and agent skills, and how are they different?

Model Context Protocol (MCP) gives an agent access to tools through a standardized connection, while agent skills provide instruction files that guide the agent on how to use those tools. 41:03

🔒 Unlock Premium Features

Access to Chat is a premium feature. Upgrade now to unlock unlimited studying tools.

🔒 Unlock Premium Features

Access to Mindmap is a premium feature. Upgrade now to unlock unlimited studying tools.

🔒 Unlock Premium Features

Access to Flashcards is a premium feature. Upgrade now to unlock unlimited studying tools.

Get unlimited summaries, Q&A, transcripts and more with Pro

Upgrade to Pro

Suggestions

🔒 Unlock Premium Features

Access to AI Suggestions is a premium feature. Upgrade now to unlock unlimited studying tools.