Basic Text Message
Send a simple text message:Mentioning Users
Mention users in your message by providing their JIDs in thementions 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:Getting Messages to Quote
Messages can be obtained from themessages.upsert event:
Link Previews
Baileys can automatically generate link previews when you send URLs:Prerequisites
First, install the link preview library:Automatic Link Preview
- Detect the URL in the text
- Fetch the page metadata
- Generate a preview with title, description, and thumbnail
Manual Link Preview
You can provide your own link preview data:Disable Link Preview
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 asextendedTextMessage in the protocol:
Formatting Text
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
- Store Messages: Implement a message store to support quoting and other features
- Validate JIDs: Ensure the recipient JID is in the correct format
- Handle Errors: Wrap send operations in try-catch blocks
- Rate Limiting: Don’t send too many messages too quickly to avoid bans
- 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