MODULE 02 · COURSE 01: YOUR FIRST AI AGENT
Module 2: How It Actually Works
You don't need to understand this deeply to use OpenClaw. But most people find that once they see the picture, everything else makes more sense. So here it is.
The pieces
There are three main things at play:
1. Your messaging app (the front door)
WhatsApp, Telegram, Discord, iMessage — whichever one you want to use. This is just how you talk to your agent. Nothing special happens here on your end.2. The Gateway (the switchboard)
This is the OpenClaw software running on a computer somewhere. It's always-on (or should be), listening for messages from your chat app. When you send something, the Gateway catches it.The Gateway also handles:
- Who's allowed to talk to your agent (security)
- Which AI model to use
- Memory between conversations
- Scheduled tasks (heartbeats, crons)
- Multiple agents if you have more than one
3. The AI agent (the brain)
This is Claude, GPT-4, or another model you've configured. The Gateway hands your message to the agent, the agent thinks about it and responds, and the Gateway sends that response back to your chat.The agent also has access to tools — things like reading files, browsing the web, running code, sending messages, taking notes, and more. When you ask your agent to do something complex, it's using these tools behind the scenes.
Where does the Gateway run?
Anywhere with Node.js and internet access. Common setups:
Your laptop — works, but your agent goes offline when you close the lid. Fine for testing and getting started. A cheap cloud server — Hetzner starts at ~$4/month. Fly.io has a free tier. This is what most people move to when they want 24/7 uptime. A home server or Raspberry Pi — totally works if you've got one running.For this course, we'll start on your local machine to get everything working, then talk about moving to a server.
What about the AI API key?
OpenClaw doesn't include the AI — it connects to one. You need an API key from a provider:
- Anthropic (Claude) — recommended. Claude is excellent at following instructions and staying in character.
- OpenAI (GPT-4, GPT-4o)
- Others — Google Gemini, local models, and more are supported
Jeremy's setup uses Claude for most agents because of how well it handles complex instructions and long-term context. That's what this course assumes, but the setup works the same regardless of which provider you pick.
The flow, step by step
Here's exactly what happens when you text your agent:
You → [WhatsApp/Telegram/Discord] → Gateway → AI Model → Gateway → [WhatsApp/Telegram/Discord] → You
- You send: "What do I have going on today?"
- Your messaging app delivers it to the Gateway (via webhook or polling)
- The Gateway builds a prompt that includes: your message, the agent's personality (SOUL.md), memory from past conversations, and available tools
- That gets sent to the AI API
- The AI responds — maybe it just answers, maybe it first uses a tool to check your calendar
- The response comes back to the Gateway
- The Gateway forwards it to your messaging app
- You read it
Memory — how does it actually remember things?
OpenClaw uses a file called MEMORY.md (and often daily notes in a memory/ folder) to store what the agent has learned about you. Every session, the agent can read this file and write updates to it.
This isn't magic — it's literally a text file on the computer where your Gateway runs. You can read it, edit it, delete things you don't want it to remember. Full transparency, full control.
What's a SOUL.md?
This is the file that makes your agent yours. It's a plain text file (markdown format) that tells the agent:
- What its name is
- What its personality is like
- What it's supposed to do
- What it should never do
- How it should talk to you
We'll build one together in Module 7.