Intermediate 25 min

What You’ll Build

You’re building a support bot for SimpleSaaS—a fake subscription app. The bot can:

  1. Answer FAQs from a fixed knowledge base
  2. Check subscription status by calling a tool
  3. Escalate to human when things feel risky or unclear

This isn’t a general-purpose agent. It’s narrow, focused, and knows when to ask for help.

Why Focus on One Job?

Most tutorials show you how to build an agent that does everything. That’s dangerous. Agents with too much freedom can:

  • Make decisions you didn’t expect
  • Call tools in ways you didn’t plan
  • Fail silently when they should ask for help

We’re building something smaller and safer. It has clear boundaries and knows when to escalate.

Live Demo

Try the agent yourself. Use the chat panel below to ask questions:

SimpleSaaS Support

Online
Support agent is ready. Try asking: "What is SimpleSaaS?" or "Check my subscription"
8:15:19 AM

Example Scenarios

Here are three scenarios the agent handles:

Scenario 1: Simple FAQ

User: “What is SimpleSaaS?”

Agent: Answers directly from the knowledge base. No tools needed.

Trace shows: Single step - direct answer

Scenario 2: Check Subscription

User: “What’s my current plan?”

Agent: Calls get_subscription_status tool, then answers.

Trace shows: Two steps - tool call, then answer

Scenario 3: Billing Dispute

User: “I want a refund for last month”

Agent: Detects sensitive keyword “refund”, escalates to human.

Trace shows: Escalation step with reason

The Agent Trace

Every action the agent takes is logged. Here’s what a trace looks like:

Example Agent Trace

Step 1 thinking 10:23:15
Reasoning: User asked about subscription. Need to check their account.
Step 2 tool call 10:23:16
Tool: get_subscription_status
Arguments
{
  "user_id": "user-123"
}
Result
{
  "plan": "Pro",
  "status": "active",
  "expires": "2025-12-01"
}
Step 3 final answer 10:23:17
Reply: Your current plan is Pro, and it's active until December 1, 2025.

What You Need

Before we start coding, make sure you have:

  • Python 3.8+ or Node.js 18+
  • An API key for an LLM provider (OpenAI, Anthropic, etc.)
  • A code editor (VS Code recommended)
  • Basic familiarity with calling APIs

Don’t have an API key? Most providers offer free tiers for testing.

Tutorial Structure

This tutorial has 8 pages:

  1. Overview and Live Demo (you’re here)
  2. What Is an AI Agent? - Core concepts
  3. Designing the Support Agent - Planning
  4. Defining Tools and Prompts - Setup
  5. Building the Agent Loop - Implementation
  6. Adding Memory and Guardrails - Safety
  7. Building the Final UI - Interface
  8. Extensions and Reflection - Next steps

Each page builds on the previous one. You’ll write code, test it, and see it work.

Key Concepts You’ll Learn

By the end, you’ll understand:

  • Agent Loop: The cycle of receive → decide → act → repeat
  • Tool Calling: How agents use functions to get information
  • Memory: Short-term (conversation) and long-term (user preferences)
  • Guardrails: Rules that keep the agent safe
  • Escalation: Knowing when to ask for help

These concepts apply to any agent you build, not just support bots.

Ready to Start?

The next page explains what an AI agent actually is. We’ll contrast it with simple LLM calls and show you the basic loop structure.

Progress 13%
Page 1 of 8
Previous Next