Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

feat(webhook): report WhatsApp event RSVPs as event.response (Baileys) (#1788)

Jesus Lazo Quevedoe9656853d070
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cbfde2265..9acfefae9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Expose caller-supplied send idempotency keys in all five SDKs.
- Add optional 24-hour idempotency keys to twelve single-recipient send routes.
- Add opt-in archive-only chat media with dashboard previews.
+- Report RSVPs to WhatsApp events as an `event.response` webhook and WebSocket event on Baileys (#1788, thanks @jelasus).
### Changed
diff --git a/dashboard/src/i18n/locales/ar.json b/dashboard/src/i18n/locales/ar.json
index e8dd14770..f4ff7542f 100644
--- a/dashboard/src/i18n/locales/ar.json
+++ b/dashboard/src/i18n/locales/ar.json
@@ -554,6 +554,7 @@
"session.reconnect_loop": "عند استمرار فشل إعادة اتصال جلسة",
"session.restriction": "عندما يقيّد WhatsApp الحساب أو يرفع قيدًا عنه",
"presence.update": "عندما تصبح محادثة مشترك فيها متصلة أو تكتب أو تغادر",
+ "event.response": "عندما يرد ضيف على دعوة حدث في واتساب (سأحضر، لن أحضر، ربما)",
"group.join": "عند انضمام مشاركين إلى مجموعة أو إضافتهم إليها",
"group.leave": "عند مغادرة مشاركين مجموعة أو إزالتهم منها",
"group.update": "عند تغيّر اسم مجموعة أو وصفها أو إعداداتها",
diff --git a/dashboard/src/i18n/locales/de.json b/dashboard/src/i18n/locales/de.json
index dbc30a16f..bce9fb1bb 100644
--- a/dashboard/src/i18n/locales/de.json
+++ b/dashboard/src/i18n/locales/de.json
@@ -529,6 +529,7 @@
"session.reconnect_loop": "Wenn eine Sitzung wiederholt nicht neu verbinden kann",
"session.restriction": "Wenn WhatsApp das Konto einschränkt oder eine Einschränkung aufhebt",
"presence.update": "Wenn ein abonnierter Chat online geht, tippt oder offline geht",
+ "event.response": "Wenn ein Gast auf eine WhatsApp-Veranstaltung antwortet (Zusage, Absage, Vielleicht)",
"group.join": "Wenn Teilnehmer einer Gruppe beitreten oder hinzugefügt werden",
"group.leave": "Wenn Teilnehmer eine Gruppe verlassen oder entfernt werden",
"group.update": "Wenn sich Name, Beschreibung oder Einstellungen einer Gruppe ändern",
diff --git a/dashboard/src/i18n/locales/en.json b/dashboard/src/i18n/locales/en.json
index 511921d0e..0250ed9ec 100644
--- a/dashboard/src/i18n/locales/en.json
+++ b/dashboard/src/i18n/locales/en.json
@@ -529,6 +529,7 @@
"session.reconnect_loop": "When a session keeps failing to reconnect",
"session.restriction": "When WhatsApp restricts the account or lifts a restriction",
"presence.update": "When a subscribed chat comes online, types or goes offline",
+ "event.response": "When a guest answers a WhatsApp event invitation (going, not going, maybe)",
"group.join": "When participants join or are added to a group",
"group.leave": "When participants leave or are removed from a group",
"group.update": "When a group's name, description or settings change",
diff --git a/dashboard/src/i18n/locales/es.json b/dashboard/src/i18n/locales/es.json
index efcb31733..d68782cec 100644
--- a/dashboard/src/i18n/locales/es.json
+++ b/dashboard/src/i18n/locales/es.json
@@ -535,6 +535,7 @@
"session.reconnect_loop": "Cuando una sesión sigue sin poder reconectarse",
"session.restriction": "Cuando WhatsApp restringe la cuenta o levanta una restricción",
"presence.update": "Cuando un chat suscrito se conecta, escribe o se desconecta",
+ "event.response": "Cuando un invitado responde a un evento de WhatsApp (asistirá, no asistirá, quizás)",
"group.join": "Cuando participantes se unen a un grupo o son añadidos",
"group.leave": "Cuando participantes salen de un grupo o son eliminados",
"group.update": "Cuando cambian el nombre, la descripción o los ajustes de un grupo",
diff --git a/dashboard/src/i18n/locales/fr.json b/dashboard/src/i18n/locales/fr.json
index 4ee7d12e1..d44824233 100644
--- a/dashboard/src/i18n/locales/fr.json
+++ b/dashboard/src/i18n/locales/fr.json
@@ -535,6 +535,7 @@
"session.reconnect_loop": "Lorsqu'une session échoue à se reconnecter à plusieurs reprises",
"session.restriction": "Lorsque WhatsApp restreint le compte ou lève une restriction",
"presence.update": "Lorsqu'un chat suivi passe en ligne, écrit ou se déconnecte",
+ "event.response": "Lorsqu'un invité répond à un événement WhatsApp (participe, ne participe pas, peut-être)",
"group.join": "Lorsque des participants rejoignent un groupe ou y sont ajoutés",
"group.leave": "Lorsque des participants quittent un groupe ou en sont retirés",
"group.update": "Lorsque le nom, la description ou les paramètres d'un groupe changent",
diff --git a/dashboard/src/i18n/locales/he.json b/dashboard/src/i18n/locales/he.json
index eecb53b79..df7d35dcb 100644
--- a/dashboard/src/i18n/locales/he.json
+++ b/dashboard/src/i18n/locales/he.json
@@ -542,6 +542,7 @@
"session.reconnect_loop": "כאשר Session נכשל שוב ושוב בהתחברות מחדש",
"session.restriction": "כאשר WhatsApp מגביל את החשבון או מסיר הגבלה",
"presence.update": "כאשר צ'אט במעקב מתחבר, מקליד או מתנתק",
+ "event.response": "כאשר אורח עונה להזמנה לאירוע בוואטסאפ (מגיע, לא מגיע, אולי)",
"group.join": "כאשר משתתפים מצטרפים לקבוצה או מתווספים אליה",
"group.leave": "כאשר משתתפים עוזבים קבוצה או מוסרים ממנה",
"group.update": "כאשר השם, התיאור או ההגדרות של קבוצה משתנים",
diff --git a/dashboard/src/i18n/locales/hi.json b/dashboard/src/i18n/locales/hi.json
index 575869917..a34dabb69 100644
--- a/dashboard/src/i18n/locales/hi.json
+++ b/dashboard/src/i18n/locales/hi.json
@@ -529,6 +529,7 @@
"session.reconnect_loop": "जब कोई सत्र बार-बार फिर से कनेक्ट होने में विफल होता है",
"session.restriction": "जब WhatsApp खाते को प्रतिबंधित करता है या प्रतिबंध हटाता है",
"presence.update": "जब सब्सक्राइब की गई चैट ऑनलाइन आती है, टाइप करती है या ऑफ़लाइन जाती है",
+ "event.response": "जब कोई मेहमान WhatsApp इवेंट के निमंत्रण का जवाब देता है (आ रहे हैं, नहीं आ रहे, शायद)",
"group.join": "जब प्रतिभागी समूह में शामिल होते हैं या जोड़े जाते हैं",
"group.leave": "जब प्रतिभागी समूह छोड़ते हैं या हटाए जाते हैं",
"group.update": "जब किसी समूह का नाम, विवरण या सेटिंग्स बदलती हैं",
diff --git a/dashboard/src/i18n/locales/id.json b/dashboard/src/i18n/locales/id.json
index cced742f9..44692c6c1 100644
--- a/dashboard/src/i18n/locales/id.json
+++ b/dashboard/src/i18n/locales/id.json
@@ -529,6 +529,7 @@
"session.reconnect_loop": "Saat sesi terus gagal terhubung kembali",
"session.restriction": "Saat WhatsApp membatasi akun atau mencabut pembatasan",
"presence.update": "Saat obrolan yang dilanggani online, mengetik atau offline",
+ "event.response": "Saat tamu menjawab undangan acara WhatsApp (hadir, tidak hadir, mungkin)",
"group.join": "Saat peserta bergabung atau ditambahkan ke grup",
"group.leave": "Saat peserta keluar atau dikeluarkan dari grup",
"group.update": "Saat nama, deskripsi atau pengaturan grup berubah",
diff --git a/dashboard/src/i18n/locales/it.json b/dashboard/src/i18n/locales/it.json
index 679173aac..99b87c4e7 100644
--- a/dashboard/src/i18n/locales/it.json
+++ b/dashboard/src/i18n/locales/it.json
@@ -535,6 +535,7 @@
"session.reconnect_loop": "Quando una sessione continua a non riuscire a riconnettersi",
"session.restriction": "Quando WhatsApp limita l'account o rimuove una limitazione",
"presence.update": "Quando una chat seguita va online, scrive o va offline",
+ "event.response": "Quando un invitato risponde a un evento WhatsApp (partecipa, non partecipa, forse)",
"group.join": "Quando dei partecipanti entrano in un gruppo o vengono aggiunti",
"group.leave": "Quando dei partecipanti lasciano un gruppo o vengono rimossi",
"group.update": "Quando cambiano il nome, la descrizione o le impostazioni di un gruppo",
diff --git a/dashboard/src/i18n/locales/ko.json b/dashboard/src/i18n/locales/ko.json
index 479961fb1..b47d469ee 100644
--- a/dashboard/src/i18n/locales/ko.json
+++ b/dashboard/src/i18n/locales/ko.json
@@ -529,6 +529,7 @@
"session.reconnect_loop": "세션 재연결이 계속 실패할 때",
"session.restriction": "WhatsApp이 계정을 제한하거나 제한을 해제했을 때",
"presence.update": "구독한 채팅이 온라인이 되거나 입력 중이거나 오프라인이 되었을 때",
+ "event.response": "게스트가 WhatsApp 이벤트 초대에 응답했을 때 (참석, 불참, 미정)",
"group.join": "참여자가 그룹에 참여하거나 추가되었을 때",
"group.leave": "참여자가 그룹을 나가거나 내보내졌을 때",
"group.update": "그룹 이름, 설명 또는 설정이 바뀌었을 때",
diff --git a/dashboard/src/i18n/locales/pt-BR.json b/dashboard/src/i18n/locales/pt-BR.json
index 155a70407..d4fc781ff 100644
--- a/dashboard/src/i18n/locales/pt-BR.json
+++ b/dashboard/src/i18n/locales/pt-BR.json
@@ -535,6 +535,7 @@
"session.reconnect_loop": "Quando uma sessão continua sem conseguir se reconectar",
"session.restriction": "Quando o WhatsApp restringe a conta ou remove uma restrição",
"presence.update": "Quando um chat inscrito fica online, digita ou fica offline",
+ "event.response": "Quando um convidado responde a um evento do WhatsApp (vai, não vai, talvez)",
"group.join": "Quando participantes entram em um grupo ou são adicionados",
"group.leave": "Quando participantes saem de um grupo ou são removidos",
"group.update": "Quando o nome, a descrição ou as configurações de um grupo mudam",
diff --git a/dashboard/src/i18n/locales/te.json b/dashboard/src/i18n/locales/te.json
index 34823975f..58a2a823b 100644
--- a/dashboard/src/i18n/locales/te.json
+++ b/dashboard/src/i18n/locales/te.json
@@ -529,6 +529,7 @@
"session.reconnect_loop": "సెషన్ మళ్లీ కనెక్ట్ కావడంలో పదేపదే విఫలమైనప్పుడు",
"session.restriction": "WhatsApp ఖాతాను పరిమితం చేసినప్పుడు లేదా పరిమితిని తొలగించినప్పుడు",
"presence.update": "సబ్‌స్క్రైబ్ చేసిన చాట్ ఆన్‌లైన్‌కి వచ్చినప్పుడు, టైప్ చేస్తున్నప్పుడు లేదా ఆఫ్‌లైన్‌కి వెళ్ళినప్పుడు",
+ "event.response": "అతిథి WhatsApp ఈవెంట్ ఆహ్వానానికి స్పందించినప్పుడు (వస్తున్నారు, రావడం లేదు, బహుశా)",
"group.join": "సభ్యులు గ్రూప్‌లో చేరినప్పుడు లేదా జోడించబడినప్పుడు",
"group.leave": "సభ్యులు గ్రూప్ నుండి నిష్క్రమించినప్పుడు లేదా తొలగించబడినప్పుడు",
"group.update": "గ్రూప్ పేరు, వివరణ లేదా సెట్టింగ్‌లు మారినప్పుడు",
diff --git a/dashboard/src/i18n/locales/tr.json b/dashboard/src/i18n/locales/tr.json
index 1f8043cd1..2a0c12455 100644
--- a/dashboard/src/i18n/locales/tr.json
+++ b/dashboard/src/i18n/locales/tr.json
@@ -529,6 +529,7 @@
"session.reconnect_loop": "Bir oturum yeniden bağlanmayı sürekli başaramadığında",
"session.restriction": "WhatsApp hesabı kısıtladığında veya bir kısıtlamayı kaldırdığında",
"presence.update": "Abone olunan bir sohbet çevrimiçi olduğunda, yazdığında veya çevrimdışı olduğunda",
+ "event.response": "Bir davetli bir WhatsApp etkinliğine yanıt verdiğinde (katılıyor, katılmıyor, belki)",
"group.join": "Katılımcılar bir gruba katıldığında veya eklendiğinde",
"group.leave": "Katılımcılar bir gruptan ayrıldığında veya çıkarıldığında",
"group.update": "Bir grubun adı, açıklaması veya ayarları değiştiğinde",
diff --git a/dashboard/src/i18n/locales/zh-CN.json b/dashboard/src/i18n/locales/zh-CN.json
index 4cd71ee55..1605d6125 100644
--- a/dashboard/src/i18n/locales/zh-CN.json
+++ b/dashboard/src/i18n/locales/zh-CN.json
@@ -529,6 +529,7 @@
"session.reconnect_loop": "会话反复重连失败时",
"session.restriction": "WhatsApp 限制账号或解除限制时",
"presence.update": "已订阅的聊天上线、正在输入或下线时",
+ "event.response": "嘉宾回复 WhatsApp 活动邀请时(参加、不参加、可能参加)",
"group.join": "有成员加入或被添加到群组时",
"group.leave": "有成员退出或被移出群组时",
"group.update": "群组名称、描述或设置变化时",
diff --git a/dashboard/src/i18n/locales/zh-HK.json b/dashboard/src/i18n/locales/zh-HK.json
index 96e3412a9..d99a80c3a 100644
--- a/dashboard/src/i18n/locales/zh-HK.json
+++ b/dashboard/src/i18n/locales/zh-HK.json
@@ -529,6 +529,7 @@
"session.reconnect_loop": "工作階段反覆重新連線失敗時",
"session.restriction": "WhatsApp 限制帳戶或解除限制時",
"presence.update": "已訂閱的聊天上線、正在輸入或離線時",
+ "event.response": "嘉賓回覆 WhatsApp 活動邀請時(參加、不參加、可能參加)",
"group.join": "有成員加入或被加入群組時",
"group.leave": "有成員退出或被移出群組時",
"group.update": "群組名稱、描述或設定變更時",
diff --git a/dashboard/src/utils/webhookEvents.ts b/dashboard/src/utils/webhookEvents.ts
index 405d7e088..87212b261 100644
--- a/dashboard/src/utils/webhookEvents.ts
+++ b/dashboard/src/utils/webhookEvents.ts
@@ -17,6 +17,7 @@ export const availableEventNames = [
'session.reconnect_loop',
'session.restriction',
'presence.update',
+ 'event.response',
'group.join',
'group.leave',
'group.update',
diff --git a/docs/04-security-design.md b/docs/04-security-design.md
index 41ec9c25f..4e19c89fa 100644
--- a/docs/04-security-design.md
+++ b/docs/04-security-design.md
@@ -318,7 +318,7 @@ export class CreateWebhookDto {
@IsArray()
@ArrayMinSize(1)
// The full WEBHOOK_EVENTS catalog (message.*, status.received, session.*, presence.update,
- // group.*, call.*) plus '*' for subscribe-all.
+ // event.response, group.*, call.*) plus '*' for subscribe-all.
@IsIn([...WEBHOOK_EVENTS, '*'], { each: true })
events?: string[];
}
diff --git a/docs/05-database-design.md b/docs/05-database-design.md
index 5542ad27c..335006ce5 100644
--- a/docs/05-database-design.md
+++ b/docs/05-database-design.md
@@ -476,6 +476,7 @@ CREATE TABLE webhooks (
"session.reconnect_loop",
"session.restriction",
"presence.update",
+ "event.response",
"group.join",
"group.leave",
"group.update",
diff --git a/docs/06-api-specification.md b/docs/06-api-specification.md
index 0553d3752..a2aeac38a 100644
--- a/docs/06-api-specification.md
+++ b/docs/06-api-specification.md
@@ -4591,7 +4591,7 @@ Webhooks are configured per session and managed under `/api/sessions/:sessionId/
Two fields — `secret` and `headers` — are **write-only**: they are accepted on create/update but are never returned by any webhook route (the response DTO has no `@Expose` for them, so `fromEntity` drops them). `GET /api/infra/export-data` also omits both from its `webhooks` rows, so a backup no longer carries webhook credentials — a restored webhook comes back unsigned (`secret` null, `headers` `{}`) until you set them again. The `secret` is used to compute the `X-OpenWA-Signature: sha256=<hex>` HMAC-SHA256 header on deliveries.
-The `events` array accepts these members plus the `*` wildcard: `message.received`, `message.sent`, `message.ack`, `message.failed`, `message.revoked`, `message.reaction`, `message.edited`, `session.status`, `session.qr`, `session.authenticated`, `session.disconnected`, `session.reconnect_loop`, `session.restriction`, `presence.update`, `call.accepted`, `call.rejected`, `call.missed`, `group.join`, `group.leave`, `group.update`, `group.join_request`, `call.received`, `status.received`. All of them are actively dispatched by at least one engine — none is a reserved placeholder. Four are **Baileys only**, because whatsapp-web.js produces no callback behind them: `presence.update` (its prerequisite `POST .../presence/subscribe` answers `501` there, so this one announces itself) and `call.accepted` / `call.rejected` / `call.missed` (whatsapp-web.js has no call-outcome callback, so these three are accepted on subscribe and then simply never fire). `call.received` is dispatched by both engines but is not reliable on whatsapp-web.js: it fired there in a live test on 2026-09-17 and did not in one on 2026-08-10. See the per-event catalog below for engine scope.
+The `events` array accepts these members plus the `*` wildcard: `message.received`, `message.sent`, `message.ack`, `message.failed`, `message.revoked`, `message.reaction`, `message.edited`, `session.status`, `session.qr`, `session.authenticated`, `session.disconnected`, `session.reconnect_loop`, `session.restriction`, `presence.update`, `event.response`, `call.accepted`, `call.rejected`, `call.missed`, `group.join`, `group.leave`, `group.update`, `group.join_request`, `call.received`, `status.received`. All of them are actively dispatched by at least one engine — none is a reserved placeholder. Five are **Baileys only**, because whatsapp-web.js produces no callback behind them: `presence.update` (its prerequisite `POST .../presence/subscribe` answers `501` there, so this one announces itself), `event.response` (accepted on subscribe and never fired) and `call.accepted` / `call.rejected` / `call.missed` (whatsapp-web.js has no call-outcome callback, so these three are accepted on subscribe and then simply never fire). `call.received` is dispatched by both engines but is not reliable on whatsapp-web.js: it fired there in a live test on 2026-09-17 and did not in one on 2026-08-10. See the per-event catalog below for engine scope.
#### GET /api/sessions/:sessionId/webhooks
@@ -7127,6 +7127,7 @@ session.authenticated
session.disconnected
session.restriction
presence.update
+event.response
group.join
group.leave
group.update
@@ -7213,6 +7214,7 @@ These are the events OpenWA actually emits. A webhook is registered with an `eve
| `session.disconnected` | The session disconnects on the engine or WhatsApp side (drop, conflict, or a phone-initiated unlink). Not fired for API-initiated stop/logout/delete — those are acknowledged by the API response and the `session.status` transition | `{ sessionId, reason }` |
| `session.reconnect_loop` | Every 5th consecutive reconnect attempt is scheduled (attempt 5, 10, 15, …) — the session is failing to come back up | `{ sessionId, attempts, nextDelayMs }` |
| `presence.update` | A subscribed chat's presence changed — someone came online, started typing, or stopped. Only actual CHANGES are dispatched: WhatsApp repeats itself freely, and every repeat would otherwise be a delivery | `{ sessionId, chatId, participants: [{ id, state, lastSeen? }], groupOnlineCount? }` — `state` is `available`/`unavailable`/`composing`/`recording`/`paused`; `lastSeen` is epoch **seconds** and absent when the contact hides it. Requires `POST .../presence/subscribe` first, and Baileys — whatsapp-web.js cannot observe presence |
+| `event.response` | A guest answered a WhatsApp event invitation (going, not going, maybe). **Baileys only**; see the payload note below | `{ sessionId, eventMessageId, chatId, responderId, contact?, fromMe, response, extraGuestCount?, eventName?, responseMessageId, timestamp }`. `response` is `going`/`not_going`/`maybe`/`unknown`; `timestamp` is epoch **seconds** on the guest's clock. Order a guest's answers by `timestamp`, not by delivery |
| `session.restriction` | WhatsApp places a restriction on the account, or lifts one. Deduped: an unchanged restriction is not re-announced, and a lift is only sent when one was in force | `{ sessionId, active, kind, code, expiresAt }` — `active` is `false` for a lift and `kind`/`code` then describe the restriction that ended; `expiresAt` is an ISO timestamp or `null`. See `restriction` on the session response for the `kind` values |
| `session.status` | The session status transitions | `{ sessionId, status }` where `status` is one of `created` / `initializing` / `qr_ready` / `authenticating` / `ready` / `disconnected` / `action_required` / `failed` |
| `group.join` | Participant(s) are added to or join a group this session is in | `{ groupId, actorId?, participantIds, timestamp }`. `actorId` is the admin/inviter when known. **Baileys**: a session added to or joining a group reports only its own id in `participantIds` (members added with it are not listed) |
@@ -7233,6 +7235,28 @@ These are the events OpenWA actually emits. A webhook is registered with an `eve
> **Large media is not inlined into webhook payloads.** A `media` blob whose decoded size exceeds `WEBHOOK_MEDIA_INLINE_MAX_BYTES` (default **1 MiB**; `0` = never inline) is replaced — before the payload is fanned out to your webhook — with the marker form `media: { mimetype, filename?, omitted: true, sizeBytes }`, the same shape the engine emits for capped inbound media. Media at or under the cap stays inline unchanged. Additionally, if the serialized body still exceeds `WEBHOOK_MAX_PAYLOAD_BYTES` (default **1 MiB**) after `webhook:before` hooks ran, any remaining inline media is shed the same way so the event is still delivered; only a payload that is over budget _without_ inline media is dropped (recorded in `GET /api/webhooks/delivery-failures`). Because shedding happens before enqueue, queued and failed BullMQ jobs in Redis never carry the blob either — failed-job retention is bounded by the queue's `removeOnComplete`/`removeOnFail` windows (1h/1000 completed, 24h/5000 failed). The two limits compound: `WEBHOOK_MAX_PAYLOAD_BYTES` is measured on the serialized JSON body after `WEBHOOK_MEDIA_INLINE_MAX_BYTES` has been applied, and base64 inflates media by a third, so at the defaults media above roughly **768 KiB** reaches your webhook as the omitted marker. To inline larger media, raise both together and keep the payload limit at least 4/3 of the inline limit plus room for the rest of the event (for example `5242880` inline with `7340032` payload). The **WebSocket** `message.received` / `message.sent` events apply only the inline cap, with the same marker: an over-cap blob is never broadcast to subscribed sockets (or, with the Redis adapter enabled, replicated across every replica's pub/sub link). On either sink, media the engine downloaded stays retrievable from [`GET /api/sessions/:sessionId/messages/:chatId/:messageId/media`](#get-apisessionssessionidmessageschatidmessageidmedia), which returns `404` when nothing was stored.
+> **`event.response` reports RSVPs to WhatsApp events (Baileys only).** A WhatsApp event (the calendar-style invitation created from the attach menu, with "Going" / "Not going" / "Maybe" buttons) arrives as an ordinary `message.received` when it is posted. Each answer to it arrives as `event.response`:
+>
+> ```json
+> {
+> "sessionId": "8f3c2b1a-9d4e-4c7a-8b2f-1e6d5a4c3b2a",
+> "eventMessageId": "3EB0C767D26B8A3F1A2B",
+> "chatId": "[email protected]",
+> "responderId": "[email protected]",
+> "fromMe": false,
+> "response": "going",
+> "extraGuestCount": 1,
+> "eventName": "Game night",
+> "responseMessageId": "3EB0D1E2F3A4B5C6D7E8",
+> "timestamp": 1786000000,
+> "contact": { "name": "Ada Lovelace", "pushName": "Ada" }
+> }
+> ```
+>
+> `response` is one of `going`, `not_going`, `maybe` or `unknown`. A guest who changes their answer sends a new RSVP with a new `responseMessageId`, so the event with the latest `timestamp` per `responderId` is the current answer. Order by `timestamp` rather than by arrival: delivery order is not guaranteed (see the offline note below). `extraGuestCount` is present only when WhatsApp sends it, and `eventName` only when the event's creation message can still be read from the message store. `contact` names the responder like `message.received` names its sender: `name` from the account's addressbook, `pushName` from their own profile, each present only when known, and the whole field absent when neither is. It is read from the contacts the session already holds, with no WhatsApp lookup per answer, so a responder the session knows nothing about yet arrives without one.
+>
+> WhatsApp encrypts every RSVP with a key derived from the event creation message, so only answers to events **this session received and still holds in its message store** can be reported: an event posted before the number was linked, or one evicted past `BAILEYS_MESSAGE_STORE_LIMIT`, yields no `event.response`. This covers events in groups and in 1:1 chats, with one known gap: in a 1:1 chat, the other person's answer to an event they posted themselves cannot be decrypted (Baileys derives the event's creator from their side of the chat) and is not reported. Answers given while the session was offline are reported when WhatsApp replays them on reconnect, but Baileys merges the replayed updates per event, so several answers to one event given while offline, even from different guests, arrive as the last one only. whatsapp-web.js accepts the subscription and never fires the event.
+
> There is **no** `contact.update` event. `presence.update` is emitted only for chats you have subscribed to (see the presence-subscription endpoint); call outcomes are reported as `call.accepted`, `call.rejected` and `call.missed` alongside `call.received`.
> **Group-event timing caveat (Baileys).** Membership/metadata changes that occurred while a Baileys session was offline are replayed by WhatsApp on reconnect and are dispatched like live events — but the engine does not forward their original occurrence time, so they carry the **receipt time** as `timestamp`. Treat `group.*` payloads as change notifications rather than a precise clock; stale offline _calls_ are never emitted this way (they are filtered by the `offline` flag).
@@ -7311,6 +7335,7 @@ Every delivery includes:
- `call.accepted` / `call.rejected` / `call.missed`: `call_{sessionId}_{callId}_{outcome}` (each call ends once, so no `occurredAt` salt)
- `session.restriction`: `restr_{sessionId}_{kind}_{active}_{occurredAt}`
- `presence.update`: `pres_{sessionId}_{chatId}_{hash(participants)}_{occurredAt}`
+- `event.response`: `rsvp_{sessionId}_{responseMessageId}` (every answer is its own message with its own id, so no `occurredAt` salt)
- any other event (for example `status.received`): `evt_{event with . replaced by _}_{hash(data)}`
Recurring lifecycle events (and `message.reaction` / `message.edited` / `presence.update`) carry the same content across occurrences — the same phone on every reconnect, a constant disconnect reason, a re-applied emoji, or editing the same message multiple times — so they are salted with an `occurredAt` timestamp captured **once per dispatch and reused across that dispatch's retries**. This gives distinct occurrences distinct keys while keeping retries of one occurrence stable. Message keys are scoped by `sessionId` because WhatsApp message ids are unique per account, not globally.
diff --git a/docs/12-troubleshooting-faq.md b/docs/12-troubleshooting-faq.md
index 119f47108..0855cad6e 100644
--- a/docs/12-troubleshooting-faq.md
+++ b/docs/12-troubleshooting-faq.md
@@ -1446,6 +1446,7 @@ available_events:
- session.reconnect_loop # Every 5th consecutive reconnect attempt (payload: sessionId, attempts, nextDelayMs)
- session.restriction # WhatsApp restricted the account, or lifted it (payload: sessionId, active, kind, code, expiresAt)
- presence.update # A subscribed chat's presence changed (Baileys only; the subscribe route answers 501 on whatsapp-web.js; payload: sessionId, chatId, participants, groupOnlineCount)
+ - event.response # A guest answered a WhatsApp event invitation (Baileys only; payload: sessionId, eventMessageId, chatId, responderId, response, responseMessageId, timestamp)
- call.accepted # A ringing call was answered (Baileys only; payload: sessionId, callId, from, outcome, isVideo, isGroup, timestamp)
- call.rejected # A ringing call was declined (Baileys only)
- call.missed # A ringing call was never picked up (Baileys only)
diff --git a/docs/22-n8n-integration.md b/docs/22-n8n-integration.md
index 224ac35b7..d6d8add7a 100644
--- a/docs/22-n8n-integration.md
+++ b/docs/22-n8n-integration.md
@@ -90,6 +90,7 @@ Start workflows when WhatsApp events occur.
| `session.reconnect_loop` | Every 5th consecutive reconnect attempt | Stuck-session alerting |
| `session.restriction` | WhatsApp restricted the account, or lifted it | Pausing outreach while an account is limited |
| `presence.update` | A watched chat's online/typing state changed | Live agent hand-off, presence-aware routing |
+| `event.response` | A guest answered a WhatsApp event (Baileys) | RSVP and attendance tracking |
| `call.accepted` / `call.rejected` / `call.missed` | A ringing call ended — **Baileys only** | Missed-call follow-up, call logging |
| `group.join` | Participant(s) joined a group | Welcome messages |
| `group.leave` | Participant(s) left a group | Churn tracking |
diff --git a/openapi.json b/openapi.json
index 05b32b9be..fe6bc8d4f 100644
--- a/openapi.json
+++ b/openapi.json
@@ -19283,6 +19283,7 @@
"session.reconnect_loop",
"session.restriction",
"presence.update",
+ "event.response",
"group.join",
"group.leave",
"group.update",
@@ -19379,6 +19380,7 @@
"session.reconnect_loop",
"session.restriction",
"presence.update",
+ "event.response",
"group.join",
"group.leave",
"group.update",
@@ -19478,6 +19480,7 @@
"session.reconnect_loop",
"session.restriction",
"presence.update",
+ "event.response",
"group.join",
"group.leave",
"group.update",
diff --git a/sdk/go/client_test.go b/sdk/go/client_test.go
index 800a244f1..a1a80f2e2 100644
--- a/sdk/go/client_test.go
+++ b/sdk/go/client_test.go
@@ -1191,6 +1191,7 @@ func TestWebhookEventWireValues(t *testing.T) {
EventSessionReconnectLoop: "session.reconnect_loop",
EventSessionRestriction: "session.restriction",
EventPresenceUpdate: "presence.update",
+ EventEventResponse: "event.response",
EventCallAccepted: "call.accepted",
EventCallRejected: "call.rejected",
EventCallMissed: "call.missed",
diff --git a/sdk/go/types_webhook.go b/sdk/go/types_webhook.go
index 39f813bd1..02e4b062b 100644
--- a/sdk/go/types_webhook.go
+++ b/sdk/go/types_webhook.go
@@ -25,6 +25,7 @@ const (
EventSessionReconnectLoop WebhookEvent = "session.reconnect_loop"
EventSessionRestriction WebhookEvent = "session.restriction"
EventPresenceUpdate WebhookEvent = "presence.update"
+ EventEventResponse WebhookEvent = "event.response"
EventCallAccepted WebhookEvent = "call.accepted"
EventCallRejected WebhookEvent = "call.rejected"
EventCallMissed WebhookEvent = "call.missed"
diff --git a/sdk/java/src/main/java/com/rmyndharis/openwa/model/WebhookEvent.java b/sdk/java/src/main/java/com/rmyndharis/openwa/model/WebhookEvent.java
index 3ad8ddc18..264b81a16 100644
--- a/sdk/java/src/main/java/com/rmyndharis/openwa/model/WebhookEvent.java
+++ b/sdk/java/src/main/java/com/rmyndharis/openwa/model/WebhookEvent.java
@@ -36,6 +36,8 @@ public enum WebhookEvent {
SESSION_RESTRICTION,
@SerializedName("presence.update")
PRESENCE_UPDATE,
+ @SerializedName("event.response")
+ EVENT_RESPONSE,
@SerializedName("call.accepted")
CALL_ACCEPTED,
@SerializedName("call.rejected")
diff --git a/sdk/javascript/src/types.ts b/sdk/javascript/src/types.ts
index a7416ddf2..bea9d2a8f 100644
--- a/sdk/javascript/src/types.ts
+++ b/sdk/javascript/src/types.ts
@@ -942,6 +942,7 @@ export type WebhookEvent =
| 'session.reconnect_loop'
| 'session.restriction'
| 'presence.update'
+ | 'event.response'
| 'call.accepted'
| 'call.rejected'
| 'call.missed'
diff --git a/sdk/python/openwa/types.py b/sdk/python/openwa/types.py
index d5b016c5d..3de64121c 100644
--- a/sdk/python/openwa/types.py
+++ b/sdk/python/openwa/types.py
@@ -68,7 +68,7 @@ WebhookEvent = Literal[
"message.received", "message.sent", "message.ack", "message.failed", "message.revoked",
"message.reaction", "message.edited", "session.status", "session.qr", "session.authenticated",
"session.disconnected", "session.reconnect_loop", "session.restriction", "presence.update",
- "group.join", "group.leave", "group.update", "group.join_request",
+ "event.response", "group.join", "group.leave", "group.update", "group.join_request",
"call.received", "status.received",
"call.accepted", "call.rejected", "call.missed",
"*",
@@ -78,7 +78,7 @@ WebhookDeliveryEvent = Literal[
"message.received", "message.sent", "message.ack", "message.failed", "message.revoked",
"message.reaction", "message.edited", "session.status", "session.qr", "session.authenticated",
"session.disconnected", "session.reconnect_loop", "session.restriction", "presence.update",
- "group.join", "group.leave", "group.update", "group.join_request",
+ "event.response", "group.join", "group.leave", "group.update", "group.join_request",
"call.received", "status.received",
"call.accepted", "call.rejected", "call.missed",
]
diff --git a/src/engine/adapters/baileys-events.spec.ts b/src/engine/adapters/baileys-events.spec.ts
index da9588c5f..006093324 100644
--- a/src/engine/adapters/baileys-events.spec.ts
+++ b/src/engine/adapters/baileys-events.spec.ts
@@ -3,6 +3,7 @@ import { createLogger } from '../../common/services/logger.service';
import { ConcurrencyLimiter } from '../../common/utils/concurrency-limiter';
import { inboundMediaConcurrency } from './inbound-media-cap';
import type { WAMessage, WASocket } from '@whiskeysockets/baileys';
+import type { Contact, EventResponseEvent } from '../interfaces/whatsapp-engine.interface';
/**
* `downloadMediaMessage` is a jest mock, not a silent no-op: the real-download branch
@@ -118,6 +119,8 @@ function makeHost(overrides: Partial<BaileysEventsHost> = {}): BaileysEventsHost
getOnMessageReaction: () => undefined,
getOnMessageAck: () => undefined,
getOnGroupEvent: () => undefined,
+ getOnEventResponse: () => undefined,
+ findContact: () => null,
getOnCall: () => undefined,
getOnPresenceUpdate: () => undefined,
getOnCallOutcome: () => undefined,
@@ -630,3 +633,165 @@ describe('BaileysEvents record of messages deleted for everyone', () => {
expect(events.wasDeletedForEveryone(`M${limit}`)).toBe(true);
});
});
+
+describe('BaileysEvents event RSVPs (event.response)', () => {
+ const group = '[email protected]';
+ const eventKey = { id: 'EVT1', remoteJid: group };
+ const flush = (): Promise<void> => new Promise(resolve => setImmediate(resolve));
+
+ function rsvp(overrides: Record<string, unknown> = {}): Record<string, unknown> {
+ return {
+ eventResponseMessageKey: {
+ id: 'RSVP1',
+ remoteJid: group,
+ participant: '[email protected]',
+ fromMe: false,
+ },
+ senderTimestampMs: 1786000000123,
+ response: { response: 1, timestampMs: 1786000000123, extraGuestCount: 2 },
+ ...overrides,
+ };
+ }
+
+ it('reports a decrypted RSVP with the event name read from the stored creation message', async () => {
+ const onEventResponse = jest.fn();
+ const events = new BaileysEvents(
+ makeHost({
+ getOnEventResponse: () => onEventResponse,
+ getStoredMessage: () =>
+ Promise.resolve({ key: eventKey, message: { eventMessage: { name: 'Game night' } } } as unknown as WAMessage),
+ }),
+ );
+
+ events.handleMessagesUpdate([{ key: eventKey, update: { eventResponses: [rsvp()] } }] as never);
+ await flush();
+
+ expect(onEventResponse).toHaveBeenCalledTimes(1);
+ expect(onEventResponse).toHaveBeenCalledWith({
+ eventMessageId: 'EVT1',
+ chatId: group,
+ responderId: '[email protected]',
+ fromMe: false,
+ response: 'going',
+ extraGuestCount: 2,
+ eventName: 'Game night',
+ responseMessageId: 'RSVP1',
+ timestamp: 1786000000,
+ });
+ });
+
+ it.each([
+ [2, 'not_going'],
+ [3, 'maybe'],
+ [0, 'unknown'],
+ [undefined, 'unknown'],
+ ])('maps response type %p to %p', async (type, expected) => {
+ const onEventResponse = jest.fn();
+ const events = new BaileysEvents(makeHost({ getOnEventResponse: () => onEventResponse }));
+
+ events.handleMessagesUpdate([
+ { key: eventKey, update: { eventResponses: [rsvp({ response: { response: type } })] } },
+ ] as never);
+ await flush();
+
+ expect(onEventResponse).toHaveBeenCalledWith(expect.objectContaining({ response: expected }));
+ expect((onEventResponse.mock.calls as unknown[][])[0][0]).not.toHaveProperty('extraGuestCount');
+ });
+
+ it("attributes the account's own 1:1 answer to the account", async () => {
+ const onEventResponse = jest.fn();
+ const events = new BaileysEvents(makeHost({ getOnEventResponse: () => onEventResponse }));
+ const chat = '[email protected]';
+
+ events.handleMessagesUpdate([
+ {
+ key: { id: 'EVT2', remoteJid: chat },
+ update: { eventResponses: [rsvp({ eventResponseMessageKey: { id: 'RSVP2', remoteJid: chat, fromMe: true } })] },
+ },
+ ] as never);
+ await flush();
+
+ expect(onEventResponse).toHaveBeenCalledWith(
+ expect.objectContaining({ chatId: chat, responderId: '[email protected]', fromMe: true }),
+ );
+ });
+
+ it("takes a guest's 1:1 answer to the account's own event from the RSVP, not the guest's view of the event", async () => {
+ const onEventResponse = jest.fn();
+ const events = new BaileysEvents(makeHost({ getOnEventResponse: () => onEventResponse }));
+ const guest = '[email protected]';
+
+ // Baileys passes the creation key on as the guest sent it: its remoteJid is this account.
+ events.handleMessagesUpdate([
+ {
+ key: { id: 'EVT3', remoteJid: '[email protected]', fromMe: false },
+ update: {
+ eventResponses: [rsvp({ eventResponseMessageKey: { id: 'RSVP3', remoteJid: guest, fromMe: false } })],
+ },
+ },
+ ] as never);
+ await flush();
+
+ expect(onEventResponse).toHaveBeenCalledWith(
+ expect.objectContaining({ eventMessageId: 'EVT3', chatId: guest, responderId: guest, fromMe: false }),
+ );
+ });
+
+ it("names the responder from the session's contact store", async () => {
+ const onEventResponse = jest.fn();
+ const findContact = jest.fn((id: string) =>
+ id === '[email protected]' ? ({ id, name: 'Ana Pérez', pushName: 'Ana' } as Contact) : null,
+ );
+ const events = new BaileysEvents(makeHost({ getOnEventResponse: () => onEventResponse, findContact }));
+
+ events.handleMessagesUpdate([
+ { key: eventKey, update: { eventResponses: [rsvp()] } },
+ {
+ key: eventKey,
+ update: {
+ eventResponses: [
+ rsvp({ eventResponseMessageKey: { id: 'RSVP4', remoteJid: group, participant: '[email protected]' } }),
+ ],
+ },
+ },
+ ] as never);
+ await flush();
+
+ const byId = (id: string) =>
+ (onEventResponse.mock.calls as EventResponseEvent[][]).map(([e]) => e).find(e => e.responseMessageId === id);
+ expect(byId('RSVP1')?.contact).toEqual({ name: 'Ana Pérez', pushName: 'Ana' });
+ expect(byId('RSVP4')).not.toHaveProperty('contact');
+ });
+
+ it('still reports the RSVP, without a name, when the store cannot be read', async () => {
+ const onEventResponse = jest.fn();
+ const events = new BaileysEvents(
+ makeHost({
+ getOnEventResponse: () => onEventResponse,
+ getStoredMessage: () => Promise.reject(new Error('database is locked')),
+ }),
+ );
+
+ events.handleMessagesUpdate([{ key: eventKey, update: { eventResponses: [rsvp()] } }] as never);
+ await flush();
+
+ expect(onEventResponse).toHaveBeenCalledTimes(1);
+ expect((onEventResponse.mock.calls as unknown[][])[0][0]).not.toHaveProperty('eventName');
+ });
+
+ it('keeps reporting acks next to RSVPs, and ignores an RSVP without its own key', async () => {
+ const onEventResponse = jest.fn();
+ const onMessageAck = jest.fn();
+ const events = new BaileysEvents(
+ makeHost({ getOnEventResponse: () => onEventResponse, getOnMessageAck: () => onMessageAck }),
+ );
+
+ events.handleMessagesUpdate([
+ { key: eventKey, update: { status: 3, eventResponses: [rsvp({ eventResponseMessageKey: null })] } },
+ ] as never);
+ await flush();
+
+ expect(onMessageAck).toHaveBeenCalledTimes(1);
+ expect(onEventResponse).not.toHaveBeenCalled();
+ });
+});
diff --git a/src/engine/adapters/baileys-events.ts b/src/engine/adapters/baileys-events.ts
index c49b4645c..e2d0ef2cf 100644
--- a/src/engine/adapters/baileys-events.ts
+++ b/src/engine/adapters/baileys-events.ts
@@ -1,8 +1,10 @@
import type * as BaileysLib from '@whiskeysockets/baileys';
import type { WACallEvent, WAMessage, WAMessageKey, WASocket } from '@whiskeysockets/baileys';
import {
+ Contact,
EditedMessage,
EngineEventCallbacks,
+ EventResponseEvent,
GroupEvent,
IncomingCallEvent,
InboundTicket,
@@ -26,6 +28,7 @@ import {
extractBaileysContext,
extractBaileysLocation,
isBaileysCatalogShare,
+ mapBaileysEventResponseType,
mapBaileysStatus,
setBaileysText,
} from './baileys-message-mapper';
@@ -236,6 +239,10 @@ export interface BaileysEventsHost {
getOnMessageAck(): EngineEventCallbacks['onMessageAck'];
/** The currently-registered onGroupEvent callback, if any (assigned at initialize()). */
getOnGroupEvent(): EngineEventCallbacks['onGroupEvent'];
+ /** The currently-registered onEventResponse callback, if any (assigned at initialize()). */
+ getOnEventResponse(): EngineEventCallbacks['onEventResponse'];
+ /** A contact from the session's own store, by any id dialect; no network read. */
+ findContact(contactId: string): Contact | null;
/** The currently-registered onCall callback, if any (assigned at initialize()). */
getOnCall(): EngineEventCallbacks['onCall'];
/** The currently-registered onPresenceUpdate callback, if any (assigned at initialize()). */
@@ -244,6 +251,23 @@ export interface BaileysEventsHost {
getOnCallOutcome(): EngineEventCallbacks['onCallOutcome'];
}
+/** The subset of a Baileys `messages.update` entry this adapter reads. */
+interface BaileysMessageUpdate {
+ key?: { id?: string | null; remoteJid?: string | null };
+ update?: { status?: number | null; eventResponses?: BaileysEventResponse[] | null };
+}
+
+/** A decrypted RSVP as Baileys re-emits it under `update.eventResponses`. */
+interface BaileysEventResponse {
+ eventResponseMessageKey?: WAMessageKey | null;
+ senderTimestampMs?: number | { toNumber(): number } | null;
+ response?: {
+ response?: number | null;
+ timestampMs?: number | { toNumber(): number } | null;
+ extraGuestCount?: number | null;
+ } | null;
+}
+
/** Every teardown clears the live-call map; counting those clears lets a reject in flight tell that its
* connection was torn down meanwhile. */
class LiveCallMap<V> extends Map<string, V> {
@@ -877,9 +901,7 @@ export class BaileysEvents {
return (isDelete && inGroup) || overlap(author(target), author(envelope));
}
- handleMessagesUpdate(
- updates: Array<{ key?: { id?: string | null; remoteJid?: string | null }; update?: { status?: number | null } }>,
- ): void {
+ handleMessagesUpdate(updates: BaileysMessageUpdate[]): void {
for (const u of updates) {
const status = mapBaileysStatus(u.update?.status);
if (status && u.key?.id) {
@@ -888,7 +910,67 @@ export class BaileysEvents {
const chatId = u.key.remoteJid ? this.host.toNeutralJid(u.key.remoteJid) : undefined;
this.host.getOnMessageAck()?.(u.key.id, status, chatId);
}
+ for (const rsvp of u.update?.eventResponses ?? []) {
+ void this.emitEventResponse(u.key, rsvp).catch(err =>
+ this.host.logger.warn('Failed to report an event response', {
+ msgId: u.key?.id,
+ error: err instanceof Error ? err.message : String(err),
+ }),
+ );
+ }
+ }
+ }
+
+ /**
+ * An RSVP to a WhatsApp event. Baileys decrypts it itself while processing the inbound
+ * `encEventResponseMessage` (whose upsert the live path drops as non-content): it reads the event
+ * creation message's `messageSecret` through the socket's getMessage, which this adapter backs
+ * with the message store, and re-emits the plaintext as a `messages.update` of the CREATION
+ * message's key. An RSVP to an event the store does not hold cannot be decrypted and never
+ * arrives here. Decryption authenticates the responder, since the key is derived from their jid.
+ */
+ private async emitEventResponse(eventKey: BaileysMessageUpdate['key'], rsvp: BaileysEventResponse): Promise<void> {
+ const callback = this.host.getOnEventResponse();
+ const envelope = rsvp.eventResponseMessageKey;
+ if (!callback || !eventKey?.id || !eventKey.remoteJid || !envelope?.id) return;
+ const fromMe = envelope.fromMe === true;
+ // The creation key is the guest's view of the event (in a 1:1 chat its remoteJid is this
+ // account), so the chat comes from the RSVP's own key, which Baileys has put on our side.
+ const chatJid = envelope.remoteJid ?? eventKey.remoteJid;
+ // Same rule as a reaction: a 1:1 key names the chat partner, so the account's own answer is
+ // attributed to the account; group keys carry the responder as `participant`.
+ const responder = envelope.participant ?? (fromMe ? this.host.normalizedSelfJid() : chatJid);
+ if (!responder) return;
+ const event: EventResponseEvent = {
+ eventMessageId: eventKey.id,
+ chatId: this.host.toNeutralJid(chatJid),
+ responderId: this.host.toNeutralJid(responder),
+ fromMe,
+ response: mapBaileysEventResponseType(rsvp.response?.response),
+ responseMessageId: envelope.id,
+ timestamp: this.toEditUnixSeconds(
+ rsvp.senderTimestampMs ?? rsvp.response?.timestampMs,
+ Math.floor(Date.now() / 1000),
+ ),
+ };
+ const guests = rsvp.response?.extraGuestCount;
+ if (typeof guests === 'number' && Number.isFinite(guests)) event.extraGuestCount = guests;
+ // Named from the session's own contact store, like the sender of message.received, so an
+ // attendance list can be built from the RSVPs alone without a network read per answer.
+ const known = this.host.findContact(responder);
+ if (known?.name || known?.pushName) {
+ event.contact = {
+ ...(known.name ? { name: known.name } : {}),
+ ...(known.pushName ? { pushName: known.pushName } : {}),
+ };
+ }
+ const stored = await this.readStoredMessage(eventKey.id, 'reading the event an RSVP answers');
+ if (stored?.message) {
+ const b = await this.host.loadLib();
+ const name = b.normalizeMessageContent(stored.message)?.eventMessage?.name;
+ if (name) event.eventName = name;
}
+ callback(event);
}
/**
diff --git a/src/engine/adapters/baileys-lifecycle.ts b/src/engine/adapters/baileys-lifecycle.ts
index 23850eb27..390913d16 100644
--- a/src/engine/adapters/baileys-lifecycle.ts
+++ b/src/engine/adapters/baileys-lifecycle.ts
@@ -27,7 +27,7 @@ import {
import { differentWaIds, type BaileysEvents } from './baileys-events';
import type { BaileysHistory } from './baileys-history';
import type { BaileysSessionStore } from './baileys-session-store';
-import { userPart } from '../identity/wa-id';
+import { chatKind, userPart } from '../identity/wa-id';
/** Linked-device identity shown in WhatsApp (Settings → Linked Devices). The OS platform is
* operator-configurable via BAILEYS_BROWSER_NAME; defaults to 'Ubuntu' because some accounts reject a
@@ -430,6 +430,20 @@ export class BaileysLifecycle {
if (!stored) {
return undefined;
}
+ // An RSVP to an event this account posted in a 1:1 chat names the event by its key as the guest
+ // sees it, so its remoteJid is this account. Baileys rewrites reaction and poll keys to our side
+ // but not event keys, so our own 1:1 message asked for under our own jid is that same chat.
+ const bare = (jid: string): string => `${userPart(jid)}@${jid.split('@')[1]}`;
+ const asked = key.remoteJid ? bare(key.remoteJid) : undefined;
+ const me = this.sock?.user;
+ const askedByGuest =
+ !!asked &&
+ stored.key.fromMe === true &&
+ chatKind(stored.key.remoteJid ?? '') === 'individual' &&
+ [me?.id, me?.lid].some(own => !!own && bare(own) === asked);
+ if (askedByGuest) {
+ return stored.message ?? undefined;
+ }
const neutral = (jid: string): string => this.host.toNeutralJid(jid);
const chat = [stored.key.remoteJid, stored.key.remoteJidAlt];
if (differentWaIds(chat, [key.remoteJid], neutral)) {
diff --git a/src/engine/adapters/baileys-message-mapper.ts b/src/engine/adapters/baileys-message-mapper.ts
index 35d444b1f..c147bc069 100644
--- a/src/engine/adapters/baileys-message-mapper.ts
+++ b/src/engine/adapters/baileys-message-mapper.ts
@@ -1,5 +1,10 @@
import type { proto } from '@whiskeysockets/baileys';
-import { DeliveryStatus, IncomingMessage, MessageType } from '../interfaces/whatsapp-engine.interface';
+import {
+ DeliveryStatus,
+ EventResponseKind,
+ IncomingMessage,
+ MessageType,
+} from '../interfaces/whatsapp-engine.interface';
import { chatKind } from '../identity/wa-id';
/**
@@ -19,6 +24,23 @@ export const BAILEYS_NON_CONTENT_TYPES: ReadonlySet<string> = new Set([
'encCommentMessage',
]);
+/**
+ * Map Baileys' `EventResponseMessage.EventResponseType` (UNKNOWN=0, GOING=1, NOT_GOING=2, MAYBE=3)
+ * to the neutral RSVP kind. Matched by number so the mapper needs no runtime proto import.
+ */
+export function mapBaileysEventResponseType(type: number | null | undefined): EventResponseKind {
+ switch (type) {
+ case 1:
+ return 'going';
+ case 2:
+ return 'not_going';
+ case 3:
+ return 'maybe';
+ default:
+ return 'unknown';
+ }
+}
+
/**
* Map a Baileys message content-type token (from `getContentType`) to the engine-neutral
* {@link MessageType}. `audioMessage` splits on the `ptt` flag into `voice` vs `audio`,
diff --git a/src/engine/adapters/baileys.adapter.spec.ts b/src/engine/adapters/baileys.adapter.spec.ts
index 1b3bd08d1..6795dd128 100644
--- a/src/engine/adapters/baileys.adapter.spec.ts
+++ b/src/engine/adapters/baileys.adapter.spec.ts
@@ -344,6 +344,31 @@ describe('BaileysAdapter lifecycle & status', () => {
}
});
+ it("answers an RSVP's lookup of the account's own 1:1 event under the account's own jid", async () => {
+ await newAdapter().initialize(noopCallbacks({}));
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
+ const makeWASocket = jest.requireMock('@whiskeysockets/baileys').default as jest.Mock;
+ const [[{ getMessage }]] = makeWASocket.mock.calls as Array<
+ [{ getMessage: (key: { remoteJid?: string; id?: string }) => Promise<unknown> }]
+ >;
+ const content = { eventMessage: { name: 'Game night' } };
+ const own = { key: { remoteJid: '[email protected]', fromMe: true, id: 'EVT1' }, message: content };
+ fakeSock.user = { id: '628999:[email protected]', lid: '99887766:12@lid', name: 'Me' };
+ try {
+ // The guest names the event's chat as they see it: this account, by phone number or by lid.
+ fakeStore.getMessage.mockResolvedValue(own);
+ await expect(getMessage({ remoteJid: '[email protected]', id: 'EVT1' })).resolves.toBe(content);
+ await expect(getMessage({ remoteJid: '99887766@lid', id: 'EVT1' })).resolves.toBe(content);
+ // Only the account's own 1:1 messages: a received one or a group one still needs its own chat.
+ fakeStore.getMessage.mockResolvedValue({ ...own, key: { ...own.key, fromMe: false } });
+ await expect(getMessage({ remoteJid: '[email protected]', id: 'EVT1' })).resolves.toBeUndefined();
+ fakeStore.getMessage.mockResolvedValue({ ...own, key: { ...own.key, remoteJid: '[email protected]' } });
+ await expect(getMessage({ remoteJid: '[email protected]', id: 'EVT1' })).resolves.toBeUndefined();
+ } finally {
+ fakeSock.user = undefined;
+ }
+ });
+
it('on a logged-out close: DISCONNECTED, onDisconnected, and NO reconnect', async () => {
const rmSpy = jest.spyOn(fs.promises, 'rm').mockResolvedValue(undefined);
try {
diff --git a/src/engine/adapters/baileys.adapter.ts b/src/engine/adapters/baileys.adapter.ts
index 7e18b0f0a..9c6f8d60f 100644
--- a/src/engine/adapters/baileys.adapter.ts
+++ b/src/engine/adapters/baileys.adapter.ts
@@ -161,6 +161,7 @@ export class BaileysAdapter implements IWhatsAppEngine {
getOnMessageReaction: () => this.callbacks.onMessageReaction,
getOnMessageAck: () => this.callbacks.onMessageAck,
getOnGroupEvent: () => this.callbacks.onGroupEvent,
+ getOnEventResponse: () => this.callbacks.onEventResponse,
getOnCall: () => this.callbacks.onCall,
getOnPresenceUpdate: () => this.callbacks.onPresenceUpdate,
getOnCallOutcome: () => this.callbacks.onCallOutcome,
diff --git a/src/engine/interfaces/whatsapp-engine.interface.ts b/src/engine/interfaces/whatsapp-engine.interface.ts
index a4fd4a257..14d900795 100644
--- a/src/engine/interfaces/whatsapp-engine.interface.ts
+++ b/src/engine/interfaces/whatsapp-engine.interface.ts
@@ -651,6 +651,38 @@ export interface EditedMessage {
timestamp: number;
}
+/** A guest's answer to a WhatsApp event invitation (the "Going" / "Not going" / "Maybe" buttons). */
+export type EventResponseKind = 'going' | 'not_going' | 'maybe' | 'unknown';
+
+/**
+ * One RSVP to a WhatsApp event (the calendar-style event created from the attach menu). WhatsApp
+ * encrypts each RSVP with a key derived from the event creation message's `messageSecret`, so an
+ * engine can only report the answers to events whose creation message it holds. A guest who changes
+ * their answer produces a new RSVP; the one with the latest `timestamp` per `responderId` is the
+ * current state.
+ */
+export interface EventResponseEvent {
+ /** Id of the event creation message the RSVP answers. */
+ eventMessageId: string;
+ /** Neutral id of the chat the event was posted in. */
+ chatId: string;
+ /** Neutral id of the guest who answered (the account itself when it answered from its phone). */
+ responderId: string;
+ /** The responder's saved name and profile name, when the session knows either. */
+ contact?: { name?: string; pushName?: string };
+ /** True when the account itself answered (from its phone). */
+ fromMe: boolean;
+ response: EventResponseKind;
+ /** Extra guests the responder said they are bringing; absent when WhatsApp sent none. */
+ extraGuestCount?: number;
+ /** The event's name, when the creation message is available to read it from. */
+ eventName?: string;
+ /** Id of the RSVP message itself; unique per answer, so a changed answer has a new one. */
+ responseMessageId: string;
+ /** Unix seconds the guest answered (sender clock). */
+ timestamp: number;
+}
+
export interface ReactionEvent {
messageId: string;
chatId: string;
@@ -850,6 +882,11 @@ export interface EngineEventCallbacks {
onMessageRevoked?: (message: RevokedMessage) => void;
onMessageReaction?: (event: ReactionEvent) => void;
onMessageEdited?: (message: EditedMessage) => void;
+ /**
+ * Fired for each RSVP to a WhatsApp event (consumers emit `event.response`). Baileys only: it
+ * decrypts the RSVP itself from the stored event creation message. whatsapp-web.js never fires it.
+ */
+ onEventResponse?: (event: EventResponseEvent) => void;
/**
* Fired on group membership changes (join/leave), group metadata updates
* (subject/description/announce/locked), and pending join requests. The `kind` selects the
diff --git a/src/modules/events/dto/ws-messages.dto.ts b/src/modules/events/dto/ws-messages.dto.ts
index cbe142251..48674728a 100644
--- a/src/modules/events/dto/ws-messages.dto.ts
+++ b/src/modules/events/dto/ws-messages.dto.ts
@@ -25,6 +25,7 @@ export const SUBSCRIBABLE_EVENTS = [
'call.received',
'status.received',
'presence.update',
+ 'event.response',
'call.accepted',
'call.rejected',
'call.missed',
diff --git a/src/modules/events/events.gateway.ts b/src/modules/events/events.gateway.ts
index 4d58436fc..5aa099f49 100644
--- a/src/modules/events/events.gateway.ts
+++ b/src/modules/events/events.gateway.ts
@@ -75,6 +75,7 @@ const CHAT_EVENTS = new Set([
'group.update',
'group.join_request',
'presence.update',
+ 'event.response',
]);
function chatRoom(sessionId: string, event: string, chatId: string): string {
@@ -882,6 +883,11 @@ export class EventsGateway implements OnGatewayInit, OnGatewayConnection, OnGate
this.emitToRooms(sessionId, 'presence.update', data);
}
+ /** Emit an RSVP to a WhatsApp event (Baileys only). Payload mirrors the `event.response` webhook. */
+ emitEventResponse(sessionId: string, data: Record<string, unknown>) {
+ this.emitToRooms(sessionId, 'event.response', data);
+ }
+
/**
* Emit QR code update for a session. Scanning the QR links a device to the account, so it only
* reaches keys that may read it over REST (OPERATOR and above).
diff --git a/src/modules/session/session-engine-event-wiring.ts b/src/modules/session/session-engine-event-wiring.ts
index 73502ad60..e807101a5 100644
--- a/src/modules/session/session-engine-event-wiring.ts
+++ b/src/modules/session/session-engine-event-wiring.ts
@@ -283,6 +283,18 @@ export class SessionEngineEventWiring {
host.messages.applyMessageEditQueued(id, message);
},
+ onEventResponse: (event): void => {
+ if (!host.isLiveEngine(id, engine)) return;
+ this.logger.debug(`Event response: ${event.response} to ${event.eventMessageId}`, {
+ sessionId: id,
+ chatId: event.chatId,
+ eventMessageId: event.eventMessageId,
+ action: 'event_response',
+ });
+ const payload = { sessionId: id, ...event };
+ host.eventsGateway.emitEventResponse(id, payload);
+ void host.webhookService.dispatch(id, 'event.response', payload);
+ },
onGroupEvent: (event): void => {
if (!host.isLiveEngine(id, engine)) return;
this.logger.debug(`Group event: ${event.kind} in ${event.groupId}`, {
diff --git a/src/modules/session/session-event-response-wiring.spec.ts b/src/modules/session/session-event-response-wiring.spec.ts
new file mode 100644
index 000000000..9eac352fe
--- /dev/null
+++ b/src/modules/session/session-event-response-wiring.spec.ts
@@ -0,0 +1,53 @@
+import { SessionEngineEventWiring, SessionEngineWiringHost } from './session-engine-event-wiring';
+import { EventResponseEvent, IWhatsAppEngine } from '../../engine/interfaces/whatsapp-engine.interface';
+import { createLogger } from '../../common/services/logger.service';
+
+describe('event.response wiring', () => {
+ const rsvp: EventResponseEvent = {
+ eventMessageId: 'EVT1',
+ chatId: '[email protected]',
+ responderId: '[email protected]',
+ contact: { name: 'Ana Pérez', pushName: 'Ana' },
+ fromMe: false,
+ response: 'going',
+ responseMessageId: 'RSVP1',
+ timestamp: 1786000000,
+ };
+
+ const setup = (live: boolean) => {
+ const dispatch = jest.fn();
+ const emitEventResponse = jest.fn();
+ const host = {
+ isLiveEngine: () => live,
+ messages: {},
+ webhookService: { dispatch },
+ eventsGateway: { emitEventResponse },
+ } as unknown as SessionEngineWiringHost;
+ const cb = new SessionEngineEventWiring({ logger: createLogger('test') }).buildCallbacks(
+ 'sess-1',
+ {} as IWhatsAppEngine,
+ 'sess-1-name',
+ host,
+ );
+ return { cb, dispatch, emitEventResponse };
+ };
+
+ it('publishes the RSVP with its session to the webhook and the WebSocket', () => {
+ const { cb, dispatch, emitEventResponse } = setup(true);
+
+ cb.onEventResponse?.(rsvp);
+
+ const payload = { sessionId: 'sess-1', ...rsvp };
+ expect(dispatch).toHaveBeenCalledWith('sess-1', 'event.response', payload);
+ expect(emitEventResponse).toHaveBeenCalledWith('sess-1', payload);
+ });
+
+ it('publishes nothing from an engine that is no longer live', () => {
+ const { cb, dispatch, emitEventResponse } = setup(false);
+
+ cb.onEventResponse?.(rsvp);
+
+ expect(dispatch).not.toHaveBeenCalled();
+ expect(emitEventResponse).not.toHaveBeenCalled();
+ });
+});
diff --git a/src/modules/webhook/dto/webhook.dto.ts b/src/modules/webhook/dto/webhook.dto.ts
index bb717c92b..e1c159931 100644
--- a/src/modules/webhook/dto/webhook.dto.ts
+++ b/src/modules/webhook/dto/webhook.dto.ts
@@ -92,6 +92,7 @@ export const WEBHOOK_EVENTS = [
'session.reconnect_loop',
'session.restriction',
'presence.update',
+ 'event.response',
'group.join',
'group.leave',
'group.update',
diff --git a/src/modules/webhook/utils/idempotency.util.spec.ts b/src/modules/webhook/utils/idempotency.util.spec.ts
index e3533c9fe..3d654cb8b 100644
--- a/src/modules/webhook/utils/idempotency.util.spec.ts
+++ b/src/modules/webhook/utils/idempotency.util.spec.ts
@@ -288,6 +288,18 @@ describe('Idempotency Utils', () => {
expect(generateIdempotencyKey('presence.update', other, at)).not.toBe(a);
});
+ it('keys event.response on the session + RSVP id (unique per answer, no occurrence salt needed)', () => {
+ const at = '2026-07-20T00:00:00.000Z';
+ const data = { sessionId: 'A', eventMessageId: 'EVT1', responseMessageId: 'RSVP1', response: 'going' };
+ const key = generateIdempotencyKey('event.response', data, at);
+ expect(key).toBe('rsvp_A_RSVP1');
+ expect(generateIdempotencyKey('event.response', data, '2026-07-20T01:00:00.000Z')).toBe(key);
+ // A changed answer is a new RSVP with a new id, so it is never deduped against the first.
+ const changed = { ...data, responseMessageId: 'RSVP2', response: 'not_going' };
+ expect(generateIdempotencyKey('event.response', changed, at)).not.toBe(key);
+ expect(generateIdempotencyKey('event.response', { ...data, sessionId: 'B' }, at)).not.toBe(key);
+ });
+
it('keys call.received on the session + call id (unique per call, no occurrence salt needed)', () => {
const at = '2026-07-20T00:00:00.000Z';
const data = { sessionId: 'A', callId: 'CALL1', from: '[email protected]', timestamp: 1782000000 };
diff --git a/src/modules/webhook/utils/idempotency.util.ts b/src/modules/webhook/utils/idempotency.util.ts
index 82c3e4ddf..cb4027d31 100644
--- a/src/modules/webhook/utils/idempotency.util.ts
+++ b/src/modules/webhook/utils/idempotency.util.ts
@@ -109,6 +109,11 @@ export function generateIdempotencyKey(event: string, data: Record<string, unkno
// is already distinct — no occurrence salt, matching call.received's stable key.
return `call_${toStr(data.sessionId)}_${toStr(data.callId)}_${toStr(data.outcome)}`;
+ case 'event.response':
+ // Each RSVP is its own message with its own id, and a changed answer is a new RSVP with a new
+ // id, so (session, RSVP id) is already unique per occurrence and stable across retries.
+ return `rsvp_${toStr(data.sessionId)}_${toStr(data.responseMessageId)}`;
+
case 'presence.update':
// Keyed on the chat and salted per occurrence. Only genuine state CHANGES are dispatched, and
// a contact who types, stops, and types again produces the same payload each time — content