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
Usecases
Usecases validate requests, resolve the device/client, perform WhatsApp and storage
operations, and return domain responses. Constructors use New*Service and return
the matching domain interface; keep Fiber/MCP response types in the adapters.
- Validate with
validations.Validate*before network or storage work, even when the transport already parsed the request. Use existingpkg/errorerrors and contextual wrapping; the package name iserror, commonly aliasedpkgError. - Resolve clients with
whatsapp.ClientFromContext(ctx)and chat/message scope withdeviceIDFromContext(ctx). An explicit device context must not fall back to the global client. Pass scope through repository filters and sent-message storage. send.goowns send payloads and quote context.mergeReplyContextmust useGetMessageByIDAndDevice; an unscoped lookup can quote another device's message.wrapSendMessagecalls whatsmeow'sSendMessageand normalizes errors. Code 463 is surfaced as a server-side reach-out restriction; whatsmeow owns the token lifecycle. Async sent-message persistence retains device context while detaching cancellation.schedule.goownsScheduleService(durable worker, pause/resume/cancel) andscheduledSendService, a decorator overISendUsecase. A new send method whose request embedsScheduleOptionsmust branch onIsScheduled()and getvalidateScheduledPayload/dispatchcases. The worker dispatches through the undecorated base usecase, never the decorator. Rows are keyed byinstance.ID()(slot alias) so the worker can resolve them withDeviceManager.GetDevice. Every attempt of an occurrence is sent under the WhatsApp message id stored inpending_message_idbefore the first attempt (pinOccurrenceMessageID), so a retry after a lost acknowledgment does not create a fresh message identity. An occurrence whose lease lapsed (crash, or a send that outlived it) is requeued byrecoverInterruptedand resent under that id, not skipped; a send path the worker dispatches to must go throughwrapSendMessage, which applies the pinned id. Polls also persistpending_poll_secretwith the id and reuse it in the builder. Legacy unknown attempts are skipped/failed; no exactly-once delivery is promised.chat.goowns history queries;message.goowns reactions, revokes, edits, and other message actions. Message actions read the calling device's own stored copy in the requested chat; a lookup by ID alone can return another device's row, whose "from me" flag and media keys differ. Media downloads usestoredMessageForAction; resolve scope withstorageDeviceID(ctx)and refuse that read when it is empty.group.gohandles participant JIDs and group settings,user.goaccount/contact operations, anddevice.godelegates lifecycle operations toDeviceManager.
For mapping, media, quote, or isolation changes, use the colocated tests and stubs to cover the affected behavior. Choose test scope from the change rather than requiring every usecase suite for each edit.