Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
chore(message): satisfy the lint, docs and format gates for the button prompt work
Yudhi Armyndharisfae8b49e91e5
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f14e04a23..4be42a7ee 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,17 +9,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Added-- Baileys inbound button, template quick-reply, list-row and native-flow replies arrive as `type: "text"` with a structured `button { id, text? }` on `message.received` (whatsapp-web.js still has no interactive reply fields). The REST chat-history route is whatsapp-web.js only and does not carry these fields.-- Baileys inbound business prompts that offer clickable buttons (or list rows) also carry `buttons: [{ id, text }, …]` on `message.received` (URL/call CTAs are omitted — they cannot be clicked), so choices like Sim/Não are no longer flattened away into `body` only.-- `POST /api/sessions/:sessionId/messages/click-button` sends a structured button/list reply against a stored WhatsApp Business prompt on Baileys (whatsapp-web.js returns `501`). Classic `buttonsMessage` / `templateMessage` / `listMessage` prompts are supported; native-flow `interactiveMessage` replies are unverified.-- The dashboard Chats thread renders inbound Baileys prompt `buttons` and taps them through `POST .../messages/click-button`; prompt choices are also kept in persisted message `metadata` so they survive reload for rendering. Clicking still requires the prompt to be in the engine store — an evicted prompt 404s.+- Baileys inbound button, template quick-reply, list-row and native-flow replies arrive as `type: "text"` with a structured `button { id, text? }` on `message.received` (whatsapp-web.js still has no interactive reply fields). The REST chat-history route is whatsapp-web.js only and does not carry these fields. Thanks @gabrielmmoraes1999.+- Baileys inbound business prompts that offer clickable buttons (or list rows) also carry `buttons: [{ id, text }, …]` on `message.received` (URL/call CTAs are omitted — they cannot be clicked), so choices like Sim/Não are no longer flattened away into `body` only. Thanks @gabrielmmoraes1999.+- `POST /api/sessions/:sessionId/messages/click-button` sends a structured button/list reply against a stored WhatsApp Business prompt on Baileys (whatsapp-web.js returns `501`). Classic `buttonsMessage` / `templateMessage` / `listMessage` prompts are supported; native-flow `interactiveMessage` replies are unverified. Thanks @gabrielmmoraes1999.+- The dashboard Chats thread renders inbound Baileys prompt `buttons` and taps them through `POST .../messages/click-button`; prompt choices are also kept in persisted message `metadata` so they survive reload for rendering. Clicking still requires the prompt to be in the engine store — an evicted prompt 404s. Thanks @gabrielmmoraes1999.- Webhook and automation filters accept a `chatId` condition, so a webhook can be scoped to specific groups or chats instead of only to a sender ([#1634](https://github.com/rmyndharis/OpenWA/issues/1634)). Thanks @krishshah9944.- The dashboard Templates list has a delete button on each row, so a template can be deleted without opening it in the editor first. Like the editor's delete button, it shows only for keys that can write templates. Thanks @C24212.- On the dashboard Chats page, Escape closes the open chat, channel or status viewer and returns to the list. It leaves the key alone while a dialog, a menu or the media viewer is open, since those handle Escape themselves. Thanks @C24212.### Changed-- Baileys `listMessage`, `buttonsResponseMessage`, `templateButtonReplyMessage` and `listResponseMessage` now classify as `type: "text"` (they previously fell through to `unknown`). Consumers filtering on `type` will see those shapes as text.+- Baileys `listMessage`, `buttonsResponseMessage`, `templateButtonReplyMessage` and `listResponseMessage` now classify as `type: "text"` (they previously fell through to `unknown`). Consumers filtering on `type` will see those shapes as text. Thanks @gabrielmmoraes1999.- The PostgreSQL data connection is pinned to UTC: parameters bind as UTC, naive timestamps read back as UTC, every pooled connection sets its session `TimeZone`, and boot fails when the effective zone is not UTC year round.- Credentials on a `socks4://` session proxy are reported at session start as unauthenticatable: SOCKS4 sends the user name as the connect request's user id and drops the password.diff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.cssindex e2299e7da..ce0b357a3 100644--- a/dashboard/src/pages/Chats.css+++ b/dashboard/src/pages/Chats.css@@ -1253,7 +1253,10 @@font-size: 0.875rem;font-weight: 500;cursor: pointer;- transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;+ transition:+ background 0.15s ease,+ border-color 0.15s ease,+ opacity 0.15s ease;}.chats-page .message-prompt-button:hover:not(:disabled) {diff --git a/docs/18-sdk-design.md b/docs/18-sdk-design.mdindex 359edf81a..73d8eb2bc 100644--- a/docs/18-sdk-design.md+++ b/docs/18-sdk-design.md@@ -29,7 +29,7 @@ All five SDKs expose the same fluent surface:| Resource | Methods || ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- || `sessions` | list, get, getConfig, updateConfig, getProxy, updateProxy, create, delete, start, stop, logout, forceKill, getQrCode, requestPairingCode, setOnlinePresence, stats |-| `messages` | list, sendText, sendImage/Video/Audio/Document/Sticker, sendLocation, sendContact, sendTemplate, sendPoll, reply, forward, react, delete, editMessage, history, reactions, media, pin, unpin, star, votePoll, sendBulk, batchStatus, cancelBatch |+| `messages` | list, sendText, sendImage/Video/Audio/Document/Sticker, sendLocation, sendContact, sendTemplate, sendPoll, reply, forward, clickButton, react, delete, editMessage, history, reactions, media, pin, unpin, star, votePoll, sendBulk, batchStatus, cancelBatch || `contacts` | list, get, check, profilePicture, profilePictures, phone, upsert, delete, block, unblock, listBlocked || `groups` | list, get, create, joinInfo, joinGroup, add/remove/promote/demoteParticipants, setSubject, setDescription, getGroupSettings, updateGroupSettings, leave, getPicture, setPicture, deletePicture, inviteCode, revokeInviteCode, getMembershipRequests, approveMembershipRequests, rejectMembershipRequests || `webhooks` | list, listAll, deliveryFailures, get, create, update, delete, test |@@ -160,6 +160,7 @@ The top-level client also exposes:| `sendPoll` | `sendPoll(sessionId, body)` | Send a poll message. **OPERATOR** || `reply` | `reply(sessionId, body)` | Reply to a specific message. **OPERATOR** || `forward` | `forward(sessionId, body)` | Forward a message to another chat. **OPERATOR** |+| `clickButton` | `clickButton(sessionId, body)` | Tap a button or list row on a stored WhatsApp Business prompt (Baileys only). **OPERATOR** || `react` | `react(sessionId, body)` | React to a message (empty `reaction` removes it). **OPERATOR** || `delete` | `delete(sessionId, body)` | Delete a message. **OPERATOR** || `editMessage` | `editMessage(sessionId, body)` | Edit the text of a message already sent. **OPERATOR** |@@ -533,6 +534,7 @@ Resources are accessed as properties on the client (e.g. `client.messages`). All| `send_poll` | `send_poll(session_id, body) -> MessageResponse` | Send a poll message. **OPERATOR** || `reply` | `reply(session_id, body) -> MessageResponse` | Reply to a message. **OPERATOR** || `forward` | `forward(session_id, body) -> MessageResponse` | Forward a message. **OPERATOR** |+| `click_button` | `click_button(session_id, body) -> MessageResponse` | Tap a button or list row on a stored WhatsApp Business prompt (Baileys only). **OPERATOR** || `react` | `react(session_id, body) -> SuccessResult` | React to a message. **OPERATOR** || `delete` | `delete(session_id, body) -> SuccessResult` | Delete a message. **OPERATOR** || `edit_message` | `edit_message(session_id, body) -> MessageResponse` | Edit the text of a message already sent. **OPERATOR** |@@ -877,6 +879,7 @@ All payloads are associative arrays; all listed methods are synchronous and retu| `sendPoll` | `sendPoll(string $sessionId, array $body): array` | Send a native poll (2–12 options). **OPERATOR** || `reply` | `reply(string $sessionId, array $body): array` | Reply to a message. **OPERATOR** || `forward` | `forward(string $sessionId, array $body): array` | Forward a message. **OPERATOR** |+| `clickButton` | `clickButton(string $sessionId, array $body): array` | Tap a button or list row on a stored WhatsApp Business prompt (Baileys only). **OPERATOR** || `react` | `react(string $sessionId, array $body): array` | React to a message. **OPERATOR** || `delete` | `delete(string $sessionId, array $body): array` | Delete a message. **OPERATOR** || `editMessage` | `editMessage(string $sessionId, array $body): array` | Edit the text of a message already sent (`$body` needs `chatId`, `messageId`, `body`). **OPERATOR** |diff --git a/sdk/README.md b/sdk/README.mdindex 9e5c5dd6e..47c5fde32 100644--- a/sdk/README.md+++ b/sdk/README.md@@ -25,7 +25,7 @@ All five SDKs expose the same fluent resource surface:| Resource | Methods || ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ || `sessions` | list, get, getConfig, updateConfig, getProxy, updateProxy, create, delete, start, stop, logout, forceKill, getQrCode, requestPairingCode, setOnlinePresence, stats |-| `messages` | list, sendText, sendImage/Video/Audio/Document/Sticker, sendLocation, sendContact, sendTemplate, sendPoll, reply, clickButton, forward, react, delete, editMessage, history, reactions, media, pin, unpin, star, votePoll, sendBulk, batchStatus, cancelBatch |+| `messages` | list, sendText, sendImage/Video/Audio/Document/Sticker, sendLocation, sendContact, sendTemplate, sendPoll, reply, clickButton, forward, react, delete, editMessage, history, reactions, media, pin, unpin, star, votePoll, sendBulk, batchStatus, cancelBatch || `contacts` | list, get, check, profilePicture, profilePictures, phone, upsert, delete, block, unblock, listBlocked || `groups` | list, get, create, joinGroup, joinInfo, add/remove/promote/demoteParticipants, setSubject, setDescription, get/updateGroupSettings, leave, getPicture, setPicture, deletePicture, inviteCode, revokeInviteCode, getMembershipRequests, approveMembershipRequests, rejectMembershipRequests || `webhooks` | list, listAll, deliveryFailures, get, create, update, delete, test |diff --git a/sdk/go/types_message.go b/sdk/go/types_message.goindex cacb78a13..1265707f0 100644--- a/sdk/go/types_message.go+++ b/sdk/go/types_message.go@@ -321,20 +321,6 @@ type MessageProduct struct {BusinessOwnerJID string `json:"businessOwnerJid,omitempty"`}-// MessageButton is the button/list reply block on message.received when the sender tapped a-// WhatsApp Business control. Baileys only. Not populated on the REST chat-history route.-type MessageButton struct {- ID string `json:"id"`- Text string `json:"text,omitempty"`-}--// MessageButtonChoice is one clickable choice on an inbound WhatsApp Business prompt, carried on-// message.received. Baileys only. Not populated on the REST chat-history route.-type MessageButtonChoice struct {- ID string `json:"id"`- Text string `json:"text"`-}-// MessageCall is the call block on a live history message, present on call messages only.type MessageCall struct {Video bool `json:"video"`diff --git a/sdk/python/openwa/types.py b/sdk/python/openwa/types.pyindex f6bb9e5a7..eef9a4b1e 100644--- a/sdk/python/openwa/types.py+++ b/sdk/python/openwa/types.py@@ -559,25 +559,6 @@ class MessageProduct(TypedDict):businessOwnerJid: NotRequired[str]-class MessageButton(TypedDict):- """Button/list reply block on ``message.received`` when the sender tapped a WhatsApp Business- control. Baileys only; ``id`` is the stable handle, ``text`` the visible label when present.- Not populated on the REST chat-history route.- """-- id: str- text: NotRequired[str]---class MessageButtonChoice(TypedDict):- """One clickable choice on an inbound WhatsApp Business prompt (buttons or list rows), carried- on ``message.received``. Baileys only. Not populated on the REST chat-history route.- """-- id: str- text: str--class MessageContact(TypedDict, total=False):"""Sender contact block. History carries ``pushName`` only; the richer fields arrive on``message.received`` when ``WEBHOOK_CONTACT_DETAILS`` is enabled."""diff --git a/src/engine/adapters/baileys-click-button.spec.ts b/src/engine/adapters/baileys-click-button.spec.tsindex 6fa3e57d3..d422ca45c 100644--- a/src/engine/adapters/baileys-click-button.spec.ts+++ b/src/engine/adapters/baileys-click-button.spec.ts@@ -85,6 +85,7 @@ function makeMessaging(stored: unknown = PROMPT, opts: { ephemeralExpiration?: n} as never),getStoredMessage,putStoredMessage,+ rememberOwnSend: () => undefined,recordLidMapping: () => undefined,getOnMessageCreate: () => undefined,mapMessage: () => Promise.resolve({} as never),diff --git a/src/engine/adapters/whatsapp-web-js.adapter.ts b/src/engine/adapters/whatsapp-web-js.adapter.tsindex dfb10cf57..11fe708f6 100644--- a/src/engine/adapters/whatsapp-web-js.adapter.ts+++ b/src/engine/adapters/whatsapp-web-js.adapter.ts@@ -730,12 +730,9 @@ export class WhatsAppWebJsAdapter extends EventEmitter implements IWhatsAppEnginreturn this.messaging.votePoll(chatId, pollMessageId, options);}- clickButton(- _chatId: string,- _messageId: string,- _buttonId: string,- _text?: string,- ): Promise<MessageResult> {+ // whatsapp-web.js has no interactive button-reply send path; the parameters are not named so the+ // method reads as the 501 it is, and TypeScript accepts the narrower signature for the interface.+ clickButton(): Promise<MessageResult> {throw new EngineNotSupportedError('clickButton');}diff --git a/src/modules/message/message-send.service.spec.ts b/src/modules/message/message-send.service.spec.tsindex 0c79fd9cd..cafc380fa 100644--- a/src/modules/message/message-send.service.spec.ts+++ b/src/modules/message/message-send.service.spec.ts@@ -1010,30 +1010,24 @@ describe('MessageSendService', () => {});expect(mockEngine.clickButton).toHaveBeenCalledWith('[email protected]', 'PROMPT-1', 'yes', undefined);- expect(repository.create).toHaveBeenCalledWith(- expect.objectContaining({- body: 'yes',- type: 'text',- status: MessageStatus.PENDING,- metadata: expect.objectContaining({- button: { id: 'yes', text: undefined },- quotedMessage: { id: 'PROMPT-1', body: '' },- }),- }),- );- expect(repository.save).toHaveBeenLastCalledWith(- expect.objectContaining({- body: 'Sim',- status: MessageStatus.SENT,- metadata: expect.objectContaining({- button: { id: 'yes', text: 'Sim' },- }),- }),- );+ type Row = { body?: string; type?: string; status?: MessageStatus; metadata?: Record<string, unknown> };+ // Partial<Repository> hides the jest.Mock behind the overloaded signature, so the calls are read+ // through a structural cast rather than through `.mock` on the typed method.+ const create = repository.create as unknown as { mock: { calls: [Row][] } };+ const created = create.mock.calls[0][0];+ expect(created).toMatchObject({ body: 'yes', type: 'text', status: MessageStatus.PENDING });+ expect(created.metadata).toMatchObject({+ button: { id: 'yes', text: undefined },+ quotedMessage: { id: 'PROMPT-1', body: '' },+ });+ const save = repository.save as unknown as { mock: { calls: [Row][] } };+ const saved = save.mock.calls[save.mock.calls.length - 1][0];+ expect(saved).toMatchObject({ body: 'Sim', status: MessageStatus.SENT });+ expect(saved.metadata).toMatchObject({ button: { id: 'yes', text: 'Sim' } });});it('routes an engine refusal through failSend so the pending row is marked failed', async () => {- (mockEngine.clickButton as jest.Mock).mockRejectedValueOnce(+ mockEngine.clickButton.mockRejectedValueOnce(new BadRequestException('message PROMPT-1 is not a WhatsApp Business button/list prompt that can be clicked'),);