openclaw - 💡(How to fix) Fix Feature request: pre-delivery message hook (messageFilter / denyMessages) [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#61631Fetched 2026-04-08 02:56:38
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×2
  • OpenClaw version: 2026.3.23-2
  • Channels: WhatsApp, Telegram
  • 5 active users, growing

Root Cause

  • OpenClaw version: 2026.3.23-2
  • Channels: WhatsApp, Telegram
  • 5 active users, growing

Fix Action

Fix / Workaround

Current workaround

Code Example

{
  "gateway": {
    "nodes": {
      "denyMessages": ["HEARTBEAT_OK", "NO_REPLY", "^On it\\.$"]
    }
  }
}

---

{
  "hooks": {
    "internal": {
      "entries": {
        "message-filter": {
          "enabled": true,
          "type": "preDelivery",
          "command": "curl -s -X POST http://localhost:18800/api/validate_outbound -d '{\"message\": \"$MESSAGE\"}'"
        }
      }
    }
  }
}
RAW_BUFFERClick to expand / collapse

Problem

OpenClaw has denyCommands for blocking tool calls, but no equivalent for message content. There is no way to intercept and suppress an assistant message before it reaches the channel (WhatsApp, Telegram, etc).

Currently, hooks (session-memory, message-log) are post-delivery only. By the time they fire, the user has already received the message.

Use case

We run a health coaching agent (Milo) that occasionally leaks internal process narration ("On it.", "Logged.", system health check output) to users via WhatsApp. We have a deterministic outbound gate (validate_outbound()) that catches these with regex + vocabulary matching, but we can only run it post-delivery as a detection layer, not an enforcement layer.

We need a pre-delivery hook so we can block bad messages before they reach users.

What we want

One of:

Option A: denyMessages (analogous to denyCommands)

{
  "gateway": {
    "nodes": {
      "denyMessages": ["HEARTBEAT_OK", "NO_REPLY", "^On it\\.$"]
    }
  }
}

Option B: preDeliveryHook (most flexible)

{
  "hooks": {
    "internal": {
      "entries": {
        "message-filter": {
          "enabled": true,
          "type": "preDelivery",
          "command": "curl -s -X POST http://localhost:18800/api/validate_outbound -d '{\"message\": \"$MESSAGE\"}'"
        }
      }
    }
  }
}

The hook returns {"ok": true} to allow delivery or {"ok": false, "reason": "..."} to suppress it.

Current workaround

  1. Workspace instructions telling the agent what not to send (~95% effective)
  2. Post-delivery detection via _ingest_message hook (logs warnings, can't block)

Context

  • OpenClaw version: 2026.3.23-2
  • Channels: WhatsApp, Telegram
  • 5 active users, growing

extent analysis

TL;DR

Implement a pre-delivery hook to filter out unwanted messages before they reach users, either through a proposed denyMessages configuration or a preDeliveryHook that leverages an external validation service.

Guidance

  • Consider implementing a preDeliveryHook as described in Option B, which would allow for flexible message filtering using an external command or service.
  • If the denyMessages approach is preferred, it could be implemented similarly to denyCommands, with a configuration option to specify denied message patterns.
  • To verify the effectiveness of the hook, monitor the messages that are being sent and check for any unwanted messages that are being blocked.
  • It may be necessary to modify the existing validate_outbound() function to work with the pre-delivery hook, potentially by exposing it as a REST endpoint that can be called by the hook.

Example

{
  "hooks": {
    "internal": {
      "entries": {
        "message-filter": {
          "enabled": true,
          "type": "preDelivery",
          "command": "curl -s -X POST http://localhost:18800/api/validate_outbound -d '{\"message\": \"$MESSAGE\"}'"
        }
      }
    }
  }
}

Notes

The proposed solutions assume that the validate_outbound() function is effective in detecting unwanted messages. If this function is not reliable, additional work may be needed to improve its accuracy.

Recommendation

Apply workaround by implementing a preDeliveryHook as described, as it provides the most flexibility and allows for easy integration with the existing validate_outbound() function. This approach also does not require modifying the OpenClaw configuration or codebase directly.

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