GOWA - WhatsApp REST API with support for UI, Multi Account, Webhooks, and MCP, and Chatwoot. Built with Golang for efficient memory use.
Go botgogolanggolang-whatsappgolang-whatsapp-apirestrest-apiwhatsappwhatsapp-apiwhatsapp-api-gowhatsapp-multi-devicewhatsapp-web-multi-device
WhatsApp infrastructure
This package owns clients, device lifecycle, JIDs, events, presence, and forwarding.
- Lifecycle:
device_manager.go,device_instance.go,client_lifecycle.go. Registry aliases differ from logged-in storage identities: useclient.Store.ID.ToNonAD().String()for chat/messagedevice_id, notinstance.ID(). - Events: register event types in
event_handler.goand carryContextWithDevice(ctx, instance)downstream. Keep event-side storage access behindchatstorage_wrapper.go, including new repository methods. - JIDs: use
NormalizeJIDFromLIDinjid_utils.gobefore phone-JID lookups/storage andToNonAD()for stable identities. LID lookup may fail or have nil client, store, or LID store; preserve the original JID fallback. - Webhooks:
event_message.goandwebhook_forward.go; use the payload contract for payload changes. Keep work bounded and failures observable without blocking the event loop. Preserve theshouldForwardReceiptguard: contacts' linked-device receipts stay dropped to prevent duplicates; only the account's own read receipts pass from any device. Device events (event_device.go) take the webhook config by stable slot ID with a bounded context-aware SQL lookup. They capture the session id before returning, sincehandleLoggedOutforwards just beforeTriggerLoggedOutclears the JID; delivery starts before the bounded websocket broadcast. - Chatwoot retries:
StartChatwootForwardRetryWorkeruses durable chat-storage jobs keyed by device, event name, and WhatsApp message ID. Initialize the client registry before the retry worker; preserve device routing when replaying queued events. - Presence:
presence_pulse.gotargets connected, logged-in devices, then returns them to unavailable.../../cmd/helpers.goguards process-wide startup withsync.Once; do not introduce a second scheduler. - Session keys:
key_cache.goredirects selected key stores. Leave privacy tokens in durable primary WhatsApp storage rather than moving them to a volatile keys DB. - History:
history_sync.gohandles batches; preserve the same device and JID rules.
Tests commonly exercise unexported helpers and replace package globals. Restore replacements and keep scheduler tests serial; use fake clients/clocks and bounded waits for presence behavior.