OpenClaw Working Principle
OpenClaw Working Principle
OpenClaw is not an ordinary chatbot, but a personal secretary living on your computer. It can receive instructions through chat applications like WeChat, WhatsApp, and Telegram to help you send emails, check your calendar, open a browser, run commands, or even do things automatically 24/7!

Core Concepts

| Concepts | Analogy | Function |
|---|---|---|
| Gateway | Building front desk reception | Receives all external messages and distributes them to the correct workspace |
| Workspace | Your private office | Handles specific tasks, manages conversation history and skills |
| LLM | AI advisor brain | Understands your intent and generates replies |
| Skills | Tools in the toolbox | Executing specific functions (checking weather, writing code, managing schedules, etc.) |
| Channels | Communication devices | Connecting different messaging platforms |
What is OpenClaw?
OpenClaw is aA completely open-source AI assistant that runs on your computer(Previously called Clawdbot, later renamed).
It doesn't just chat like ChatGPT; it actually takes action:
- If you say "Check tomorrow's flights for me" in WhatsApp, it can automatically open a browser, log into the airline's website, and take a screenshot for you.
- It supports hundreds of Skills, and the community is constantly adding more.
- It has long-term memory (remembers what you like) and can even generate new Skills on its own.
- Most importantly:All data stays on your computer; it is not uploaded to the cloud, ensuring privacy and security..
Core idea:Connecting the AI large model (brain) + local tools (hands and feet) + chat software (mouth and ears), allowing the AI to truly become your computer butler.
Overall architecture: Gateway is the brain's command center
The most core part of OpenClaw is calledGateway. It is like the main control panel in your home, with everything revolving around it.
Simple explanation of each part:
- Channel Bridge: Responsible for "handshaking" with chat applications like WhatsApp and Telegram. For example, connecting to WhatsApp using the Baileys library.
- Gateway: The single running process (occupies one port, default 18789), acting like a central switchboard operator to forward messages to the AI.
- AI Brain: The actual thinking is done by an external large model (you provide the API Key); the Gateway is only responsible for "calling it to work."
- Tools & SkillsAI's hands and feet, such as opening a browser, reading and writing files, and sending emails.
- Memory systemLike a notebook, the AI won't forget what you said last time.
How does a message turn into an action?
We use a real example: "In WhatsApp, say: Help me summarize today's emails and send them to me."
The flowchart is as follows:
Detailed breakdown:
- Receive instructionYou send a message -> the chat software's Bridge pushes the message to the Gateway.
- Retrieve memoryThe Gateway opens your "profile" (Session + Memory), knowing you are an old user and what tone you liked last time.
- AI thinkingPackage the message + memory and send it to the AI brain. The AI acts like a smart secretary: "Hmm, I need to read the email first, then summarize."
- Call toolThe AI says "I need to use the Gmail skill." The Gateway executes it in a secure sandbox (to prevent the AI from arbitrarily modifying files).
- Execution + feedbackTools provide the results to the AI, and the AI writes the summary.
- Reply to the userGateway sends the summary back to WhatsApp. You receive it!
Overall architecture
Three-tier architecture design
OpenClaw adopts a classic three-tier architecture, so let's understand layer by layer from outside to inside:
Why this design?
Analogy: Imagine a large company
- Outer layer (User Interface)= Customers can contact the company through various channels such as phone, email, WeChat, etc.
- Middle layer (Gateway)= Front desk reception, uniformly receiving all customers, and then assigning them to the appropriate department
- Inner layer (Workspace)= Different business departments, each responsible for different tasks
- Bottom layer (Capability Layer)Company resources (expert consultants, tools and equipment, etc.)
Detailed explanation of core components
Gateway: Unified portal
What is Gateway?
Gateway is the gateway of OpenClaw; all external messages must pass through here first.
Gateway's three main responsibilities:
1. Authentication
Ensure that only authorized platforms can connect
2. Routing
Sending messages to the correct workspace
3. Logging
Recording all interactions for debugging and auditing
Command to start Gateway:
Original prompt (Chinese, left untranslated)
# 启动网关,监听 18789 端口
openclaw gateway --port 18789 --verbose
Workspace: Your private office
What is a Workspace?
A Workspace is where tasks are actually processed. You can have multiple workspaces, each responsible for different things.
A typical Workspace configuration example:
Original prompt (Chinese, left untranslated)
# workspace-personal.yaml
name: "个人助理"
llm:
provider: "anthropic" # 使用 Claude
model: "claude-sonnet-4"
apiKey: "sk-ant-xxx"
skills:
- weather # 查天气
- calendar # 管理日程
- email # 处理邮件
- web-search # 网页搜索
settings:
language: "zh-CN"
temperature: 0.7
max_tokens: 4000
Multi-workspace use cases:
LLM: The brain of AI
What is an LLM?
LLM (Large Language Model) is the intelligent brain of OpenClaw, responsible for understanding your intent and generating responses.
LLMs supported by OpenClaw:
| Provider | Model examples | Features | Applicable Scenarios |
|---|---|---|---|
| Anthropic | Claude Sonnet 4 | Balanced, safe, good for multiple languages | Daily conversation, writing |
| OpenAI | GPT-4 | Professional, broad knowledge | Professional tasks, analysis |
| DeepSeek | DeepSeek-V3 | Strong coding ability, inexpensive | Programming assistance |
| Local deployment | Ollama | Fully private and free | Privacy-sensitive scenarios |
Channels: Connecting to the outside world
What are Channels?
Channels are "adapters" that connect to various messaging platforms.
The job of each Channel:
- Receiving messages: Obtaining user messages from the platform
- Format conversion: Unify to OpenClaw internal format
- Send reply: Send OpenClaw's reply back to the platform
Example: Telegram Channel workflow
Message flow process
Now let's look at how a complete message flows in OpenClaw:
Complete message flow chart
Detailed step analysis
Steps 1-3: Message reception and standardization
After the user sends a message in Telegram, the Telegram Channel converts it to OpenClaw's standard format:
Original prompt (Chinese, left untranslated)
{
"platform": "telegram",
"channel_id": "telegram_123",
"user": {
"id": "user_456",
"name": "Alice"
},
"message": {
"type": "text",
"content": "上海明天天气?",
"timestamp": "2024-03-09T10:30:00Z"
}
}
Steps 4-5: Authentication and routing
The Gateway checks this message:
- Is the source authorized?
- Which Workspace should it be routed to?
- Does the user have permission?
Steps 6-8: AI Understanding and Decision Making
Workspace prepares the complete context to send to the LLM:
Original prompt (Chinese, left untranslated)
[系统提示]
You are a personal assistant, and you can use the following skills:
- weather: 查询天气
- calendar: 管理日程
- ...
[对话历史]
用户: 你好
助理: 你好!有什么可以帮你的?
[当前消息]
用户: 上海明天天气?
Steps 9-12: Skill Execution
LLM decides to call the weather skill, Workspace executes and retrieves the result:
Original prompt (Chinese, left untranslated)
{
"location": "上海",
"date": "2024-03-10",
"weather": "晴转多云",
"temperature": "18-26°C",
"humidity": "60%",
"wind": "东风 3-4级"
}
Steps 13-17: Generating and Returning the Response
LLM generates a natural language response based on the weather data and returns it to the user through the original path.
Skill System
What are Skills?
Skills are the "capability modules" for OpenClaw to perform specific tasks. If OpenClaw were a person, skills would be the various abilities that person has learned.
Skill structure
Each skill includes:
Example: Definition of a weather skill
Skill invocation process
Skill security mechanisms
OpenClaw has strict security controls for skills:
Permission types:
| Permissions | Description | Example |
|---|---|---|
network |
Network Access | Check weather, search web pages |
filesystem |
File System | Read and write files |
email |
Email Access | Send/receive emails |
calendar |
Calendar access | Manage schedules |
system |
System operations | Execute commands |
Complete workflow
Let's connect all concepts through a real-world scenario:
Scenario: Scheduled daily weather report sending
Requirements: Receive today's weather and schedule reminders via Telegram every morning at 8 AM
Configuration code
Original prompt (Chinese, left untranslated)
# workspace-daily-report.yaml
name: "每日报告助理"
# Scheduled task
cron_jobs:
- name: "早间报告"
schedule: "0 8 * * *" # 每天早上8点
action:
type: "send_message"
channel: "telegram"
template: |
Please generate today's report:
1. 查询我所在城市的天气
2. 列出今天的所有日程
3. 以友好的方式呈现
# Available skills
skills:
- weather
- calendar
# LLM 配置
llm:
provider: "anthropic"
model: "claude-sonnet-4"
Messages received by the user
Original prompt (Chinese, left untranslated)
早安!今日简报
天气情况
上海今天多云,气温 15-23°C
建议穿着:薄外套
降雨概率:10%
今日日程
- 09:00 - 10:00 团队晨会
- 14:00 - 15:30 客户演示
- 16:00 - 17:00 代码评审
温馨提示
今天有 3 个会议,建议提前准备演示材料。
Data flow and state management
How is the data stored?
Data types and storage methods:
| Data type | Storage method | Retention period | Example |
|---|---|---|---|
| Current session state | Memory | Until session ends | Ongoing conversation context |
| Conversation history | Local database | Configurable (e.g., 30 days) | Past chat history |
| User settings | Configuration file | Permanent | API key, preferences |
| Skill data | Skill self-management | Depends on the skill | Schedule, email drafts |
| System logs | Log files | Configurable | Error, debugging information |
Scalability and plugin ecosystem
How to add new features?
OpenClaw's design allows for easy extension: