Core message types
WAMessage
Represents a complete WhatsApp message with metadata.
export type WAMessage = proto.IWebMessageInfo & {
key: WAMessageKey
messageStubParameters?: any
category?: string
retryCount?: number
}
Unique identifier for the message
The actual message content (text, media, etc.)
Unix timestamp when the message was sent
Parameters for system messages (group events, etc.)
Message category classification
Number of times message delivery was retried
WAMessageKey
Unique identifier for a message across conversations.
export type WAMessageKey = proto.IMessageKey & {
remoteJidAlt?: string
participantAlt?: string
server_id?: string
addressingMode?: string
isViewOnce?: boolean
}
JID of the chat (user or group)
Whether the message was sent by you
JID of sender in group chats
WAMessageContent
The Protocol Buffer message content.
export type WAMessageContent = proto.IMessage
This type includes all possible message content types from the WhatsApp protocol.
Message content types
AnyMessageContent
Union type for all sendable message content.
export type AnyMessageContent =
| AnyRegularMessageContent
| { forward: WAMessage; force?: boolean }
| { delete: WAMessageKey }
| { disappearingMessagesInChat: boolean | number }
| { limitSharing: boolean }
AnyRegularMessageContent
Regular user-sent messages.
export type AnyRegularMessageContent = (
| TextMessageContent
| AnyMediaMessageContent
| { event: EventMessageOptions }
| { poll: PollMessageOptions }
| { contacts: ContactsContent }
| { location: WALocationMessage }
| { react: proto.Message.IReactionMessage }
| ButtonReplyContent
| GroupInviteContent
| ListReplyContent
| PinMessageContent
| ProductMessageContent
| SharePhoneNumber
| RequestPhoneNumber
) & ViewOnce
Text messages
type TextMessageContent = {
text: string
linkPreview?: WAUrlInfo | null
} & Mentionable & Contextable & Editable
JIDs of users mentioned in the text
Context information (quoted message, etc.)
Key of message being edited
AnyMediaMessageContent
Media messages (images, videos, audio, documents, stickers).
export type AnyMediaMessageContent = (
| ImageMessage
| VideoMessage
| AudioMessage
| StickerMessage
| DocumentMessage
) & { mimetype?: string } & Editable
Image message
type ImageMessage = {
image: WAMediaUpload
caption?: string
jpegThumbnail?: string
width?: number
height?: number
} & Mentionable & Contextable
Image file (Buffer, stream, or URL)
Video message
type VideoMessage = {
video: WAMediaUpload
caption?: string
gifPlayback?: boolean
jpegThumbnail?: string
ptv?: boolean
width?: number
height?: number
} & Mentionable & Contextable
Video file (Buffer, stream, or URL)
Send as video note (round video)
Audio message
type AudioMessage = {
audio: WAMediaUpload
ptt?: boolean
seconds?: number
}
Audio file (Buffer, stream, or URL)
Audio duration in seconds
Sticker message
type StickerMessage = {
sticker: WAMediaUpload
isAnimated?: boolean
width?: number
height?: number
}
Sticker file (Buffer, stream, or URL)
Whether sticker is animated
Document message
type DocumentMessage = {
document: WAMediaUpload
mimetype: string
fileName?: string
caption?: string
} & Contextable
Document file (Buffer, stream, or URL)
MIME type of the document
Display name for the file
Type for uploading media files.
export type WAMediaUpload =
| Buffer
| WAMediaPayloadStream
| WAMediaPayloadURL
export type WAMediaPayloadURL = { url: URL | string }
export type WAMediaPayloadStream = { stream: Readable }
Special message types
Poll message
export type PollMessageOptions = {
name: string
selectableCount?: number
values: string[]
messageSecret?: Uint8Array
toAnnouncementGroup?: boolean
}
Number of options users can select (default: 1)
32-byte secret to encrypt poll selections
Event message
export type EventMessageOptions = {
name: string
description?: string
startDate: Date
endDate?: Date
location?: WALocationMessage
call?: 'audio' | 'video'
isCancelled?: boolean
isScheduleCall?: boolean
extraGuestsAllowed?: boolean
messageSecret?: Uint8Array
}
MessageUpsertType
Indicates how a message should be handled.
export type MessageUpsertType = 'append' | 'notify'
notify: New message requiring user notification
append: Add to history without notification
WAMessageUpdate
Partial update to an existing message.
export type WAMessageUpdate = {
update: Partial<WAMessage>
key: WAMessageKey
}
MessageReceiptType
Types of message receipts.
export type MessageReceiptType =
| 'read'
| 'read-self'
| 'hist_sync'
| 'peer_msg'
| 'sender'
| 'inactive'
| 'played'
| undefined
MessageUserReceiptUpdate
User-level read receipt update.
export type MessageUserReceiptUpdate = {
key: WAMessageKey
receipt: MessageUserReceipt
}
export type MessageUserReceipt = proto.IUserReceipt
Message generation options
MiscMessageGenerationOptions
Options for generating messages.
export type MiscMessageGenerationOptions = {
messageId?: string
timestamp?: Date
quoted?: WAMessage
ephemeralExpiration?: number | string
mediaUploadTimeoutMs?: number
statusJidList?: string[]
backgroundColor?: string
font?: number
broadcast?: boolean
useCachedGroupMetadata?: boolean
}
Custom message ID (auto-generated if not provided)
Message to quote/reply to
Disappearing message duration
Timeout for media uploads
JIDs for status@broadcast messages
MessageRelayOptions
Options for relaying messages.
export type MessageRelayOptions = {
messageId?: string
participant?: { jid: string; count: number }
additionalAttributes?: { [_: string]: string }
additionalNodes?: BinaryNode[]
useUserDevicesCache?: boolean
useCachedGroupMetadata?: boolean
statusJidList?: string[]
}
participant
{ jid: string; count: number }
Send to specific participant (for retries)
Extra attributes for WA binary node
Use cached group metadata