Skip to content

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

Closed
mubbie wants to merge 3 commits into
openclaw:mainfrom
mubbie:feature/dm-require-mention
Closed

mubbie wants to merge 3 commits into
openclaw:mainfrom
mubbie:feature/dm-require-mention

Conversation

@mubbie

@mubbie mubbie commented Apr 6, 2026

Copy link
Copy Markdown

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

File What
src/config/types.channels.ts Add dmRequireMention to ExtensionChannelConfig
src/config/types.whatsapp.ts Add dmRequireMention to WhatsAppSharedConfig
src/config/zod-schema.providers-whatsapp.ts Add Zod validation for dmRequireMention
extensions/whatsapp/src/accounts.ts Thread dmRequireMention through ResolvedWhatsAppAccount
extensions/whatsapp/src/auto-reply/monitor/on-message.ts DM mention gating logic in the DM processing branch
Generated files Config 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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: whatsapp-web Channel integration: whatsapp-web size: M labels Apr 6, 2026
@mubbie
mubbie force-pushed the feature/dm-require-mention branch from 3dff2f1 to 1c0bd26 Compare April 6, 2026 02:34
@greptile-apps

greptile-apps Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds dmRequireMention to the WhatsApp channel (and the base ExtensionChannelConfig) to gate DM replies behind mention-pattern matching, cleanly reusing the existing buildMentionConfig / debugMention / resolveMentionGating stack. The type additions, Zod schema, and account resolution are consistent with the surrounding codebase patterns. The one P2 note is that DM trigger patterns are sourced from agents[*].groupChat.mentionPatterns, which is semantically confusing for users configuring a DM-only feature and could silently suppress DMs if no patterns are configured.

Confidence Score: 5/5

Safe to merge; no P0 or P1 issues found.

All findings are P2 style/UX. The implementation is correct, the config placement follows the existing pattern (mirrors how dmPolicy is handled in ExtensionChannelConfig), and the reuse of the mention-gating stack is sound.

No files require special attention.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/whatsapp/src/auto-reply/monitor/on-message.ts
Line: 168-179

Comment:
**DM mention patterns sourced from `groupChat` config key**

`buildMentionConfig(loadConfig(), route.agentId)` resolves patterns via `resolveMentionPatterns`, which reads exclusively from `agents[*].groupChat.mentionPatterns` and `messages.groupChat.mentionPatterns` (see `src/auto-reply/reply/mentions.ts:104-119`). This means users enabling `dmRequireMention: true` must configure their trigger patterns under the `groupChat` key — semantically at odds with a DM-only feature. If neither patterns nor an agent `identity` is configured the regex list is empty, so the only passing path is the phone-number body fallback inside `isBotMentionedFromTargets`, which could silently suppress most DMs and be difficult to diagnose. Worth documenting clearly or adding a dedicated `dm.mentionPatterns` resolution path in a follow-up.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "feat(whatsapp): add dmRequireMention for..." | Re-trigger Greptile

@mubbie
mubbie force-pushed the feature/dm-require-mention branch from 1c0bd26 to 8e3f6ee Compare April 6, 2026 02:37
@mubbie
mubbie force-pushed the feature/dm-require-mention branch from 8e3f6ee to c3e626f Compare April 6, 2026 02:46

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c3e626f066

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

mubbie and others added 3 commits April 6, 2026 00:29
Adds a `dmRequireMention` config option that allows authorized DM senders
to chat without triggering a bot reply on every message. When enabled,
only DMs matching the agent's configured `mentionPatterns` trigger a
response — mirroring the existing `requireMention` behavior for groups.

Closes openclaw#61607

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
When dmRequireMention is enabled but no mentionPatterns are configured,
allow DMs through instead of silently suppressing all messages. Adds a
code comment noting that patterns currently resolve from the groupChat
config key, with a dedicated dmMentionPatterns path as a follow-up.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Hoist the loadConfig() call into a variable and reuse it in the DM
gating branch instead of calling loadConfig() a second time per message.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@mubbie
mubbie force-pushed the feature/dm-require-mention branch from f20a22e to 5db76e1 Compare April 6, 2026 07:29
@vincentkoc vincentkoc added the triage: dirty-candidate Candidate: broad unrelated surfaces; may need splitting or cleanup. label Apr 26, 2026
@clawsweeper

clawsweeper Bot commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Keep this PR open because current main still lacks authorized-WhatsApp-DM mention gating and the linked request was closed in favor of this branch, but it is not merge-ready: the branch conflicts with current main, lacks real WhatsApp proof, and introduces sensitive DM body logging.

Root-cause cluster
Relationship: canonical
Canonical: #61624
Summary: This PR is the open implementation candidate for authorized WhatsApp DM mention gating; the linked issue and older closed report describe the same user problem, while the broad pre-auth PR is adjacent access-control work.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

So I’m closing this here because the remaining work is already tracked in the canonical issue.

Review details

Best possible solution:

Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

Do we have a high-confidence way to reproduce the issue?

Not applicable as a feature PR. Source inspection shows current main has no dmRequireMention support, while the PR body leaves the real WhatsApp behavior checks unchecked.

Is this the best way to solve the issue?

No as submitted. Reusing mention-pattern infrastructure is plausible, but the best fix needs a current-main port, privacy-safe logging, policy/docs alignment, regression coverage, and redacted real WhatsApp proof.

Security review:

Security review needs attention: Security review needs attention because the patch logs skipped private WhatsApp DM content.

  • [medium] Skipped DM content logged — extensions/whatsapp/src/auto-reply/monitor/on-message.ts:186
    The new skip branch includes the full direct-message body in a verbose log when dmRequireMention blocks processing, which can expose sensitive user text outside the chat.
    Confidence: 0.9

AGENTS.md: found and applied where relevant.

What I checked:

  • stale F-rated PR: PR was opened 2026-04-06T02:30:26Z, is older than 60 days, and the latest review rated it F.
  • proof blocker: real behavior proof is missing and proof tier is F, so this branch is not merge-ready without contributor follow-up.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • mcaxtr: Authored recent admission-object and multi-account/shared-defaults changes in the WhatsApp handler, inbound policy, and account-resolution paths this PR now conflicts with. (role: recent WhatsApp inbound/account contributor; confidence: high; commits: 8686f0469936, 458a52610a4d; files: extensions/whatsapp/src/auto-reply/monitor/on-message.ts, extensions/whatsapp/src/accounts.ts, extensions/whatsapp/src/inbound-policy.ts)
  • patrick-slimelab: Authored the provider-scoped mention-pattern work that changed WhatsApp mention-pattern resolution and related config semantics. (role: mention-pattern feature contributor; confidence: medium; commits: 9c1adf4e51a9; files: extensions/whatsapp/src/auto-reply/mentions.ts, src/auto-reply/reply/mentions.ts, src/config/types.whatsapp.ts)
  • TurboTheTurtle: Authored configured ACP binding work that substantially changed the WhatsApp message handler after this branch was opened. (role: recent WhatsApp handler contributor; confidence: medium; commits: 8549a203d4df; files: extensions/whatsapp/src/auto-reply/monitor/on-message.ts)
  • LZY3538: Authored recent work preserving effective mention policy in WhatsApp group gating, sharing the mention-decision invariant this PR extends to DMs. (role: adjacent mention-policy contributor; confidence: medium; commits: e272da5c5579; files: extensions/whatsapp/src/auto-reply/monitor/group-gating.ts)

Codex review notes: model internal, reasoning high; reviewed against 010b61746379.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels May 19, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. label May 19, 2026
@clawsweeper

clawsweeper Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels May 21, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jun 5, 2026
@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 5, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jun 6, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. labels Jun 14, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Jul 3, 2026
@openclaw-barnacle openclaw-barnacle Bot added the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 3, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. and removed merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 3, 2026
@clawsweeper

clawsweeper Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper applied the proposed close for this PR.

@clawsweeper clawsweeper Bot closed this Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: whatsapp-web Channel integration: whatsapp-web docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: dirty-candidate Candidate: broad unrelated surfaces; may need splitting or cleanup. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add DM trigger gating separate from DM access policy

2 participants