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
Chat storage
sqlite_repository.go implements domains/chatstorage.IChatStorageRepository.
For a contract change, update the domain interface and WhatsApp wrapper together.
Identity and queries
chatsuses(jid, device_id);messagesuses(id, chat_jid, device_id). Use device-scoped chat, message, delete, and count methods for user-facing flows.GetMessagesandSearchMessagesrequire device IDs. Quote lookups useGetMessageByIDAndDevice; useGetMessageByIDChatAndDevicewhen chat identity is part of the request. Do not copy legacy global lookups into scoped flows.- Event/sent-message storage derives device identity from the whatsmeow client
context.
status@broadcastmust display asStatus. scheduled_sendsis keyed by the registry slot alias (instance.ID()), not the storage JID, because the worker resolves clients withDeviceManager.GetDevice.scheduled_sends.pending_message_idis the WhatsApp id of the occurrence being attempted: set under the lease before the first attempt, kept across retries, cleared when the occurrence completes or is given up (RetryScheduledSendwith attempts 0, or a paused job resumed at a later slot). A job whose lease lapsed goes back to the queue with the id kept, so the same occurrence is resent under it.- Poll occurrences persist
pending_poll_secretatomically with the id; clear both when moving to a new occurrence.legacy_attempt_unknownmarks pre-protocol running/retried rows for conservative skip/fail recovery, including paused retries. - Parameterize values in SQL; dynamic clauses use fixed fragments plus arguments.
message_editsretains append-only history while the current message updates.
Schema and cleanup
- Append migrations to
getMigrations(); do not reorder or rewrite applied entries. Read the current schema there instead of relying on a documented migration count. chatwoot_message_linksuses(device_id, wa_message_id); reverse conversation lookup also needs account/config scope. Legacy account0is allowed only in legacy single-account mode, never as a wildcard for per-device routing.chatwoot_forward_queueuniqueness is(device_id, event_name, wa_message_id). Device deletion/truncation must clean up related links and retry jobs. Config deletion removes its owned links so stale rows cannot route a rebound destination.DeleteDeviceDataandTruncateAllChatsdeletescheduled_sends. Scheduled media understorages/scheduled/<id>is removed on completion, failure, or cancel, and by the startup GC.- Preserve device registry operations during purge/load changes. Poll definitions
use
(device_id, chat_jid, poll_message_id)and must retain that scope.
Storage tests use real SQLite with temporary or in-memory databases. For schema, isolation, or cleanup changes, cover the affected query and deletion behavior with those fixtures; exercise CGO/purego variants when driver behavior is involved.