Architecture: How should WhatsApp conversations be segmented when one phon...

Documentation for Sessions

🏗️ Architecture: How should WhatsApp conversations be segmented when one phon...

Date: 2026-02-21
Time: 17:51:29 UTC
Session: gspace1-131.10
Agent: backend
Confidence: 95%
Status: ✅ Documented


📋 Decision Context

Question:

How should WhatsApp conversations be segmented when one phone number = one chat thread?

Task: Not specified


🎯 Decision Made

Chosen:

All three: context commands + groups + space-bound channels

Options Considered:

  1. Accept WhatsApp's limitation, one flat thread per user
  2. Context switching via slash commands within one thread
  3. WhatsApp groups for per-space isolation
  4. All three: context commands + groups + space-bound channels

💭 Reasoning

WhatsApp Business API only allows ONE chat thread per business number per user phone (Meta platform constraint). Solution: 3 layers of segmentation. Layer 1: /space slash commands switch Vitto's context within a single chat (stored in AgentSessionService.activeContext). Layer 2: WhatsApp groups auto-bind to spaces (each group = separate space context, multi-user collaboration). Layer 3: Space-bound channel records allow same phone to have multiple MongoDB channel docs tied to different spaceIds. A 4-level context resolution chain (group binding > session context > channel spaceId > task context > default) determines which space scopes each incoming message.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation