openclaw - ✅(Solved) Fix Add DM trigger gating separate from DM access policy [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#61607Fetched 2026-04-08 02:56:55
View on GitHub
Comments
0
Participants
1
Timeline
6
Reactions
1
Author
Participants
Timeline (top)
referenced ×5cross-referenced ×1

Fix Action

Fixed

PR fix notes

PR #61624: feat(whatsapp): add dmRequireMention for DM trigger gating

Description (problem / solution / changelog)

Summary

  • Adds dmRequireMention config option to WhatsApp channel (and base ExtensionChannelConfig) that gates DM replies behind mention-pattern matching
  • Reuses existing mentionPatterns + resolveMentionGating infrastructure — no new pattern config needed
  • When enabled, authorized DM senders can chat without triggering a reply on every message; only messages matching a mention pattern trigger the bot

Closes #61607

Changes

FileWhat
src/config/types.channels.tsAdd dmRequireMention to ExtensionChannelConfig
src/config/types.whatsapp.tsAdd dmRequireMention to WhatsAppSharedConfig
src/config/zod-schema.providers-whatsapp.tsAdd Zod validation for dmRequireMention
extensions/whatsapp/src/accounts.tsThread dmRequireMention through ResolvedWhatsAppAccount
extensions/whatsapp/src/auto-reply/monitor/on-message.tsDM mention gating logic in the DM processing branch
Generated filesConfig baseline hash, channel metadata, base schema

Example config

{
  "channels": {
    "whatsapp": {
      "dmRequireMention": true
    }
  },
  "agents": {
    "list": [
      {
        "id": "main",
        "groupChat": {
          "mentionPatterns": ["@openclaw"]
        }
      }
    ]
  }
}

Test plan

  • TypeScript type check passes (no new errors)
  • mention-gating.test.ts passes (core gating logic)
  • accounts.test.ts passes (account config resolution)
  • config-accessors.test.ts passes
  • Config schema drift checks pass (config:docs:check, config:channels:check, check:base-config-schema)
  • Manual verification: set dmRequireMention: true, send DM without mention pattern → no reply
  • Manual verification: send DM with mention pattern → reply triggers

Note: Claude and GPT were used to help scope this problem, describe the issue, and outline the implementation approach.

🤖 Generated with Claude Code

Changed files

  • docs/.generated/config-baseline.sha256 (modified, +2/-2)
  • extensions/whatsapp/src/accounts.ts (modified, +2/-0)
  • extensions/whatsapp/src/auto-reply/monitor/on-message.ts (modified, +37/-2)
  • src/config/bundled-channel-config-metadata.generated.ts (modified, +6/-0)
  • src/config/types.channels.ts (modified, +2/-0)
  • src/config/types.whatsapp.ts (modified, +2/-0)
  • src/config/zod-schema.providers-whatsapp.ts (modified, +1/-0)

Code Example

{
  "channels": {
    "whatsapp": {
      "dmRequireMention": true
    }
  },
  "agents": {
    "list": [
      {
        "id": "main",
        "groupChat": {
          "mentionPatterns": ["@openclaw"]
        }
      }
    ]
  }
}
RAW_BUFFERClick to expand / collapse

Problem

Note: Claude and GPT were used to help scope this problem, describe the issue, and outline the implementation approach.


OpenClaw currently has two layers for group chats:

  1. Access controlgroupPolicy / allowlists determine if a message is permitted at all
  2. Trigger gatingrequireMention + mentionPatterns + native mention metadata + reply-to-bot detection determine if a permitted message actually triggers a response

For DMs, only the first layer exists:

  1. Access controldmPolicy (pairing / allowlist / open / disabled) determines if a sender can reach the bot

There is no second trigger-gating layer for DMs. This means once a sender is authorized, every DM triggers a reply. There is no way to say "this sender can reach the bot, but only messages matching specific patterns should trigger processing."

Use case

Someone running OpenClaw wants authorized DM contacts to be able to chat in the DM thread, but only have the bot respond when explicitly addressed via mention patterns like @openclaw. Without DM trigger gating, the bot responds to every single message from an authorized sender.

This is the same problem requireMention solves for groups — it just doesn't exist for DMs yet.

Proposed solution

Add an optional dmRequireMention flag at the channel config level that reuses the existing mentionPatterns infrastructure.

Config surface

{
  "channels": {
    "whatsapp": {
      "dmRequireMention": true
    }
  },
  "agents": {
    "list": [
      {
        "id": "main",
        "groupChat": {
          "mentionPatterns": ["@openclaw"]
        }
      }
    ]
  }
}

Behavior

  • If DM is unauthorized → blocked by dmPolicy (unchanged)
  • If DM is authorized and dmRequireMention is not set or false → process normally (unchanged, backwards compatible)
  • If DM is authorized and dmRequireMention: true and no text pattern matches → no reply (new)
  • If DM is authorized and dmRequireMention: true and a pattern matches → normal reply (new)

MVP scope

  • No reply-to-bot shortcut in DMs (every message in a DM is "to the bot," so this would collapse the gate)
  • No pending-history buffering for skipped DMs (silently skip; can be revisited later)
  • Reuses existing mentionPatterns from agent config — no new pattern list needed
  • Applies to all DM-capable channels (WhatsApp initially, extensible to others)

Implementation areas

  1. Config schema — add dmRequireMention boolean to ExtensionChannelConfig and validation
  2. Channel runtime — in the DM processing branch (e.g., WhatsApp on-message.ts), check the flag and run mention pattern matching before processing
  3. Reuse existing infrastructureresolveMentionGating() from src/channels/mention-gating.ts and buildMentionRegexes() from mention pattern utilities already do the heavy lifting

Design decisions

QuestionDecisionRationale
Should skipped DMs be buffered?No (MVP)Buffering untriggered DMs could feel unexpected; revisit if needed
Should reply-to-bot count as trigger?NoIn DMs every message is "to the bot" — this would negate the gate
Should native mention metadata matter?No (for WhatsApp DMs)Text patterns are the primary mechanism in DM context
WhatsApp-only or cross-channel?Cross-channel config, WhatsApp firstdmRequireMention lives on ExtensionChannelConfig, so any channel can adopt it

extent analysis

TL;DR

To fix the issue of OpenClaw responding to every DM from authorized senders, add an optional dmRequireMention flag to the channel config level, reusing the existing mentionPatterns infrastructure.

Guidance

  • Implement the dmRequireMention flag in the config schema and add validation for it in ExtensionChannelConfig.
  • Update the channel runtime to check the dmRequireMention flag and run mention pattern matching before processing DMs.
  • Reuse existing infrastructure, such as resolveMentionGating() and buildMentionRegexes(), to minimize new code.
  • Test the new functionality with different scenarios, including authorized and unauthorized senders, and various mention patterns.

Example

{
  "channels": {
    "whatsapp": {
      "dmRequireMention": true
    }
  },
  "agents": {
    "list": [
      {
        "id": "main",
        "groupChat": {
          "mentionPatterns": ["@openclaw"]
        }
      }
    ]
  }
}

Notes

The proposed solution focuses on adding a new flag to the channel config, which may require updates to the config schema and validation. Additionally, the implementation should consider the MVP scope and design decisions outlined in the issue.

Recommendation

Apply the workaround by adding the dmRequireMention flag to the channel config, as it provides a flexible solution for controlling when the bot responds to DMs. This approach allows for a gradual rollout and testing of the new functionality without disrupting existing behavior.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING