Skip to main content

Basic Text Message

Send a simple text message:

Mentioning Users

Mention users in your message by providing their JIDs in the mentions array:
The @number in the text is optional but recommended for clarity. The actual mentions are controlled by the mentions array.

Multiple Mentions

Quoting Messages

Reply to a message by quoting it:
The quoted parameter is passed in the options object (third parameter), not in the content object.

Getting Messages to Quote

Messages can be obtained from the messages.upsert event:
Baileys can automatically generate link previews when you send URLs:

Prerequisites

First, install the link preview library:
Baileys will automatically:
  1. Detect the URL in the text
  2. Fetch the page metadata
  3. Generate a preview with title, description, and thumbnail
You can provide your own link preview data:
To send a URL without a preview:

Advanced Text Features

Context Info

Add additional context to your message:

Combined Features

Combine mentions, quotes, and other features:

Message Content Type Structure

Text messages are sent as extendedTextMessage in the protocol:

Formatting Text

WhatsApp Web does not natively support markdown-style formatting (bold, italic, etc.) through the protocol. What you see in the WhatsApp mobile app is handled client-side.
While you can send special formatting characters, the rendering is client-dependent:

Examples from Source

Here are real examples from the Baileys codebase:

Best Practices

  1. Store Messages: Implement a message store to support quoting and other features
  2. Validate JIDs: Ensure the recipient JID is in the correct format
  3. Handle Errors: Wrap send operations in try-catch blocks
  4. Rate Limiting: Don’t send too many messages too quickly to avoid bans
  5. Link Previews: Use the library for automatic preview generation

Next Steps

Media Messages

Learn to send images, videos, and documents

Message Options

Configure ephemeral messages and other options