Skip to main content

OpenClaw

Introduction

OpenClaw 是一款開源的個人 AI 數位助理,讓你在各種通訊平台上擁有專屬的智慧管家。無論是自動回覆訊息、整理資訊、串接工作流程,OpenClaw 都能幫你搞定。

Resources

Installation

With Docker
git clone https://github.com/openclaw/openclaw
cd openclaw
export OPENCLAW_IMAGE="ghcr.io/openclaw/openclaw:latest"
./scripts/docker/setup.sh

CLI Commands

BrowserPairing Accessrequired
    遠端存取可以使用 SSH Port Forwarding

    ~/.openclaw/openclaw.json :

      "gateway": {
        "port": 18789,
        "mode": "local",
        "bind": "lan",
        "controlUi": {
          "allowedOrigins": [
            "http://localhost:18789",
            "http://127.0.0.1:18789"
          ]
        },

    Approve the device

    docker compose run --rm openclaw-cli devices list
    docker compose run --rm openclaw-cli devices approve <request-id>

    Telegram

    Configuration

    Create a Bot from Telegram

    1. Open Telegram
    2. Chat with @BotFather 
    3. Run /newbot , follow prompts to create your bot, and save the token.
      • Bot Name: <whatever>
      • Bot Username: <unique-name and must end in 'bot'> 

    Go to OpenClaw CLI

    docker compose run --rm openclaw-cli channels add --channel telegram --token "<bot-token>"

    Go to Telegram

    1. Open you-bot
    2. Send "Hi"
    3. Getting a pairing code "XXXXX"

    Go to OpenClaw CLI

    docker compose run --rm openclaw-cli pairing list telegram
    docker compose run --rm openclaw-cli pairing approve telegram XXXXX

    Done

    Bot Commands
    • /btw : 題外話,在不打斷目前對話(主任務),可以臨時問一個小問題,其內容不會進入主對話的上下文。
    • /subagent : 子代理,在不打斷目前對話(主任務),呼叫另一個代理執行其他任務,其任務結果會納入主任務的上下文。
    • /new : 新對話,建立新的對話(任務),全新的上下文,可節省 Token 用量。

    Gateway

    Local only (default)
      遠端存取可以使用 SSH Port Forwarding

      ~/.openclaw/openclaw.json :

        "gateway": {
          "port": 18789,
          "mode": "local",
          "bind": "loopback",
          "controlUi": {
            "allowedOrigins": [
              "http://localhost:18789",
              "http://127.0.0.1:18789"
            ]
          },
          "auth": {
            "mode": "token",
            "token": "YOUR-OPENCLAW-TOKEN"
          },
      Tailscale
      1. Tailscale Console: Enable HTTPS Certicficates
      2. OpenClaw Host: Run sudo tailscale serve --bg --https=443 127.0.0.1:18789 
      3. Change ~/.openclaw/openclaw.json as follows
      4. Connect to tailnet, and then visit https://your-openclaw-device.tailnet-domain ,  such as https://dockers-vm.tailcb58c9.ts.net/ 

      ~/.openclaw/openclaw.json :

      • mode: local
      • bind: loopback
      • trustedProxies: ["127.0.0.1", "::1"]
      • allowedOrigins: https://yourdevice.tailnet-domain
        "gateway": {
          "port": 18789,
          "mode": "local",
          "bind": "loopback",
          "trustedProxies": ["127.0.0.1", "::1"],
          "controlUi": {
            "allowedOrigins": [
              "http://localhost:18789",
              "http://127.0.0.1:18789",
              "https://yourdevice.tailnet-domain"
            ]
          },
          "auth": {
            "mode": "token",
            "token": "YOUR-OPENCLAW-TOKEN"
          },