Skip to content

feat(whatsapp): add debounceMs for batching rapid messages#971

Merged
steipete merged 3 commits intoopenclaw:mainfrom
juanpablodlc:feature/whatsapp-message-debounce
Jan 15, 2026
Merged

feat(whatsapp): add debounceMs for batching rapid messages#971
steipete merged 3 commits intoopenclaw:mainfrom
juanpablodlc:feature/whatsapp-message-debounce

Conversation

@juanpablodlc
Copy link
Copy Markdown
Contributor

Summary

Implements message debouncing for WhatsApp to batch rapid consecutive messages from the same sender.

Changes

  • Added `debounceMs` configuration option to WhatsApp channel settings
  • Implemented message buffering in `monitorWebInbox`
  • Wired configuration through account resolution and monitor tuning
  • Added UI hints and schema documentation

Usage

```json5
{
"channels": {
"whatsapp": {
"debounceMs": 5000 // 5 second window
}
}
}
```

Testing

  • ✅ Type-check passed (`pnpm build`)
  • ✅ Lint passed (`pnpm lint`)
  • ✅ All existing tests passed (3204 tests)
  • Manual integration testing with rapid messages

AI Assistance

Marked as AI-assisted - This PR was implemented with assistance from AI coding tools. I understand what the code does and have verified it works correctly.

Closes #967

@steipete steipete self-assigned this Jan 15, 2026
@juanpablodlc
Copy link
Copy Markdown
Contributor Author

Local Testing Results ✅

Successfully tested the WhatsApp debouncing feature in a local deployment. The feature works exactly as designed!

Test Environment

Test Case 1: Rapid Messages (Should Batch) ✅

Sent messages in quick succession:

Hey claude
can
you tell
me what is
the weather

Gateway logs:

22:23:34 [whatsapp] Inbound message +15551234567 -> +15551234567 (direct, 88 chars)
22:23:34 [whatsapp] Inbound body: [WhatsApp +15551234567 2026-01-15T22:23Z] Hey claude
can
you tell
me what is
the weather
22:23:34 [agent/embedded] embedded run start: runId=25a0189b-efae-4204-b3dc-e58a258f1e6c

Result: ✅ All messages batched into a single 88-char message with newline separators. Only one agent run triggered (runId=25a0189b...).

Test Case 2: Slow Messages (Should NOT Batch) ✅

Sent two messages 14 seconds apart:

  1. 22:24:38 - "First test: what is 2+2" → runId=e537719b-8183-42e6-b0f2-db54000f6370
  2. 22:24:52 - "First test: what is 3 x 3" → runId=48d61a1a-7f0c-49f3-b44b-0ed09f757457

Result: ✅ Two separate agent runs with different runId values. Messages were NOT batched because they were outside the 5-second debounce window.

Confirmed Behaviors

  1. ✅ Messages within debounce window are batched together
  2. ✅ Messages outside debounce window are processed separately
  3. ✅ Batched messages are joined with newline separators (\n)
  4. ✅ Single agent run per batch (not per message)
  5. ✅ No errors or warnings in gateway logs

Configuration

The debounceMs setting was added to the WhatsApp channel config:

{
  "channels": {
    "whatsapp": {
      "debounceMs": 5000,
      "dmPolicy": "allowlist",
      "allowFrom": ["+15551234567"]
    }
  }
}

Feature works perfectly! Ready to merge. 🚀

juanpablodlc and others added 3 commits January 15, 2026 22:57
Add a `debounceMs` configuration option to WhatsApp channel settings
that batches rapid consecutive messages from the same sender into a
single response. This prevents triggering separate agent runs for
each message when a user sends multiple short messages in quick
succession (e.g., "Hey!", "how are you?", "I was wondering...").

Changes:
- Add `debounceMs` config to WhatsAppConfig and WhatsAppAccountConfig
- Implement message buffering in `monitorWebInbox` with:
  - Map-based buffer keyed by sender (DM) or chat ID (groups)
  - Debounce timer that resets on each new message
  - Message combination with newline separator
  - Single message optimization (no modification if only one message)
- Wire `debounceMs` through account resolution and monitor tuning
- Add UI hints and schema documentation

Usage example:
{
  "channels": {
    "whatsapp": {
      "debounceMs": 5000  // 5 second window
    }
  }
}

Default behavior: `debounceMs: 0` (disabled by default)

Verified: All existing tests pass (3204 tests), TypeScript compilation
succeeds with no errors.

Implemented with assistance from AI coding tools.

Closes openclaw#967
@steipete steipete force-pushed the feature/whatsapp-message-debounce branch from 1a6ab83 to 1561b1c Compare January 15, 2026 23:07
@steipete steipete merged commit 4a99b9b into openclaw:main Jan 15, 2026
39 of 42 checks passed
@steipete
Copy link
Copy Markdown
Contributor

Landed via squash after temp rebase onto main.\n\n- Gate: pnpm lint && pnpm build && pnpm test\n- Land commit: 1561b1c\n- Merge commit: 4a99b9b\n\nThanks @juanpablodlc!

dominicnunez pushed a commit to dominicnunez/openclaw that referenced this pull request Feb 26, 2026
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
)

* feat(whatsapp): add debounceMs for batching rapid messages

Add a `debounceMs` configuration option to WhatsApp channel settings
that batches rapid consecutive messages from the same sender into a
single response. This prevents triggering separate agent runs for
each message when a user sends multiple short messages in quick
succession (e.g., "Hey!", "how are you?", "I was wondering...").

Changes:
- Add `debounceMs` config to WhatsAppConfig and WhatsAppAccountConfig
- Implement message buffering in `monitorWebInbox` with:
  - Map-based buffer keyed by sender (DM) or chat ID (groups)
  - Debounce timer that resets on each new message
  - Message combination with newline separator
  - Single message optimization (no modification if only one message)
- Wire `debounceMs` through account resolution and monitor tuning
- Add UI hints and schema documentation

Usage example:
{
  "channels": {
    "whatsapp": {
      "debounceMs": 5000  // 5 second window
    }
  }
}

Default behavior: `debounceMs: 0` (disabled by default)

Verified: All existing tests pass (3204 tests), TypeScript compilation
succeeds with no errors.

Implemented with assistance from AI coding tools.

Closes openclaw#967

* chore: wip inbound debounce

* fix: debounce inbound messages across channels (openclaw#971) (thanks @juanpablodlc)

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
dustin-olenslager pushed a commit to dustin-olenslager/ironclaw-supreme that referenced this pull request Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: WhatsApp Message Debouncing for Batching Rapid Messages

2 participants