-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
Closed
Labels
bugSomething isn't workingSomething isn't workingstaleMarked as stale due to inactivityMarked as stale due to inactivity
Description
Bug Report: Matrix mentions not detected when using formatted_body links
Summary
Matrix mention detection fails when clients use the formatted_body with matrix.to links instead of (or without) the newer m.mentions field.
Environment
- OpenClaw version: 2026.1.30
- Matrix extension: bundled
- Homeserver: Synapse (matrix.medher.online)
- Client: Element Web
Steps to Reproduce
- Configure a Matrix room with
requireMention: true - In Element, mention the bot using the UI (click on username to create mention)
- Send the message
- Bot does not respond
Expected Behavior
Bot should detect the mention and respond.
Actual Behavior
Bot logs {"roomId":"...", "reason":"no-mention"} and ignores the message.
Root Cause Analysis
The resolveMentions() function in extensions/matrix/src/matrix/monitor/mentions.ts only checks:
m.mentions.room- room mention flagm.mentions.user_ids- explicit user ID array- Regex patterns on plain
bodytext
However, many Matrix clients (including Element) send mentions using HTML in formatted_body:
{
"body": "Myka ⚡: hello",
"formatted_body": "<a href=\"https://matrix.to/#/@myka:matrix.medher.online\">Myka ⚡</a>: hello",
"m.mentions": null
}The function does NOT check formatted_body for matrix.to mention links.
Proposed Fix
Add a check for matrix.to links in formatted_body:
// Check formatted_body for matrix.to mention links (legacy/alternative mention format)
let mentionedInFormattedBody = false;
if (params.userId && params.content.formatted_body) {
const escapedUserId = params.userId.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const matrixToPattern = new RegExp(
`href=["']https://matrix\\.to/#/${escapedUserId}["']`,
'i'
);
mentionedInFormattedBody = matrixToPattern.test(params.content.formatted_body);
}Then include mentionedInFormattedBody in the wasMentioned check.
Files to Modify
extensions/matrix/src/matrix/monitor/mentions.ts
Additional Context
- The
m.mentionsfield is part of MSC3952 and may not be sent by all clients - Element Web appears to use
formatted_bodylinks withoutm.mentions - This affects any Matrix bot using OpenClaw with
requireMention: true
Workaround
Set requireMention: false for the room to bypass mention detection entirely.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingstaleMarked as stale due to inactivityMarked as stale due to inactivity