630 字
3 分钟
安装部署openclaw并对接QQ机器人教程
2026-01-31

openclaw(原ClawdBot)最近实在太火了,我玩了一下感觉确实很强大,本文介绍一下国内环境的安装和对接QQ机器人。

准备工作#

  • 模型API
  • 2H4G以上的硬件配置
  • linux/mac/windows都可以
  • QQ

大模型以deepseek为例,官方购买地址:https://platform.deepseek.com

部署环境以windows本地部署为例,其他系统步骤都一样,只是配置目录不一样,openclaw的默认配置路径都是在用户目录,三大系统都一样。

环境安装#

首先安装nodejs环境,需要v22.22.0以上的版本,下载地址:https://nodejs.org/zh-cn/download

其次需要Git,下载地址:https://git-scm.com/install/windows

允许执行脚本#

有时候安装环境后不会自动刷新变量,需要重启电脑,然后还需要管理员打开PowerShell执行如下命令,并选择A允许执行脚本

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

国内环境配置#

设置npm镜像

npm config set registry https://registry.npmmirror.com

设置Git全局加速(可忽略)

git config --global url."https://hub.cmoko.com/https://github.com/".insteadOf https://github.com/

移除Git全局加速的命令

git config --global --unset url."https://hub.cmoko.com/https://github.com/".insteadOf

开始部署#

  1. npm安装openclaw
npm install -g openclaw-cn@latest
  1. 初始化配置
openclaw-cn setup
  1. 打开配置文件
%USERPROFILE%\.openclaw
  1. 修改openclaw.json配置,贴入以下配置并修改对应的字段
{
  "gateway": {
    "mode": "local",
    "bind": "loopback",
    "port": 18789,
    "auth": {
      "mode": "token",
      "token": "设置一个token令牌"
    }
  },

  "agents": {
    "defaults": {
      "model": {
        "primary": "openai-compat/填写模型名称"
      },
      "elevatedDefault": "full",
      "compaction": {
        "mode": "safeguard"
      },
      "maxConcurrent": 4
    }
  },

  "models": {
    "mode": "merge",
    "providers": {
      "openai-compat": {
        "baseUrl": "https://api.example.com/v1",
        "apiKey": "填写你的模型API密钥",
        "api": "openai-completions",
        "models": [
          {
            "id": "填写模型名称",
            "name": "填写模型名称"
          }
        ]
      }
    }
  },

  "tools": {
    "exec": {
      "backgroundMs": 10000,
      "timeoutSec": 1800,
      "cleanupMs": 1800000,
      "notifyOnExit": true
    },
    "elevated": {
      "enabled": true,
      "allowFrom": {}
    },
    "allow": [
      "exec",
      "process",
      "read",
      "write",
      "edit",
      "web_search",
      "web_fetch",
      "cron"
    ]
  },

  "channels": {}
}
  1. 创建QQ机器人

浏览器访问 QQ机器人Openclaw专区,然后直接在专区内创建机器人即可。

  1. 安装机器人插件
openclaw-cn channels add
  1. 根据交互式提示选择QQ (社区版),按提示输入AppIDAppSecret即可。

  2. 启动

openclaw-cn gateway start
  1. 其他命令
# 查看状态
openclaw-cn gateway status

# 重启
openclaw-cn gateway restart

# 查看日志
openclaw-cn logs

# 停止
openclaw-cn gateway stop

# 卸载
npm uninstall -g openclaw-cn

至此,全部部署完成,可以向你的QQ机器人对话了。

常见问题#

Linux和mac系统部署都一样,只是配置文件的目录在用户目录下。

web访问需要带上token令牌:http://127.0.0.1:18789/?token=你的网关令牌

有任何问题先查看日志:openclaw-cn logs,然后问AI。

中文文档#

https://clawd.org.cn/reference/cli-cheatsheet.html

安装部署openclaw并对接QQ机器人教程
https://emohe.cn/posts/37/
作者
阿涛の小破站
发布于
2026-01-31
许可协议
CC BY-NC-SA 4.0