# OpenClaw Matrix bot setup for your first DM reply

Canonical: https://cwyn.com/pages/openclaw-guide-first-matrix-bot.html
Last updated: 2026-11-27T03:39:41-05:00

OpenClaw operations guide

OpenClaw Matrix bot setup needs a running Gateway, the Matrix plugin, your homeserver URL and a bot access token. Invite the bot to a private, unencrypted DM from a second account. Accept the invite as the bot, then message it from the sender account. Approve the pairing code in OpenClaw and send another message for a reply.

Last updated November 27, 2026 · Published November 19, 2026

By CWYN · Reviewed November 19, 2026 against OpenClaw 2026.11.5 · Checked against docs, not run ([Matrix setup reference](https://raw.githubusercontent.com/openclaw/openclaw/v2026.11.5/docs/channels/matrix/setup.md))

## 1. Create the bot account and save its access token

Start with a working local managed Gateway, a reachable Matrix homeserver, and two accounts you control. Use one as the bot and the other as the sender. Use a private, unencrypted test DM and send only test text. For an encrypted DM, follow the separate [Matrix encryption setup](https://docs.openclaw.ai/channels/matrix/encryption) first.

Create the bot account on your homeserver. Get an access token for that account from your Matrix client or homeserver admin UI, as described in the [Matrix setup reference](https://docs.openclaw.ai/channels/matrix/setup). On a default OpenClaw installation, save it as `MATRIX_ACCESS_TOKEN` in the private [global environment file](https://docs.openclaw.ai/help/environment) at `~/.openclaw/.env`. Preserve the existing entries.

## 2. Install and configure the Matrix plugin

```
openclaw plugins install @openclaw/matrix
```

Save this example as `matrix.patch.json5` and replace the sample homeserver with the bot’s HTTPS homeserver URL. The patch references the token, requires DM pairing, and leaves group handling and automatic invite acceptance off.

Before changing the homeserver and invite settings, record how to restore your previous configuration.

```
{
  channels: {
    matrix: {
      enabled: true,
      homeserver: "https://matrix.example.org",
      accessToken: { source: "env", provider: "default", id: "MATRIX_ACCESS_TOKEN" },
      dm: { policy: "pairing" },
      groupPolicy: "disabled",
      autoJoin: "off",
    },
  },
}
```

[Restart the managed Gateway](https://docs.openclaw.ai/cli/gateway/restart-and-supervision) so it reads the token before you apply the patch. Use the [config CLI](https://docs.openclaw.ai/cli/config) to validate and apply the patch. Follow its restart hint before probing the channel.

```
openclaw gateway restart
openclaw config patch --file ./matrix.patch.json5 --dry-run
openclaw config patch --file ./matrix.patch.json5
openclaw channels status --probe
```

## 3. Accept the DM invitation as the bot

Use your sender account to open a direct conversation with the bot’s full Matrix user ID. In a client signed in as the bot, accept that invitation. Matrix [handles invites before it checks DM policy](https://docs.openclaw.ai/channels/matrix/setup#auto-join), so starting a DM alone leaves the bot outside the room when automatic joining is off.

## 4. Approve the sender

After the bot joins, send a short test message from your sender account. Follow the [Matrix pairing procedure](https://docs.openclaw.ai/channels/matrix/access-control) and approve the code from your own DM. Check the sender before approving, since the [first CLI approval](https://docs.openclaw.ai/channels/pairing) can establish the command owner.

```
openclaw pairing list matrix
openclaw pairing approve matrix <CODE>
```

## 5. Check the reply in the joined DM

Send a fresh message from your sender account in the same DM. Check for a new message from the bot account in that room. Keep the invite acceptance and the agent reply as separate checks if you need to diagnose a missing response.

If you plan to move this setup to Hermes, save the working DM as a reference, then [preview what Hermes can import from OpenClaw](https://cwyn.com/pages/hermes-guide-openclaw-migration.html).

To repeat the test in a shared Nextcloud Talk room, [allow one sender in a private Talk room](https://cwyn.com/pages/openclaw-guide-first-nextcloud-talk-bot.html) using the room token and Nextcloud user ID.

[Get your free CWYN Score](https://cwyn.com/pages/score.html)

## Related guides

- [Link Signal to OpenClaw for the first time](https://cwyn.com/pages/openclaw-guide-first-signal-link.html)
- [Set up your first OpenClaw Discord bot](https://cwyn.com/pages/openclaw-guide-first-discord-bot.html)
- [Mattermost OpenClaw bot setup for your first reply](https://cwyn.com/pages/openclaw-guide-first-mattermost-bot.html)
- [Set up your first OpenClaw Slack app in Socket Mode](https://cwyn.com/pages/openclaw-guide-first-slack-socket-mode-app.html)

## Next steps

- [All 135 OpenClaw guides](https://cwyn.com/guides/openclaw/)
- [OpenClaw setup walkthrough](https://cwyn.com/setup/openclaw/)
- [CWYN Score](https://cwyn.com/pages/score.html)
- [OpenClaw Complete Setup Pack ($14.95)](https://cwyn.com/pages/pack-openclaw-complete-setup-pack.html)

### Keep a record of the Matrix reply

The [OpenClaw Complete Setup Pack ($14.95)](https://cwyn.com/pages/pack-openclaw-complete-setup-pack.html) is an optional paid kit with a Gateway checklist for recording the account and the private reply you verified.
Kit details as of Nov 22, 2026

OpenClaw Complete Setup Pack $14.95

Start an OpenClaw workspace with editable instructions, local Gateway and tool presets, and checklists for pairing, memory, costs and rollback.
