Skip to content

Commit 174263c

Browse files
authored
Merge pull request #291 from icey-yu/feat-openclaw
feat: add OpenClaw integration guide for OpenIM
1 parent 917cb38 commit 174263c

5 files changed

Lines changed: 97 additions & 1 deletion

File tree

56.2 KB
Loading
26.1 KB
Loading
15.6 KB
Loading

docs/guides/solution/openclaw.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
title: '如何接入OpenClaw'
3+
sidebar_position: 8
4+
5+
---
6+
7+
# 如何接入OpenClaw
8+
9+
本文面向使用 OpenIM 的用户,说明如何通过 OpenClaw Gateway 接入 OpenIM,并完成“发送第一条消息”的验证。
10+
11+
## 1. 前置条件
12+
13+
- 你已部署并启动 OpenClaw Gateway,并能在运行 Gateway 的机器上执行 `openclaw` 命令。
14+
- 你已从管理员/运维/业务系统获取以下 OpenIM 连接信息:
15+
- `userID`:OpenClaw 在 OpenIM 中使用的用户 ID
16+
- `wsAddr`:OpenIM SDK WebSocket 地址(例如:`ws://127.0.0.1:10001`
17+
- `apiAddr`:OpenIM REST API 地址(例如:`http://127.0.0.1:10002`
18+
- `platformID`:平台 ID(需与签发该 Token 时使用的 platformID 一致)
19+
20+
## 2. 准备用户 Token
21+
22+
### 1.注册用户
23+
24+
登陆管理后台,默认地址为`http://server_ip:11002``server_ip``open-im-server`部署地址ip。
25+
26+
选择 用户管理->用户列表,点击右边**创建新用户**
27+
![image-20260310115043272](./openclaw.assets/1.png)
28+
29+
输入账号相关信息:
30+
31+
![image-20260311110212683](./openclaw.assets/2.png)
32+
33+
34+
35+
36+
37+
### 获取管理员token
38+
39+
参考 [获取管理员 Token](../../restapi/apis/authenticationManagement/getAdminToken) 文档获取管理员 token。
40+
41+
### 获取用户token
42+
43+
拿到管理员 token 后,参考 [获取用户 Token](../../restapi/apis/authenticationManagement/getUserToken) 文档为指定用户签发登录 token。userID填写刚刚注册的用户的userID,platformID建议填写12。
44+
45+
## 3. 安装 OpenIM Channel 插件
46+
47+
```bash
48+
openclaw plugins install @openim/openclaw-channel
49+
```
50+
51+
插件地址:https://www.npmjs.com/package/@openim/openclaw-channel
52+
53+
## 4. 启用插件并配置 OpenIM Channel
54+
55+
### 方式 A:交互式配置(推荐)
56+
57+
```bash
58+
openclaw openim setup
59+
```
60+
61+
按提示填入 `token``wsAddr``apiAddr` 等信息。
62+
63+
### 方式 B:直接编辑配置文件
64+
65+
编辑:`~/.openclaw/openclaw.json`
66+
67+
示例:
68+
69+
```json
70+
{
71+
"channels": {
72+
"openim": {
73+
"accounts": {
74+
"default": {
75+
"enabled": true,
76+
"token": "your_token",
77+
"wsAddr": "ws://127.0.0.1:10001",
78+
"apiAddr": "http://127.0.0.1:10002"
79+
}
80+
}
81+
}
82+
}
83+
}
84+
```
85+
86+
## 5. 验证:发送第一条消息
87+
88+
使用 OpenIM 通过userID搜索对应的机器人账号,对机器人账号发送一条消息,验证是否能够自动回复。
89+
90+
若对方成功收到消息,则说明 OpenClaw 已完成 OpenIM 接入。
91+
92+
![image-20260311115813414](./openclaw.assets/3.png)
93+
94+
## 6. 常见问题
95+
96+
- **提示 OpenIM is not connected**:通常由 `token``wsAddr``apiAddr` 配置错误或网络不可达导致。请先核对配置,然后结合 OpenClaw Gateway 日志定位原因。

docs/restapi/commonFields.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title: 常用字段说明
77
| 字段名 | 类型 | 字符串长度限制 | 说明 | 取值说明 |
88
| -------------- | ------ | -------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
99
| secret | string | 32 | 服务端秘钥 | 字符串 |
10-
| platformID | int | | 用户登录时的终端类型 | 1:iOS, 2:Android, 3:Windows, 4:OSX, 5:Web, 6:MiniWeb, 7:Linux, 8:APad, 9:IPad, 10:Admin, 11:HarmonyOS|
10+
| platformID | int | | 用户登录时的终端类型 | 1:iOS, 2:Android, 3:Windows, 4:OSX, 5:Web, 6:MiniWeb, 7:Linux, 8:APad, 9:IPad, 10:Admin, 11:HarmonyOS,12:Bot|
1111
| userID | string | 64 | 用户ID,保证唯一,不能包含特殊字符 | 字符串 |
1212
| nickname | string | 255 | 昵称 | 字符串 |
1313
| faceURL | string | 255 | 头像URL | URL 链接 |

0 commit comments

Comments
 (0)