Runoob Tutorial ArchiveEnglish

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!

1 eZX31 3n KTJ MY1RB JBg

Core Concepts

openclaw how it works runoob

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:

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.

openclaw how it works runoob

Simple explanation of each part:


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:

openclaw how it works runoob 3

Detailed breakdown:

  1. Receive instructionYou send a message -> the chat software's Bridge pushes the message to the Gateway.
  2. Retrieve memoryThe Gateway opens your "profile" (Session + Memory), knowing you are an old user and what tone you liked last time.
  3. 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."
  4. 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).
  5. Execution + feedbackTools provide the results to the AI, and the AI writes the summary.
  6. 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:

openclaw how it works runoob 4

Why this design?

Analogy: Imagine a large company


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.

openclaw how it works runoob 5

Gateway's three main responsibilities:

1. Authentication

Ensure that only authorized platforms can connect

openclaw how it works runoob 6

2. Routing

Sending messages to the correct workspace

openclaw how it works runoob 7

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.

openclaw how it works runoob 8

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:

openclaw how it works runoob 9

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.

openclaw how it works runoob 1

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.

openclaw how it works runoob 11

The job of each Channel:

  1. Receiving messages: Obtaining user messages from the platform
  2. Format conversion: Unify to OpenClaw internal format
  3. Send reply: Send OpenClaw's reply back to the platform

Example: Telegram Channel workflow

openclaw how it works runoob 1


Message flow process

Now let's look at how a complete message flows in OpenClaw:

Complete message flow chart

openclaw how it works runoob 13

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:

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.

openclaw how it works runoob 14

Skill structure

Each skill includes:

openclaw how it works runoob 15

Example: Definition of a weather skill

openclaw how it works runoob 16

Skill invocation process

openclaw how it works runoob 17

Skill security mechanisms

OpenClaw has strict security controls for skills:

openclaw how it works runoob 18

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

openclaw how it works runoob 19

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?

openclaw how it works runoob

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:

openclaw how it works runoob 1

Skill installation process

openclaw how it works runoob