#14852: feat(matrix): add multi-account support
channel: matrix
stale
size: M
Cluster:
Multi-Account Matrix Support
## Problem
The Matrix plugin currently only supports a **single account**, while other channels like WhatsApp support multiple accounts via `channels.whatsapp.accounts`.
## Current Behavior
In `extensions/matrix/src/matrix/accounts.ts`:
```typescript
export function listMatrixAccountIds(_cfg: CoreConfig): string[] {
return [DEFAULT_ACCOUNT_ID]; // Hardcoded single account
}
```
This function completely ignores the config and hardcodes a single account ID.
## Expected Behavior
Matrix should support the same multi-account pattern as WhatsApp:
```json5
channels: {
matrix: {
accounts: {
personal: {
homeserver: "https://matrix.personal.org",
userId: "@me:personal.org",
accessToken: "..."
},
work: {
homeserver: "https://matrix.company.org",
userId: "@me:company.org",
accessToken: "..."
}
}
}
}
```
## Use Case
Users who want to run multiple agents with different Matrix identities (e.g., personal vs. work) cannot do so with a single OpenClaw instance. They must run multiple OpenClaw instances as a workaround.
## Changes
- Add `accounts` map to MatrixConfig schema
- Add `MatrixAccountConfig` type for per-account settings
- Update `listMatrixAccountIds()` to read from config.accounts
- Update `resolveMatrixAccount()` to handle account-specific resolution
- Add `resolveMatrixConfigForAccount()` for account-specific config merging
- Add `loadMatrixCredentialsForAccount()` for account-specific credentials
- Add comprehensive tests for multi-account functionality
- Maintain backwards compatibility with single-account configs
## References
- Fixes https://github.com/openclaw/openclaw/issues/14840
- WhatsApp multi-account schema: `src/config/zod-schema.providers-whatsapp.ts`
- Matrix single-account code: `extensions/matrix/src/matrix/accounts.ts#L21-L23`
Most Similar PRs
#13013: feat(matrix): multi account support
by ti · 2026-02-10
82.0%
#11869: feat: Multi-account Matrix plugin with accountId routing
by jacoblyles · 2026-02-08
80.9%
#21105: feat(matrix): multi-account support
by omnibot1985 · 2026-02-19
79.8%
#23333: fix(matrix): add accountId routing for multi-account message sending 🤖
by BadTurki · 2026-02-22
72.7%
#6517: fix(matrix): pass accountId through outbound chain to resolveMatrix...
by saxyguy81 · 2026-02-01
71.3%
#13057: feat(matrix): add sessionScope=room to route sessions by roomId
by spengrah · 2026-02-10
63.3%
#23721: feat(inbound-meta): expose account_id in inbound_meta.v1 schema
by ekson73 · 2026-02-22
62.8%
#20278: Fix/matrix missing bot sdk dependency
by saurav470 · 2026-02-18
58.6%
#13832: feat(matrix): add sessionScope and thread-scoped inbound sessions
by yamoroc · 2026-02-11
58.0%
#18718: matrix: add pending group history context for room messages
by pharasyte · 2026-02-17
57.9%