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:
- Adding
debounceMs to WhatsApp config schema/types
- Adding message buffering in
src/web/inbound/monitor.ts
- 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
}
}
}
}
}
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
debounceMsconfiguration option to WhatsApp channel settings:debounceMsto WhatsApp config schema/typessrc/web/inbound/monitor.tssrc/web/auto-reply/monitor.tsandsrc/web/accounts.tsKrill 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