Skip to content

[Feature]: WhatsApp Message Debouncing for Batching Rapid Messages #967

Description

@juanpablodlc

Summary

Allow users to configure a debounce window that batches rapid consecutive messages from the same sender into a single response.

Problem

Users who send multiple short messages in quick succession (e.g., "Hey!", "how are you?", "I was wondering...") trigger separate agent runs for each message instead of having them combined into one coherent conversation turn.

Proposed Solution

Add a debounceMs configuration option to WhatsApp channel settings:

{
  "channels": {
    "whatsapp": {
      "debounceMs": 5000  // wait 5 seconds for more messages before responding
    }
  }
}


When enabled, messages from the same sender within the debounce window are combined with newlines.

Implementation Hints
See the conversation in Discord #batch-processing-of-messages for details. The implementation involves:
  1. Adding debounceMs to WhatsApp config schema/types
  2. Adding message buffering in src/web/inbound/monitor.ts
  3. Wiring it through src/web/auto-reply/monitor.ts and src/web/accounts.ts

Krill initial thoughts

Implement something like this:

Changes Made

Config Schema
(src/config/zod-schema.providers-whatsapp.ts)
Added debounceMs field (default: 0, meaning disabled)

Config Types
(src/config/types.whatsapp.ts)
Added debounceMs?: number to both WhatsAppConfig and WhatsAppAccountConfig

UI Hints
(src/config/schema.ts)
Added label and help text for the new config option

Message Buffering
(src/web/inbound/monitor.ts)
Added debounce logic that buffers messages from the same sender
Combines multiple messages into one with \n separators
For DMs: batches by sender (from)
For Groups: batches by chatId

Account Resolution
(src/web/accounts.ts)
Added debounceMs to ResolvedWhatsAppAccount type
Wires config through to the monitor

Usage
{
  "channels": {
    "whatsapp": {
      "debounceMs": 5000  // wait 5 seconds for more messages before responding
    }
  }
}
Or per-account:
{
  "channels": {
    "whatsapp": {
      "accounts": {
        "default": {
          "debounceMs": 5000
        }
      }
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions