Skip to Content
Message Payload

Message Payload

Every live inbound message carries the complete Zaileys MessageContext — the decoded, normalized payload Zaileys is known for. One helper unlocks it:

import { zaileysContext } from 'chat-adapter-zaileys' bot.onSubscribedMessage(async (thread, message) => { const ctx = zaileysContext(message) if (!ctx) return // history fetches / sent echoes have no live context ctx.senderDevice // 'android' | 'ios' | 'web' | 'desktop' ctx.isForwarded / ctx.isViewOnce // 20+ decoded flags const quoted = await ctx.replied() // the full decoded quoted message await ctx.react('🔥') // zaileys shortcuts still work })

The raw shape

Message.raw is a ZaileysRaw:

FieldTypeWhen present
keyWAMessageKeyAlways — remoteJid, id, fromMe.
contextMessageContextLive inbound messages.
messageWAMessageLive inbound + history fetches (the raw Baileys message).

zaileysContext(message) is the typed accessor for raw.context — it returns null instead of forcing you to null-chain.

Field mapping

How the adapter fills the Chat SDK Message from MessageContext:

Chat SDK fieldSource
idctx.chatId (the WhatsApp message id)
threadIdctx.roomId — always the conversation target
textctx.text (body / caption / poll name, unwrapped)
formattedctx.text parsed from WhatsApp markup to mdast
author.userIdctx.senderId — phone-number jid, LID already resolved
author.fullNamectx.senderName (push name)
author.isMectx.isFromMe or tracked adapter sends
metadata.dateSentctx.timestamp (already in ms)
metadata.editedctx.isEdited
isMentionctx.isTagMe
attachmentsctx.media — lazy, see below

Lazy media

Media never downloads until you ask. ctx.media (or the SDK-standard message.attachments[0]) exposes metadata immediately and bytes on demand:

const [attachment] = message.attachments if (attachment) { attachment.mimeType // 'image/jpeg' attachment.size // bytes, when known const buffer = await attachment.fetchData() // downloads now } // or through the zaileys context: const ctx = zaileysContext(message) if (ctx?.media && 'buffer' in ctx.media) { const buffer = await ctx.media.buffer() }

Sticker attachments map to type: 'image', documents to type: 'file'.

What the context gives you beyond the SDK

Straight from Zaileys’ message payload:

  • IdentityuniqueId (per-message fingerprint), staticId (stable sender-in-room hash), senderLid, senderDevice, receiverId
  • FlagsisGroup, isBroadcast, isStory, isViewOnce, isEphemeral, isForwarded, isQuestion, isPrefix, isTagMe, isEdited, isDeleted, isPinned, isBot, isHideTags, and more
  • Lazy functionsroomName(), receiverName(), replied(), message() (raw WAMessage)
  • Actionsreply(text), react(emoji)
  • Citationcitation.authors() / citation.banned() predicates from your Zaileys config

mentions, links, chatType, and typed media unions (poll, location, event, contact, album, …) are all documented in Zaileys → Message Payload.