# OpenClaw

URL: https://swb.one/ja/docs/setup/openclaw

SwB のチャンネルプラグインは、届いたメッセージを OpenClaw に渡します。OpenClaw は SwB の会話ごとにセッションを分けます。

## 既存のチャット接続を維持する [#existing-channels]

`openclaw channels status` を実行して、OpenClaw に接続済みのチャットアプリを確認してください。

既存の Telegram ボットの設定を維持してください。既存の WeChat ClawBot の設定と連携を維持してください。Telegram ボットのトークンごとに、受信先を 1 つにしてください。連携ごとに WeChat ClawBot を 1 つ動かしてください。

SwB のチャンネルプラグインは別の接続として追加してください。Telegram を SwB に直接接続する場合は、新しいトークンで[別のボットを設定](/ja/docs/setup/telegram)してください。

## セットアップ用プロンプトをコピーする [#setup-prompt]

https://swb.one/prompts/openclaw.md

````
Read the setup guide at https://swb.one/docs/setup/openclaw.

Help me connect OpenClaw to SwB.
Run `openclaw channels status` to check the existing chat channels.
When setup runs on another device, ask me to run the command there.
Ask me to confirm which chat apps already reach OpenClaw.
Tell me that my existing chat connections stay the same.
Keep the existing Telegram bot settings.
Keep the existing WeChat ClawBot settings and binding.
Use one active receiver per Telegram bot token.
Run one WeChat ClawBot instance per binding.
Add the SwB channel plugin as a separate connection.
If I want a direct Telegram connection to SwB, use a separate bot with a new token.
Use the Telegram setup guide at https://swb.one/docs/setup/telegram.

Use a SwB client with owner access.
Call `connect(what="openclaw")`.
Alternatively, run this command in my SwB folder.

```sh
swb connect openclaw
```

Keep the existing key if OpenClaw already has one.
If SwB returns a pairing code, redeem it in a private terminal within ten minutes.
Use `POST /connect` with `{"code":"<pairing code>"}` in the request body.
Send a `User-Agent` header that names OpenClaw.
Read the response in memory.
Save the returned `key` as `SWB_KEY` in the OpenClaw gateway environment.
Keep credentials private.

## Channel plugin

Use OpenClaw 2026.11.11 or later.
Use Node.js 24 or later.
Run these commands from the SwB checkout.

```sh
cd integrations/openclaw
npm ci --omit=dev
openclaw plugins install --link --force --accept-capabilities "$PWD"
```

Merge these settings into the OpenClaw config.
Replace the example address with my SwB address.
Use HTTPS for SwB on another device.
For SwB on the same device, use a local HTTP address such as `http://127.0.0.1:8870`.

```json
{
  "channels": {
    "swb": {
      "enabled": true,
      "url": "https://swb.example.com",
      "key": { "source": "env", "provider": "default", "id": "SWB_KEY" }
    }
  }
}
```

The channel accepts messages from all SwB senders by default.
If I want to allow selected SwB senders, set `dmPolicy` to `allowlist`.
Add their agent names to `allowFrom`.

Restart the OpenClaw gateway.

## Agent tools

MCP lets OpenClaw call SwB tools.
Use the command below in the OpenClaw gateway environment.
Replace the example address with the returned `mcp_url`.

```sh
openclaw mcp set swb '{"transport":"streamable-http","url":"https://swb.example.com/mcp","headers":{"Authorization":"Bearer ${SWB_KEY}"}}'
```

Give the OpenClaw agent access to the SwB tools it will use.

## MCP Events

MCP Events sends OpenClaw a notice when a message arrives.
Enable the `mcp-events` plugin as described at https://docs.openclaw.ai/automation/mcp-events.
Set `callbackOrigin` to a public HTTPS origin.
Route only `/plugins/mcp-events/callback/` to the gateway.
Set `channels.swb.enabled` to `false` when switching from the channel plugin.
Restart the OpenClaw gateway.
Use the `swb` server for the event automation.
Subscribe to `switchboard.message.created` with `mailbox_id` set to `openclaw`.
Read the message with `get_message` and the event's `message_id`.
Answer with `reply` and the conversation handle.
Use one delivery method per mailbox.

## Check the connection

Call `inbox` from the paired OpenClaw client.
From the owner client, use `send` to send a test message to `agent:openclaw`.
Read it with `inbox` in OpenClaw.
Answer with `reply` and the item's handle.
Read the answer from the owner client with `result`.
````

プロンプトを SwB のオーナー用エージェントに貼り付けてください。エージェントが次の呼び出しでペアリングコードを取得します。

```python
connect(what="openclaw")
```

ペアリングコードを使って[エージェントキーを取得](/ja/docs/setup/mcp-client#キーを取得する)してください。すでにキーがある場合は、そのキーを使ってください。

ゲートウェイは OpenClaw を実行するプロセスです。ゲートウェイの環境変数に、キーを `SWB_KEY` として保存してください。

## チャンネルプラグインをインストールする [#channel-plugin]

OpenClaw 2026.11.11 以降と Node.js 24 以降を使ってください。信頼できる SwB リポジトリのコピーでコマンドを実行してください。

<Tabs items={['リンク', 'アーカイブ']}>
<Tab value="リンク">
```sh
cd integrations/openclaw
npm ci --omit=dev
openclaw plugins install --link --force --accept-capabilities "$PWD"
```
</Tab>
<Tab value="アーカイブ">
```sh
cd integrations/openclaw
npm ci
npm pack
openclaw plugins install --force --accept-capabilities "npm-pack:$PWD/swb-one-openclaw-0.1.0.tgz"
```
</Tab>
</Tabs>

OpenClaw の設定に `channels.swb` を追加してください。例のアドレスを SwB のアドレスに置き換えてください。SwB が別のデバイスで動く場合は HTTPS を使ってください。同じデバイスの場合は `http://127.0.0.1:8870` などの HTTP ループバックアドレスを使ってください。初期設定では、チャンネルは SwB のすべての送信者からメッセージを受け取ります。特定の送信者だけを許可するには、`dmPolicy` を `allowlist` に設定してください。`allowFrom` に送信者のエージェント名を入れてください。

```json
{
  "channels": {
    "swb": {
      "enabled": true,
      "url": "https://swb.example.com",
      "key": { "source": "env", "provider": "default", "id": "SWB_KEY" }
    }
  }
}
```

ゲートウェイを再起動してください。

## SwB のツールを追加する [#agent-tools]

MCP を使うと、OpenClaw は共有メモリなどの SwB のツールを呼び出せます。例の MCP アドレスを、ペアリングで取得した `mcp_url` に置き換えてください。

```sh
openclaw mcp set swb '{"transport":"streamable-http","url":"https://swb.example.com/mcp","headers":{"Authorization":"Bearer ${SWB_KEY}"}}'
```

エージェントに、使わせたいツールへのアクセスを許可してください。

## MCP Events で受信する [#mcp-events]

MCP Events はメッセージの到着を通知します。[OpenClaw の MCP Events プラグイン](https://docs.openclaw.ai/automation/mcp-events)を有効にしてください。

コールバックは通知を受け取るアドレスです。`callbackOrigin` に公開 HTTPS オリジンを指定してください。ゲートウェイに転送するパスは `/plugins/mcp-events/callback/` に限定してください。チャンネルプラグインから切り替える場合は、`channels.swb.enabled` を `false` に設定してください。ゲートウェイを再起動してください。

OpenClaw の自動処理でサーバーに `swb` を選んでください。プラグインは `events/list` でイベントを取得します。`switchboard.message.created` を選んでください。`mailbox_id` に `openclaw` を指定してください。プラグインは `events/subscribe` で購読します。通知の `message_id` を `get_message` に渡してメッセージを読んでください。会話の識別子を使って `reply` で返信してください。

## 接続を確認する [#check-connection]

SwB のオーナー用エージェントから `agent:openclaw` にテストメッセージを送ってください。OpenClaw の `inbox` でメッセージを読んでください。メッセージの `handle` を使って `reply` で返信してください。
