WhatsApp API Multi Device: Cara Kerjanya
Panduan WhatsApp Multi Device API. Cara kerja, batasan, dan implementasi untuk bisnis. Support multiple devices!
Multi-device = 1 nomor, banyak device!
WhatsApp sekarang support linked devices. Bagaimana ini mempengaruhi API dan bot development?
Apa Itu Multi-Device?
DULU (Single Device):
1 nomor WA = 1 HP only
WhatsApp Web = butuh HP online
SEKARANG (Multi-Device):
1 nomor WA = HP + 4 linked devices
Linked devices bisa offline dari HP
Bot bisa jalan tanpa HP always on!Multi-Device Support by API Type
WhatsApp Cloud API (Official):
✅ Full multi-device support
✅ Tidak perlu HP online
✅ Server-side API
✅ Reliable & stableWhatsApp Business API (On-Premise):
✅ Multi-device supported
✅ Self-hosted solution
✅ Enterprise gradeUnofficial API (whatsapp-web.js, Baileys):
⚠️ Multi-device mode WAJIB
✅ Bisa jalan tanpa HP online
✅ Lebih stable dari single-device era
⚠️ Still unofficial, ada risikoCara Kerja Multi-Device
┌─────────────────────────────────────────────────────┐
│ WhatsApp Servers │
└────────────────────────┬────────────────────────────┘
│
┌───────────────┼───────────────┐
│ │ │
▼ ▼ ▼
┌─────────┐ ┌─────────┐ ┌─────────┐
│ Primary │ │ Linked │ │ Linked │
│ (HP) │ │ Device 1│ │ Device 2│
│ │ │ (Web) │ │ (Bot) │
└─────────┘ └─────────┘ └─────────┘
End-to-end encryption tetap terjaga!
Setiap device punya identity key sendiri.Linked Devices Limits
📱 PRIMARY DEVICE: 1 (HP utama)
🔗 LINKED DEVICES: Max 4
• WhatsApp Web
• WhatsApp Desktop
• Bot/API client
• Other browsers
⏰ LINKED DEVICE TIMEOUT:
• Jika primary offline > 14 hari
• Linked devices akan disconnectSetup Bot dengan Multi-Device
whatsapp-web.js:
javascript
const { Client, LocalAuth } = require('whatsapp-web.js');
const client = new Client({
authStrategy: new LocalAuth(),
puppeteer: {
headless: true,
args: ['--no-sandbox']
}
});
client.on('qr', (qr) => {
// Scan QR untuk link device
qrcode.generate(qr, { small: true });
});
client.on('ready', () => {
console.log('Bot connected as linked device!');
});
client.initialize();Baileys:
javascript
const { makeWASocket, useMultiFileAuthState } = require('@whiskeysockets/baileys');
async function startBot() {
const { state, saveCreds } = await useMultiFileAuthState('./auth_info');
const sock = makeWASocket({
auth: state,
printQRInTerminal: true
});
sock.ev.on('creds.update', saveCreds);
sock.ev.on('connection.update', (update) => {
const { connection, lastDisconnect } = update;
if (connection === 'close') {
// Reconnect logic
const shouldReconnect = lastDisconnect?.error?.output?.statusCode !== 401;
if (shouldReconnect) {
startBot();
}
} else if (connection === 'open') {
console.log('Bot connected!');
}
});
return sock;
}Keuntungan Multi-Device untuk Bot
1. HP Tidak Perlu Online 24/7
DULU:
HP mati → Bot mati ❌
SEKARANG:
HP mati → Bot tetap jalan ✅
(sampai 14 hari)2. Lebih Stabil
- Tidak tergantung koneksi HP
- Fewer disconnections
- Better reliability3. Parallel Access
- Bot bisa akses bersamaan dengan HP
- Admin bisa manual reply + bot auto reply
- Tidak conflictBatasan Multi-Device
1. History Sync Limitation
Linked device TIDAK dapat:
- Full chat history
- Older messages (sebelum link)
Hanya dapat:
- Messages setelah link
- Recent history (limited)2. Some Features Not Available
Di linked device tidak bisa:
- Create/manage broadcast lists
- Clear/delete chats for everyone
- Send to unsaved contacts (some cases)3. Max 4 Linked Devices
Jika sudah 4, harus unlink salah satu
untuk tambah device baru.Multi-Admin dengan Multi-Device
Scenario: 1 nomor CS, 3 admin
Setup:
- Admin 1: HP primary
- Admin 2: WhatsApp Web
- Admin 3: WhatsApp Desktop
- Bot: Server (linked device)
Semua bisa access bersamaan!
Tapi tidak ada assignment system built-in.Best Practice Multi-Admin:
javascript
// Buat sistem assignment sendiri
const assignments = new Map();
async function handleMessage(message) {
const existingAssignment = assignments.get(message.from);
if (existingAssignment) {
// Sudah ada yang handle
return;
}
// Assign ke available admin atau bot
const handler = getAvailableHandler();
assignments.set(message.from, handler);
// Proses message
await processMessage(message, handler);
}Troubleshooting
Device Disconnected:
Penyebab:
- Primary offline > 14 hari
- Manual unlink
- WhatsApp update
Solusi:
- Re-scan QR code
- Check primary device
- Update libraryMessage Not Syncing:
Penyebab:
- Network issues
- Device out of sync
- Server lag
Solusi:
- Restart bot
- Re-link device
- Check internet connectionDuplicate Messages:
Penyebab:
- Multiple devices responding
- No coordination
Solusi:
- Implement locking/assignment
- Mark message as "handled"
- Coordinate between devicesFAQ
Apakah HP harus selalu online?
Tidak lagi! Dengan multi-device, linked devices bisa jalan sendiri sampai 14 hari tanpa HP online.
Berapa device yang bisa di-link?
Max 4 linked devices + 1 primary (HP).
Apakah chat history tersedia di bot?
Terbatas. Hanya recent messages dan messages setelah link.
Kesimpulan
Multi-device = Game changer untuk bot!
| Single Device Era | Multi-Device Era |
|---|---|
| HP harus online | HP bisa offline |
| Sering disconnect | Lebih stable |
| Bot dependent on HP | Bot independent |
More reliable bots with multi-device!