约 30 分钟
如何安装 OpenClaw 并连接 Telegram
从零开始,到拥有一个可以在 Telegram 上给你发消息的智能助手,大约需要三十分钟。命令摘自官方文档;请对照你使用的版本进行核实。
准备事项
- 运行 macOS、Linux、WSL2 或 Windows 的电脑或 VPS
- Node 24.16+ 或 Node 26(安装程序可以安装)
- 模型的 API 密钥或订阅,或者本地模型
- Telegram 账号
步骤
- 1
选择运行位置
用自己的笔记本电脑试用就可以。要让智能体始终在线,请使用小型 VPS 或家用服务器。不要将网关端口暴露到互联网。
- 2
安装 OpenClaw
运行官方安装程序。它会检测你的操作系统,在需要时安装 Node、安装 OpenClaw 并启动初始设置。
# macOS / Linux / WSL2 curl -fsSL https://openclaw.ai/install.sh | bash # Windows (PowerShell) iwr -useb https://openclaw.ai/install.ps1 | iex
- 3
运行初始设置并安装服务
选择 Quick start 以复用检测到的 AI 访问权限,或选择 Custom setup 完成完整设置流程。然后将网关安装为后台服务,使其在重启后仍能运行。
openclaw onboard # after quick start, stop the foreground gateway (Ctrl+C) and install the service openclaw gateway install
- 4
创建 Telegram 机器人并添加它
在 Telegram 中给 @BotFather 发消息(仔细核对用户名),运行 /newbot 并复制令牌。将令牌添加到 OpenClaw,并检查频道状态。
openclaw channels add --channel telegram --token <bot-token> openclaw channels status --probe
- 5
批准你自己的账号
向你的机器人发送任意消息。对于未知发送者,机器人会发送配对码而不是回复;请在一小时内批准你自己的账号。
openclaw pairing list telegram openclaw pairing approve telegram <CODE>
- 6
加强安全防护
运行内置安全审计,并保持网关更新。2026.4.22 之前的版本存在已知的严重漏洞。
openclaw security audit openclaw update --channel stable
实用经验
- 让 gateway.bind 保持为 loopback,并通过 SSH 或 Tailscale 访问网关,切勿开放端口。
- 将 dmPolicy 保持为 pairing,这样找到你机器人的陌生人就无法使用它。
- 把第三方技能当作浏览器扩展一样对待:少安装,只从你信任的来源安装。
- 在你信任自己的配置之前,将 exec 审批设为始终询问。