feat(whatsapp): gate group replies on mention and share group sessions

Stop replying to every group message by filtering on @bot/triggers in the sidecar and gateway, and map group chats to one shared session while preserving per-sender identity.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-06-04 18:49:59 +08:00
parent bc1b45a8fd
commit 900e3d0d3e
5 changed files with 581 additions and 10 deletions

View file

@ -20,9 +20,9 @@ def get_or_create_session_for_wecom(
external_chat_id: str,
is_group: bool,
) -> SessionMapResult:
"""Group: session per chat_id; DM: session per user_id.
"""Group chats share one session per external_chat_id (sentinel user key).
We store mapping under (tenant, channel, external_chat_id, external_user_id) to keep it simple.
Direct chats use one session per external_user_id. Identity binding always uses the real sender id.
"""
scope = "group" if bool(is_group) else "dm"
# For DM, external_chat_id is often contact id; we still keep it as provided.