Skip to content

Instantly share code, notes, and snippets.

@maraoz
Created March 15, 2026 16:22
Show Gist options
  • Select an option

  • Save maraoz/8decd9e564c3ba2e6724d8ee1879a888 to your computer and use it in GitHub Desktop.

Select an option

Save maraoz/8decd9e564c3ba2e6724d8ee1879a888 to your computer and use it in GitHub Desktop.

WhatsApp Composing Debounce Patch for OpenClaw

Version tested: OpenClaw 2026.3.1, Baileys 7.0.0-rc.9

Problem

OpenClaw's inbound debounce (default 6s) can't tell if the sender is still typing. Send "Hello", start writing a long follow-up → the bot responds to "Hello" alone before you finish.

Fix

Listen for WhatsApp "composing" presence events and extend the debounce while the sender is typing.

Patch (2 files in openclaw/dist/)

reply-XaR8IPbY.js — Debouncer

Add touch(key, extendMs) and touchByPrefix(prefix, extendMs) to createInboundDebouncer. These reset the flush timer on an existing buffer without adding a message. extendMs temporarily overrides the debounce duration.

channel-web-*.js — WhatsApp Channel

  1. presenceSubscribe on each inbound message (Baileys won't send typing events without it)
  2. LID→E164 cache — presence events arrive with WhatsApp's internal LID format, not phone numbers. Cache the mapping from inbound messages so composing events match the right debounce buffer.
  3. presence.update listener — on "composing", resolve sender E164, call debouncer.touchByPrefix(prefix, 15000). 15s covers the ~10s gap between WhatsApp composing events.
  4. Cleanup — remove listener on socket close.

Key Details

  • Works for all senders.
  • Normal debounce (no typing) is unchanged.
  • WhatsApp sends composing events every ~10s while typing. The 15s extend timeout covers this with margin.
  • The dist filenames contain hashes that may differ across OpenClaw versions. Find the equivalent files by grepping for createInboundDebouncer and messages.upsert.
  • Overwrites on openclaw update — save your diffs and reapply.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment