socketon
v0.31.0
Published
WhatsApp API Library - Socketon By IbraDecode
Maintainers
Readme
Socketon WhatsApp API Library
Why Socketon?
If you feel Baileys is now slow, has double responses, or sometimes infinite connecting, Socketon can be a better alternative.
This is a fork of Baileys focused on stability, session handling, and more flexible pairing codes. Most APIs remain the same, so migration from Baileys usually doesn't require major changes.
Key Features
- Custom Pairing Codes: Default "SOCKETON" code for easier authentication
- Enhanced Stability: Improved session handling and automatic reconnection
- Multi-Device Support: Full compatibility with WhatsApp's multi-device feature
- Interactive Messages: Buttons, lists, and native flow interactions
- Album Messages: Send multiple images in a single message
- Newsletter Integration: Auto-follow and manual newsletter management
- Business Messaging: Product catalogs, payments, and business features
- Media Support: Comprehensive upload/download with progress tracking
- Event-Driven Architecture: Extensive real-time event system
- TypeScript Support: Full type definitions for better development experience
- Lightweight & Fast: WebSocket-based, no browser dependencies
Installation
npm install socketonRequirements:
- Node.js >= 20.0.0
Quick Start
Basic Echo Bot
const { makeWASocket, useMultiFileAuthState } = require('socketon');
async function startBot() {
// Setup authentication
const { state, saveCreds } = await useMultiFileAuthState('./auth');
// Create WhatsApp socket
const sock = makeWASocket({
auth: state,
printQRInTerminal: true
});
// Handle connection
sock.ev.on('connection.update', (update) => {
const { connection, qr } = update;
if (qr) console.log('Scan QR Code:', qr);
if (connection === 'open') console.log('Connected to WhatsApp!');
});
// Handle messages
sock.ev.on('messages.upsert', async ({ messages }) => {
for (const msg of messages) {
if (msg.key.fromMe) continue;
const jid = msg.key.remoteJid;
const text = msg.message?.conversation || msg.message?.extendedTextMessage?.text || '';
console.log(`Message from ${jid}: ${text}`);
// Echo response
if (text) {
await sock.sendMessage(jid, { text: `Echo: ${text}` });
}
}
});
// Save credentials
sock.ev.on('creds.update', saveCreds);
}
startBot().catch(console.error);Pairing Code Authentication
const { makeWASocket, useMultiFileAuthState } = require('socketon');
async function startWithPairing() {
const { state, saveCreds } = await useMultiFileAuthState('./auth');
const sock = makeWASocket({
auth: state,
printQRInTerminal: false // Disable QR, use pairing code
});
sock.ev.on('connection.update', async (update) => {
const { connection } = update;
if (connection === 'open') {
// Use default "SOCKETON" pairing code
const pairingCode = await sock.requestPairingCode('6281234567890');
console.log('Pairing Code:', pairingCode);
// Or use custom pairing code
// const customCode = await sock.requestPairingCode('6281234567890', 'MYCODE');
// console.log('Custom Pairing Code:', customCode);
}
});
sock.ev.on('creds.update', saveCreds);
}
startWithPairing().catch(console.error);Documentation
Complete Guide
For comprehensive documentation covering everything from basic to advanced usage:
The complete guide includes:
- Detailed installation and setup
- Authentication methods (QR code, pairing code)
- Message handling (text, media, interactive)
- Group management and newsletter features
- Business API integration and webhooks
- Event system and error handling
- Advanced usage patterns and performance optimization
- Database integration and real-world use cases
- Deployment guides and troubleshooting
- API reference and migration guide
Examples Directory
Check the examples/ directory for runnable code samples:
- Basic Bot: Simple echo bot with command handling
- Media Handling: Download/upload images, videos, documents
- Group Management: Admin bot for group control
- Business Features: Product catalog and ordering system
- Analytics: Bot with usage statistics and monitoring
- Deployment: Production-ready setup with Docker/PM2
Use Cases
Socketon is perfect for building:
- Chatbots: Customer service, entertainment, automation
- Business Applications: CRM integration, order management
- Automation Tools: Message forwarding, scheduling
- Analytics Bots: Message tracking, user engagement
- Fun Bots: Games, quizzes, interactive experiences
- E-commerce: Product catalogs, order processing
Migration from Baileys
Migrating from Baileys is usually simple, just change the import:
// From Baileys
const { makeWASocket } = require('@whiskeysockets/baileys');
// To Socketon
const { makeWASocket } = require('socketon');For detailed migration steps, see the Migration Guide in the complete documentation.
Troubleshooting
Common Issues
Connection Problems:
- Check internet connection
- Ensure WhatsApp account is active
- Try deleting auth/ folder and re-authenticating
Authentication Issues:
- Delete auth folder and scan QR again
- Check file permissions on auth directory
- Ensure stable network during authentication
Message Failures:
- Verify JID format
- Check if recipient blocked you
- Implement retry logic for reliability
For detailed troubleshooting, see COMPLETE_GUIDE.md#troubleshooting.
Contributing
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Credits
- Original Baileys: @adiwajshing/baileys
- Socketon Enhancement: IbraDecode
Support & Community
- Telegram Community: Join our community
- GitHub Issues: Report bugs
- WhatsApp: +31617786379
- Complete Documentation: COMPLETE_GUIDE.md
Ready to build your WhatsApp bot? Start with the Quick Start above, or explore the complete documentation for advanced features!
Version Management
See VERSION_MANAGEMENT.md for detailed versioning and release information.
Socketon v0.31.0 - Built by IbraDecode
