Skip to main content
Baileys uses an event-driven architecture. All socket events are typed through the BaileysEventMap interface.

BaileysEventEmitter

The event emitter interface used by Baileys sockets.
function
required
Register an event listener
function
required
Remove an event listener
function
required
Remove all listeners for an event
function
required
Emit an event

BaileysEventMap

Complete mapping of all events to their payload types.

Connection Events

Partial<ConnectionState>
Fired when connection state changes (WS opened, closed, connecting, etc.)

Authentication Events

Partial<AuthenticationCreds>
Fired when credentials are updated (keys, identity, etc.)

Message Events

object
New messages received or synced from history
WAMessageUpdate[]
Updates to existing messages (delivery receipts, edits, etc.)
object
Messages deleted by user
array
Reactions added/removed from messages
Example:
array
Media encryption info updates
MessageUserReceiptUpdate[]
Individual user receipts (read, played, etc.)

Chat Events

Chat[]
New chats created
ChatUpdate[]
Updates to existing chats (name, unread count, etc.)
string[]
Array of chat JIDs that were deleted
object
Chat lock status changed

History Sync Events

object
Bulk history sync from phone (reverse chronological order)

Contact Events

Contact[]
New contacts added
Partial<Contact>[]
Updates to existing contacts

Group Events

GroupMetadata[]
New groups joined
Partial<GroupMetadata>[]
Updates to group metadata (name, subject, etc.)
object
Participant changes in a group
object
Someone requested to join a group
object
Labels assigned to group member changed

Presence Events

object
Contact presence changed (typing, online, etc.)
Example:

Blocklist Events

object
Entire blocklist replaced
object
Blocklist updated incrementally

Call Events

WACallEvent[]
Incoming/outgoing call events

Label Events

Label
Label created or edited
object
Label associated/disassociated with item

Newsletter Events

object
Reaction on newsletter message
object
Newsletter message viewed
object
Newsletter participant role changed
object
Newsletter settings changed

Settings Events

union
Account settings changed. Union of:
LIDMapping
LID to phone number mapping updated

BufferedEventData

Internal type used for buffering events before emission:

Example: Complete Event Handler