Features
- QR code authentication
- Pairing code authentication
- Send text, images, videos, audio, and documents
- Receive media and files
- Send polls
- Send locations and contacts
- Sticker support
- Group message support (optional)
- Read status support (optional)
- Session persistence
Installation
Dependencies
The Baileys provider uses:baileys: ^7.0.0-rc.9 - Core WhatsApp Web APIsharp: Image processingffmpeg: Audio/video processingwa-sticker-formatter: Sticker creation
Configuration
Basic Setup
Configuration Options
Authentication
QR Code Authentication
By default, the provider uses QR code authentication:http://localhost:3000/ or check the console output.
Pairing Code Authentication
require_action event.
Basic Usage
Sending Messages
Sending Media
Receiving Media
Advanced Features
Sending Polls
Sending Location
Sending Contact
Sending Stickers
Presence Updates (Typing Indicator)
Event Handling
Ready Event
Host Information
Authentication Failure
Require Action (QR/Pairing Code)
Session Management
Session Files
Sessions are stored in{name}_sessions/ directory by default.
Clear Session
Auto-cleanup
HTTP Endpoints
The provider exposes an HTTP server for QR code access and custom endpoints.QR Code Endpoint
Custom Endpoints
Best Practices
Session Management
Session Management
- Keep session files backed up
- Don’t share session files (they contain authentication data)
- Use
timeReleasefor automatic cleanup in production - Monitor session health with the
readyevent
Message Rate Limiting
Message Rate Limiting
- Avoid sending too many messages too quickly
- Use delays between messages
- Baileys has built-in rate limiting to prevent bans
Group Messages
Group Messages
- Set
groupsIgnore: trueto ignore group messages by default - Handle group messages separately if needed
- Be careful with automated replies in groups
Error Handling
Error Handling
- Listen to
auth_failureevents - Implement reconnection logic
- Log errors to
baileys.log(automatically created)
Troubleshooting
QR Code Not Loading
QR Code Not Loading
Check the logs in
baileys.log file. Ensure the port is not in use and your firewall allows connections.Session Expired
Session Expired
Delete the
{name}_sessions directory and restart. You’ll need to scan the QR code again.Messages Not Sending
Messages Not Sending
- Check if the phone number is correctly formatted
- Verify the session is active (check
readyevent) - Review rate limiting
Connection Keeps Dropping
Connection Keeps Dropping
- Check your internet connection
- Verify WhatsApp is working on your phone
- Review
baileys.logfor detailed error messages - The provider has automatic reconnection with exponential backoff
Example: Complete Bot
Migration from Other Providers
Switching from other WhatsApp providers to Baileys:- Install the Baileys provider
- Update the import statement
- Adjust configuration (remove API keys, add session name)
- Test authentication flow
- Verify media handling works as expected