Bonus — OpenClaw Architecture

When to read this

Finish M9-A — What Are AI Agents and M9-B — Memory Planning and Execution first. This note shows a real product using markdown files as agent memory.

OpenClaw is basically an LLM wrapped around memory files + tools + integrations + an execution engine. (GitHub)

A rough architecture looks like this:

            WhatsApp / Telegram / Discord
                         ↓
                  Message Gateway
                         ↓
                 OpenClaw Runtime
                         ↓
        ┌─────────────────────────┐
        │                         │
        │    Read .md files       │
        │    Load memory          │
        │    Load skills          │
        │                         │
        └─────────────────────────┘
                         ↓
                  Build prompt
                         ↓
              Claude/GPT/Gemini API
                         ↓
                  Tool Request
                         ↓
      Terminal | Browser | APIs | Files
                         ↓
                  Execute Action
                         ↓
                Return Result

Step 1: You send a message

Example:

Telegram:
"Find today's AWS news and save it into notes.md"

Telegram doesn't talk to GPT directly.

Instead:

Telegram
    ↓
Telegram Bot API
    ↓
OpenClaw Gateway

The Gateway is basically a Node.js/TypeScript server running 24/7 on your PC or VPS. (GitHub)


Step 2: OpenClaw loads all the markdown files

This is the secret sauce.

Before sending anything to Claude/GPT, OpenClaw gathers context:

SOUL.md
MEMORY.md
PROJECT.md
TASKS.md
SKILLS/
    gmail.md
    shell.md
    browser.md

Example:

You are Sanskar's personal assistant.
Be concise.
Use Linux commands.
Never delete files.

User likes AWS.
User is preparing for SAA.
User lives in Mumbai.

Pending:
- Finish AWS prep
- Create portfolio

Tool: shell

Description:
Execute Linux commands.

Example:
ls -la
mkdir project
npm install

OpenClaw concatenates all this and creates a giant prompt. (Wikipedia)


Step 3: Send everything to Claude/GPT

The actual prompt becomes something like:

SYSTEM:
You are Sanskar's assistant.

Memory:
- User likes AWS
- User studies Data Science

Available tools:
- shell
- browser
- telegram
- gmail

User:
Find AWS news and save it.

Then OpenAI/Claude responds:

{
  "tool": "browser.search",
  "arguments": {
    "query": "AWS news today"
  }
}

This is called tool calling.


Step 4: OpenClaw executes the tool

The LLM itself cannot execute anything.

OpenClaw executes it.

Example:

if(tool=="shell"){
    exec(command)
}

if(tool=="browser"){
    playwright.run()
}

if(tool=="telegram"){
    telegram.send()
}

The AI says:

"Run this."

OpenClaw says:

"Okay, I'll actually run it."

(DigitalOcean)


How does it run CMD?

Usually through:

child_process.exec()

or

spawn()

in Node.js.

Example:

exec("mkdir aws-project")
exec("git clone repo")
exec("npm install")

That's why OpenClaw can:

because it's literally executing shell commands on your computer. (Tom's Guide)


How does it connect to Telegram?

Simple.

You create a Telegram bot:

Telegram
   ↓
BotFather
   ↓
BOT_TOKEN

OpenClaw stores:

TELEGRAM_TOKEN=xxxx

Then it listens:

telegram.onMessage((msg)=>{
   sendToOpenClaw(msg)
})

And replies:

telegram.sendMessage()

Same idea for Discord and Slack. (OpenClaw)


How does WhatsApp work?

Usually through:

Flow:

WhatsApp
    ↓
Webhook
    ↓
OpenClaw
    ↓
GPT/Claude
    ↓
Tool execution
    ↓
Reply

(OpenClaw)


How does browser automation work?

Most agents use:

Example:

AI:
"Open amazon.com"

OpenClaw:
browser.goto()

AI:
"Search for laptop"

OpenClaw:
browser.click()
browser.type()

AI:
"Add first result to cart"

OpenClaw:
browser.click()

So the AI isn't clicking.

The automation framework is clicking. (Wikipedia)


Why are the markdown files so important?

Because LLMs have no permanent memory.

Without MD files:

User:
Remember I love AWS.

Tomorrow:

AI:
Who are you?

With MD files:

memory.md

User:
Likes AWS.
Preparing for SAA.

Every request:

Read memory.md
Read skills.md
Read soul.md
Construct prompt
Call GPT

So markdown files become the AI's:

(Wikipedia)


The biggest realization for your students

OpenClaw itself is actually not very intelligent.

Claude/GPT = Brain

Markdown files = Memory

Tools = Hands

OpenClaw Runtime = Nervous System

Telegram/WhatsApp = Mouth and Ears

Put together:

Brain
+ Memory
+ Tools
+ Execution
+ Communication
=
AI Agent

That's basically how every modern AI agent framework works, including OpenClaw, LangGraph agents, Claude Code, Codex CLI, and many autonomous systems today. (GitHub)