Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
feat(engine): surface Meta-masked business messages as a 'masked' type (#574) (#579)
Yudhi Armyndharis712cfbe640e1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f5efa65cb..0f839eb17 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]+### Added++- **Business messages WhatsApp masks on linked devices are now surfaced as a `masked` type instead of an empty bubble.** For some high-security business messages (e.g. enterprise OTPs), WhatsApp delivers only a bodyless placeholder to linked/companion devices — the actual text is withheld by design and is only readable on the primary phone. On the Baileys engine these previously arrived as `type: "unknown"` with a blank body, which looked like a parsing bug. They are now classified as `type: "masked"` (with an empty body) so the API, webhooks, and filters can distinguish them, and the dashboard shows a short notice explaining the message is only available on the primary phone. (#574) Thanks @crossgg.+### Fixed- **Sending to a contact WhatsApp has migrated to LID addressing no longer fails with HTTP 500 on the whatsapp-web.js engine.** WhatsApp has begun addressing some individual chats by privacy id (`@lid`) instead of the phone-number WID (`@c.us`); for those contacts whatsapp-web.js rejected the send with `No LID for user`, which surfaced as a 500 (and as a passed-through 500 in integrations such as n8n). Pinning the WhatsApp Web version did not help because this is an addressing change, not version drift. The engine now resolves an individual recipient to its current WhatsApp id before sending — across text, media (image/video/audio/document), location, contact, and sticker messages, plus the typing indicator — and falls back to the original id if resolution is unavailable, so a send is never blocked on it. Group and channel sends are unaffected; the Baileys engine already handled this. (#573) Thanks @lexcorp.diff --git a/dashboard/src/components/DashboardCharts.tsx b/dashboard/src/components/DashboardCharts.tsxindex 0f90cf1fc..2aac7462e 100644--- a/dashboard/src/components/DashboardCharts.tsx+++ b/dashboard/src/components/DashboardCharts.tsx@@ -36,6 +36,7 @@ const TYPE_COLORS: Record<string, string> = {sticker: '#ef4444',location: '#84cc16',revoked: '#f43f5e',+ masked: '#8b5cf6',unknown: '#64748b',};diff --git a/dashboard/src/components/FilterBuilder.tsx b/dashboard/src/components/FilterBuilder.tsxindex ac3812f05..51f2529a3 100644--- a/dashboard/src/components/FilterBuilder.tsx+++ b/dashboard/src/components/FilterBuilder.tsx@@ -30,6 +30,7 @@ const MESSAGE_TYPES = ['contact','call','revoked',+ 'masked','unknown',];diff --git a/dashboard/src/i18n/locales/ar.json b/dashboard/src/i18n/locales/ar.jsonindex d7aa5ecd7..e03408890 100644--- a/dashboard/src/i18n/locales/ar.json+++ b/dashboard/src/i18n/locales/ar.json@@ -118,6 +118,7 @@"placeholderDesc": "اختر محادثة نشطة من الشريط الجانبي الأيسر لبدء قراءة وإرسال رسائل واتساب.","deleteConfirm": "حذف هذه الرسالة للجميع؟","messageDeleted": "🚫 تم حذف هذه الرسالة",+ "messageMasked": "🔒 أخفته واتساب على الأجهزة المرتبطة — تحقق منه على هاتفك الأساسي","errors": {"loadSessions": "فشل تحميل الجلسات","loadChats": "فشل تحميل المحادثات",diff --git a/dashboard/src/i18n/locales/en.json b/dashboard/src/i18n/locales/en.jsonindex 46165ed60..f27dd0c9c 100644--- a/dashboard/src/i18n/locales/en.json+++ b/dashboard/src/i18n/locales/en.json@@ -118,6 +118,7 @@"placeholderDesc": "Choose a conversation to read and reply.","deleteConfirm": "Delete this message for everyone?","messageDeleted": "🚫 This message was deleted",+ "messageMasked": "🔒 Masked by WhatsApp for linked devices — check your primary phone","errors": {"loadSessions": "Failed to load sessions","loadChats": "Failed to load chats",diff --git a/dashboard/src/i18n/locales/es.json b/dashboard/src/i18n/locales/es.jsonindex 1c902ed73..2e52f0a0e 100644--- a/dashboard/src/i18n/locales/es.json+++ b/dashboard/src/i18n/locales/es.json@@ -118,6 +118,7 @@"placeholderDesc": "Selecciona un chat activo de la barra lateral izquierda para leer y enviar mensajes de WhatsApp.","deleteConfirm": "¿Eliminar este mensaje para todos?","messageDeleted": "🚫 Este mensaje fue eliminado",+ "messageMasked": "🔒 Ocultado por WhatsApp en dispositivos vinculados — revísalo en tu teléfono principal","errors": {"loadSessions": "Error al cargar las sesiones","loadChats": "Error al cargar los chats",diff --git a/dashboard/src/i18n/locales/fr.json b/dashboard/src/i18n/locales/fr.jsonindex 231b2487f..2ca21e49c 100644--- a/dashboard/src/i18n/locales/fr.json+++ b/dashboard/src/i18n/locales/fr.json@@ -118,6 +118,7 @@"placeholderDesc": "Sélectionnez une discussion active dans la barre latérale gauche pour commencer à lire et envoyer des messages WhatsApp.","deleteConfirm": "Supprimer ce message pour tout le monde ?","messageDeleted": "🚫 Ce message a été supprimé",+ "messageMasked": "🔒 Masqué par WhatsApp sur les appareils liés — consultez votre téléphone principal","errors": {"loadSessions": "Échec du chargement des sessions","loadChats": "Échec du chargement des discussions",diff --git a/dashboard/src/i18n/locales/he.json b/dashboard/src/i18n/locales/he.jsonindex 02fa86466..2b80874c3 100644--- a/dashboard/src/i18n/locales/he.json+++ b/dashboard/src/i18n/locales/he.json@@ -118,6 +118,7 @@"placeholderDesc": "בחר שיחה פעילה מהסרגל הצדדי כדי להתחיל לקרוא ולשלוח הודעות WhatsApp.","deleteConfirm": "למחוק הודעה זו עבור כולם?","messageDeleted": "🚫 הודעה זו נמחקה",+ "messageMasked": "🔒 הוסתר על ידי וואטסאפ במכשירים המקושרים — בדוק בטלפון הראשי שלך","errors": {"loadSessions": "טעינת הסשנים נכשלה","loadChats": "טעינת השיחות נכשלה",diff --git a/dashboard/src/i18n/locales/it.json b/dashboard/src/i18n/locales/it.jsonindex b93e5a0f7..1dfa653e2 100644--- a/dashboard/src/i18n/locales/it.json+++ b/dashboard/src/i18n/locales/it.json@@ -118,6 +118,7 @@"placeholderDesc": "Seleziona una chat attiva dalla barra laterale a sinistra per iniziare a leggere e inviare messaggi WhatsApp.","deleteConfirm": "Eliminare questo messaggio per tutti?","messageDeleted": "🚫 Questo messaggio è stato eliminato",+ "messageMasked": "🔒 Nascosto da WhatsApp sui dispositivi collegati — controlla sul telefono principale","errors": {"loadSessions": "Impossibile caricare le sessioni","loadChats": "Impossibile caricare le chat",diff --git a/dashboard/src/i18n/locales/pt-BR.json b/dashboard/src/i18n/locales/pt-BR.jsonindex 5875ec45a..ef406ab23 100644--- a/dashboard/src/i18n/locales/pt-BR.json+++ b/dashboard/src/i18n/locales/pt-BR.json@@ -118,6 +118,7 @@"placeholderDesc": "Selecione um chat ativo na barra lateral esquerda para ler e enviar mensagens do WhatsApp.","deleteConfirm": "Excluir esta mensagem para todos?","messageDeleted": "🚫 Esta mensagem foi excluída",+ "messageMasked": "🔒 Ocultada pelo WhatsApp em dispositivos vinculados — verifique no seu telefone principal","errors": {"loadSessions": "Erro ao carregar as sessões","loadChats": "Erro ao carregar os chats",diff --git a/dashboard/src/i18n/locales/te.json b/dashboard/src/i18n/locales/te.jsonindex 570536c9c..fc8b0066c 100644--- a/dashboard/src/i18n/locales/te.json+++ b/dashboard/src/i18n/locales/te.json@@ -118,6 +118,7 @@"placeholderDesc": "వాట్సాప్ సందేశాలను చదవడం మరియు పంపడం ప్రారంభించడానికి ఎడమ సైడ్బార్ నుండి ఒక యాక్టివ్ చాట్ను ఎంచుకోండి.","deleteConfirm": "ఈ సందేశాన్ని అందరి కోసం తొలగించాలా?","messageDeleted": "🚫 ఈ సందేశం తొలగించబడింది",+ "messageMasked": "🔒 లింక్ చేసిన పరికరాల్లో WhatsApp దీన్ని దాచింది — మీ ప్రధాన ఫోన్లో చూడండి","errors": {"loadSessions": "సెషన్లను లోడ్ చేయడం విఫలమైంది","loadChats": "చాట్లను లోడ్ చేయడం విఫలమైంది",diff --git a/dashboard/src/i18n/locales/zh-CN.json b/dashboard/src/i18n/locales/zh-CN.jsonindex fc431842e..bbf43d865 100644--- a/dashboard/src/i18n/locales/zh-CN.json+++ b/dashboard/src/i18n/locales/zh-CN.json@@ -118,6 +118,7 @@"placeholderDesc": "从左侧边栏选择一个活跃聊天,即可开始阅读和发送 WhatsApp 消息。","deleteConfirm": "为所有人删除此消息?","messageDeleted": "🚫 此消息已被删除",+ "messageMasked": "🔒 WhatsApp 已对关联设备隐藏此消息 — 请在主手机上查看","errors": {"loadSessions": "加载会话失败","loadChats": "加载聊天失败",diff --git a/dashboard/src/i18n/locales/zh-HK.json b/dashboard/src/i18n/locales/zh-HK.jsonindex 47a874844..9453353fd 100644--- a/dashboard/src/i18n/locales/zh-HK.json+++ b/dashboard/src/i18n/locales/zh-HK.json@@ -118,6 +118,7 @@"placeholderDesc": "從左側邊欄選擇一個活躍聊天,即可開始閱讀和傳送 WhatsApp 訊息。","deleteConfirm": "為所有人刪除此訊息?","messageDeleted": "🚫 此訊息已被刪除",+ "messageMasked": "🔒 WhatsApp 已對已連結裝置隱藏此訊息 — 請在主手機上查看","errors": {"loadSessions": "載入工作階段失敗","loadChats": "載入聊天失敗",diff --git a/dashboard/src/pages/Chats.tsx b/dashboard/src/pages/Chats.tsxindex e9538beb4..158807d56 100644--- a/dashboard/src/pages/Chats.tsx+++ b/dashboard/src/pages/Chats.tsx@@ -897,6 +897,7 @@ export function Chats() {const reactions = msg.metadata?.reactions || {};const hasReactions = Object.keys(reactions).length > 0;const isRevoked = msg.type === 'revoked';+ const isMasked = msg.type === 'masked';return (<div@@ -923,6 +924,8 @@ export function Chats() {{isRevoked ? (<div className="message-text">{t('chats.messageDeleted')}</div>+ ) : isMasked ? (+ <div className="message-text message-masked">{t('chats.messageMasked')}</div>) : (msg.body &&(!mediaInfo || msg.body !== mediaInfo.filename) &&diff --git a/dashboard/src/services/api.ts b/dashboard/src/services/api.tsindex 1ce3666bb..c9b8f13b7 100644--- a/dashboard/src/services/api.ts+++ b/dashboard/src/services/api.ts@@ -142,6 +142,7 @@ export const MESSAGE_TYPES = ['contact','call','revoked',+ 'masked','unknown',] as const;export type MessageType = (typeof MESSAGE_TYPES)[number];diff --git a/docs/06-api-specification.md b/docs/06-api-specification.mdindex 5971087aa..df53fe608 100644--- a/docs/06-api-specification.md+++ b/docs/06-api-specification.md@@ -783,7 +783,7 @@ Returns a bare array of engine-neutral `IncomingMessage` objects:]```-Each item may also include `isStatusBroadcast`, `mentionedIds`, `isLidSender`, `contact`, `media { mimetype, filename?, data?, omitted?, sizeBytes? }`, `quotedMessage { id, body }`, `call { video, missed }` (for `call` messages), and `location { latitude, longitude, description?, address?, url? }`. `type` is one of `text|image|video|audio|voice|document|sticker|location|contact|call|revoked|unknown`.+Each item may also include `isStatusBroadcast`, `mentionedIds`, `isLidSender`, `contact`, `media { mimetype, filename?, data?, omitted?, sizeBytes? }`, `quotedMessage { id, body }`, `call { video, missed }` (for `call` messages), and `location { latitude, longitude, description?, address?, url? }`. `type` is one of `text|image|video|audio|voice|document|sticker|location|contact|call|revoked|masked|unknown`. A `masked` message is one WhatsApp deliberately withholds from linked/companion devices — e.g. a high-security business OTP — so its `body` is empty by design (the content is only available on the primary phone) rather than a parsing failure; this occurs on the Baileys engine.**Errors:** `400` session not active · `401` missing/invalid API key · `500` engine errordiff --git a/src/engine/adapters/baileys-message-mapper.spec.ts b/src/engine/adapters/baileys-message-mapper.spec.tsindex 0ae814a32..6374fbab9 100644--- a/src/engine/adapters/baileys-message-mapper.spec.ts+++ b/src/engine/adapters/baileys-message-mapper.spec.ts@@ -24,6 +24,10 @@ describe('mapBaileysMessageType (baileys content-type -> neutral MessageType)',['buttonsMessage', false, 'text'],['templateMessage', false, 'text'],['interactiveResponseMessage', false, 'text'],+ // Meta masks high-security business messages (enterprise OTPs) on linked/companion devices,+ // delivering a bodyless `placeholderMessage` (PlaceholderType MASK_LINKED_DEVICES). Surface it as+ // its own `masked` type so it is distinguishable from a genuinely unparseable message (#574).+ ['placeholderMessage', false, 'masked'],[undefined, false, 'unknown'],['pollCreationMessage', false, 'unknown'],// Regression trap: calls arrive via the `call` socket event, never as a message content type,diff --git a/src/engine/adapters/baileys-message-mapper.ts b/src/engine/adapters/baileys-message-mapper.tsindex 204573cd2..e0857b232 100644--- a/src/engine/adapters/baileys-message-mapper.ts+++ b/src/engine/adapters/baileys-message-mapper.ts@@ -40,6 +40,13 @@ export function mapBaileysMessageType(contentType: string | undefined, isPtt = f// carry display text that {@link extractBaileysBody} flattens into `body`, so they surface as// `text` instead of being dropped as `unknown` with an empty body (#562).return 'text';+ case 'placeholderMessage':+ // Meta masks high-security business messages (enterprise OTPs, banking alerts) on linked/+ // companion devices — which Baileys is — delivering a bodyless `placeholderMessage` (its only+ // PlaceholderType is MASK_LINKED_DEVICES). The text is withheld by design and never arrives on+ // this device (a resend cannot recover it), so surface it as its own `masked` type rather than+ // an indistinguishable `unknown` empty bubble, so clients can explain it (#574).+ return 'masked';default:return 'unknown';}diff --git a/src/engine/interfaces/whatsapp-engine.interface.ts b/src/engine/interfaces/whatsapp-engine.interface.tsindex 1d19c438b..a52e2f113 100644--- a/src/engine/interfaces/whatsapp-engine.interface.ts+++ b/src/engine/interfaces/whatsapp-engine.interface.ts@@ -57,6 +57,9 @@ export type MessageType =| 'contact'| 'call'| 'revoked'+ // A message WhatsApp deliberately withheld from linked/companion devices (e.g. high-security+ // business OTPs): the payload is absent by design, not unparseable. See `mapBaileysMessageType`.+ | 'masked'| 'unknown';export interface IncomingMessage {diff --git a/src/modules/webhook/filters/filter-types.ts b/src/modules/webhook/filters/filter-types.tsindex 24786cfae..5f8013224 100644--- a/src/modules/webhook/filters/filter-types.ts+++ b/src/modules/webhook/filters/filter-types.ts@@ -47,6 +47,7 @@ export const MESSAGE_TYPES = ['contact','call','revoked',+ 'masked','unknown',] as const;