OpenClaw WebChat 渠道
WebChat 是 OpenClaw Gateway 内置的聊天界面。它通过 WebSocket 直接连接——无需外部服务、API 密钥或第三方账号。只需启动 Gateway、配置认证,然后打开 WebChat 界面即可开始与 AI 助手对话。所有消息采用确定性路由,意味着回复始终返回到发起对话的 WebChat 会话。
WebChat 支持的功能
文本消息
支持
媒体与文件
不支持
消息反应
不支持
消息线程
不支持
语音消息
不支持
群聊
不支持
WebChat 前置条件
- 已安装并运行 OpenClaw Gateway
- 已配置 Gateway 认证(token 或密码模式)
- 现代浏览器(Control UI)或原生 macOS/iOS 客户端
- 可访问 Gateway WebSocket 端口的网络(默认:3000)
WebChat 快速设置
启动 Gateway
启动 OpenClaw Gateway。WebChat 是内置功能——无需单独安装或插件。运行 'openclaw start' 启动 Gateway 服务。
配置认证
在 openclaw.json 中通过 gateway.auth.mode 设置 'token' 或 'password' 认证方式。所有连接(包括 localhost)都必须配置认证。
打开 WebChat
通过浏览器中的 Control UI 聊天标签页访问 WebChat 界面,或启动原生 macOS/iOS 客户端。连接到 ws://localhost:3000(或你配置的主机和端口)上的 Gateway。
开始对话
发送一条测试消息以验证连接。AI 助手将通过同一个 WebChat 会话进行回复。对话历史由 Gateway 管理,在重新连接后仍然保留。
WebChat 配置示例
{
"gateway": {
"port": 3000,
"bind": "127.0.0.1",
"auth": {
"mode": "token",
"token": "YOUR_SECRET_TOKEN"
}
}
}WebChat 深入了解
架构概述
Gateway 认证
{
"gateway": {
"auth": {
"mode": "token",
"token": "a-strong-random-token-here"
}
}
}远程访问
{
"gateway": {
"remote": {
"url": "wss://your-remote-host:3000",
"token": "YOUR_REMOTE_TOKEN"
}
}
}会话管理
只读模式
原生客户端功能
消息投递
{
"channels": {
"webchat": {
"textChunkLimit": 2000,
"blockStreaming": true
}
}
}安全最佳实践
WebChat 配置参考
| Key | Type | Default | Description |
|---|---|---|---|
| gateway.port | number | 3000 | Gateway 的 WebSocket 端口号 |
| gateway.bind | string | "127.0.0.1" | Gateway 绑定的 WebSocket 连接主机地址 |
| gateway.auth.mode | string | "token" | 认证模式:'token' 为共享密钥模式,'password' 为凭据认证模式 |
| gateway.auth.token | string | "" | 用于 WebSocket 认证的共享密钥 token |
| gateway.auth.password | string | "" | 用于 WebSocket 认证的密码 |
| gateway.remote.url | string | "" | 远程 Gateway WebSocket URL(如 wss://remote-host:3000) |
| gateway.remote.token | string | "" | 连接远程 Gateway 的认证 token |
| gateway.remote.password | string | "" | 连接远程 Gateway 的认证密码 |
| session.defaultKey | string | "" | WebChat 对话的默认会话键 |
| session.storage | string | "memory" | 会话存储后端(memory、file、redis 等) |
| textChunkLimit | number | 2000 | 每个出站消息分块的最大字符数 |
| blockStreaming | boolean | false | 在生成过程中以块为单位发送回复,提供实时反馈 |
Gateway 的 WebSocket 端口号
Gateway 绑定的 WebSocket 连接主机地址
认证模式:'token' 为共享密钥模式,'password' 为凭据认证模式
用于 WebSocket 认证的共享密钥 token
用于 WebSocket 认证的密码
远程 Gateway WebSocket URL(如 wss://remote-host:3000)
连接远程 Gateway 的认证 token
连接远程 Gateway 的认证密码
WebChat 对话的默认会话键
会话存储后端(memory、file、redis 等)
每个出站消息分块的最大字符数
在生成过程中以块为单位发送回复,提供实时反馈
WebChat 常见问题
WebChat 故障排查
Gateway 未在运行,或 WebSocket 端口被防火墙拦截。
token 或密码与 Gateway 配置不匹配。
AI Agent 未配置,或 AI 服务商 API 密钥无效。
SSH 隧道未转发正确的端口,或 Gateway 未在预期地址上监听。
会话在两次连接之间过期或被清除。