|
| 1 | +--- |
| 2 | +title: 'How to Integrate OpenClaw' |
| 3 | +sidebar_position: 8 |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +# How to Integrate OpenClaw |
| 8 | + |
| 9 | +This document is intended for OpenIMSDK users. It explains how to connect OpenIMServer through OpenClaw Gateway and verify the integration by sending the first message. |
| 10 | + |
| 11 | +## 1. Prerequisites |
| 12 | + |
| 13 | +- You have already [deployed OpenIMServer and ChatServer](../gettingStarted/dockerCompose), deployed and started OpenClaw Gateway, and can run the `openclaw` command on the machine where Gateway is running. |
| 14 | + |
| 15 | +## 2. Register an OpenClaw User |
| 16 | + |
| 17 | +### 1. Register a user |
| 18 | + |
| 19 | +Log in to the admin console. The default address is `http://server_ip:11002`, where `server_ip` is the IP address where `open-im-server` is deployed. |
| 20 | + |
| 21 | +Select User Management -> User List, then click **Create New User** on the right: |
| 22 | + |
| 23 | + |
| 24 | +Enter the account information: |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | +### Get an admin token |
| 29 | + |
| 30 | +Refer to the [Get Admin Token](../../restapi/apis/authenticationManagement/getAdminToken) document to obtain an admin token. |
| 31 | + |
| 32 | +### Get a user token |
| 33 | + |
| 34 | +After obtaining an admin token, refer to the [Get User Token](../../restapi/apis/authenticationManagement/getUserToken) document to issue a login token for the specified user. Set `userID` to the `userID` of the user you just registered, and set `platformID` to 12 (which indicates bot). |
| 35 | + |
| 36 | +## 3. Install the OpenIM Channel Plugin |
| 37 | + |
| 38 | +```bash |
| 39 | +openclaw plugins install @openim/openclaw-channel |
| 40 | +``` |
| 41 | + |
| 42 | +Plugin URL: https://www.npmjs.com/package/@openim/openclaw-channel |
| 43 | + |
| 44 | +## 4. Enable the Plugin and Configure OpenIM Channel |
| 45 | + |
| 46 | +### Method A: Interactive setup (recommended) |
| 47 | + |
| 48 | +```bash |
| 49 | +openclaw openim setup |
| 50 | +``` |
| 51 | + |
| 52 | +Follow the prompts to fill in `token`, `wsAddr`, `apiAddr`, and other information. |
| 53 | + |
| 54 | +### Method B: Edit the configuration file directly |
| 55 | + |
| 56 | +Edit: `~/.openclaw/openclaw.json` |
| 57 | + |
| 58 | +Example: |
| 59 | + |
| 60 | +```json |
| 61 | +{ |
| 62 | + "channels": { |
| 63 | + "openim": { |
| 64 | + "accounts": { |
| 65 | + "default": { |
| 66 | + "enabled": true, |
| 67 | + "token": "your_token", |
| 68 | + "wsAddr": "ws://127.0.0.1:10001", |
| 69 | + "apiAddr": "http://127.0.0.1:10002" |
| 70 | + } |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +## 5. Verification: Send the First Message |
| 78 | + |
| 79 | +In OpenIM, search for the corresponding bot account by `userID`, then send a message to verify whether it can auto-reply. |
| 80 | + |
| 81 | +If the other side successfully receives the message, OpenClaw has completed integration with OpenIM. |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | +## 6. FAQ |
| 86 | + |
| 87 | +- **OpenIM is not connected**: This is usually caused by incorrect `token`, `wsAddr`, or `apiAddr` configuration, or by network inaccessibility. First verify the configuration, then troubleshoot based on OpenClaw Gateway logs. |
0 commit comments