Skip to main content

Overview

Bailey provides a unified sendMessage API for sending all types of messages. Whether you’re sending text, media, or interactive content, the same function is used with different content types.

Basic Message Sending

All messages are sent using the sendMessage method:

Parameters

  • jid: The recipient’s WhatsApp ID
    • For individuals: [country code][phone number]@s.whatsapp.net
    • For groups: 123456789-123345@g.us
    • For broadcast lists: [timestamp]@broadcast
    • For stories: status@broadcast
  • content: The message content (see AnyMessageContent)
  • options: Message options like quoted messages, ephemeral settings (see MiscMessageGenerationOptions)

WhatsApp ID Format

Understanding the JID (Jabber ID) format is crucial for sending messages:
The JID must not include +, (), or - characters. Only include the country code and phone number digits.

Simple Text Message

The most basic message type:

Message Return Value

The sendMessage function returns a WAMessage object containing:

Message Types Overview

Baileys supports a wide variety of message types:

Text-Based Messages

  • Text messages with mentions
  • Link previews
  • Quoted/replied messages

Media Messages

  • Images (with captions)
  • Videos (including GIFs)
  • Audio (voice notes)
  • Documents
  • Stickers

Location & Contact

  • Location sharing
  • Contact cards

Interactive Messages

  • Polls
  • Reactions
  • Pin messages
  • Events

Special Messages

  • Forward messages
  • View-once messages
  • Disappearing messages
See the following pages for detailed examples of each message type:

Error Handling

Messages may fail to send due to network issues, invalid JIDs, or the recipient blocking you. Always implement proper error handling.

Next Steps

Text Messages

Learn about sending text with mentions, quotes, and links

Media Messages

Send images, videos, audio, and documents

Message Options

Configure ephemeral messages, quotes, and more

Modify Messages

Edit and delete sent messages