Troubleshoot Auto Reply WA Tidak Berfungsi
Cara troubleshoot auto reply WhatsApp yang error atau tidak berfungsi. Common issues, solutions, debugging guide lengkap!
Auto reply tiba-tiba tidak jalan?
Jangan panik! Berikut panduan troubleshooting untuk masalah-masalah umum.
Quick Diagnosis
🔍 QUICK CHECK:
1. Apakah bot/app masih running?
2. Apakah WhatsApp masih connected?
3. Apakah internet stabil?
4. Apakah ada error di log?
5. Kapan terakhir kali berfungsi?
6. Ada perubahan apa sejak itu?Common Issues & Solutions
Issue 1: Bot Tidak Reply Sama Sekali
Gejala: Tidak ada response apapun saat ada pesan masuk
Kemungkinan Penyebab:
□ Bot/app tidak running
□ WhatsApp disconnected
□ Session expired
□ Internet putus
□ Server downSolusi:
bash
# Check apakah bot running
pm2 status
# Jika tidak running, start
pm2 start wa-bot
# Check logs untuk error
pm2 logs wa-bot --lines 50
# Jika perlu restart
pm2 restart wa-botjavascript
// Check connection status
client.on('ready', () => {
console.log('✅ Bot is ready!');
});
client.on('disconnected', (reason) => {
console.log('❌ Disconnected:', reason);
});Issue 2: Bot Reply Tapi Salah
Gejala: Ada response tapi tidak sesuai dengan yang seharusnya
Kemungkinan Penyebab:
□ Logic error di code
□ Keyword tidak match
□ State user salah
□ Database outdated
□ Wrong condition matchingSolusi:
javascript
// Debug dengan logging
client.on('message', async msg => {
console.log('Input:', msg.body);
console.log('Matched keyword:', findMatchedKeyword(msg.body));
console.log('User state:', userState.get(msg.from));
// Process...
});
// Check keyword matching
function findMatchedKeyword(text) {
const keywords = {
'harga': 'price_response',
'katalog': 'catalog_response',
// ...
};
for (const [keyword, response] of Object.entries(keywords)) {
if (text.toLowerCase().includes(keyword)) {
console.log(`Matched: "${keyword}"`);
return response;
}
}
console.log('No keyword matched');
return 'default_response';
}Issue 3: Session Expired / Need Re-scan
Gejala: Muncul error auth atau minta scan QR lagi
Kemungkinan Penyebab:
□ Session terlalu lama tidak digunakan
□ Logout dari HP
□ WhatsApp update
□ Auth file corruptSolusi:
bash
# Backup auth dulu (optional)
cp -r .wwebjs_auth .wwebjs_auth_backup
# Delete auth dan re-scan
rm -rf .wwebjs_auth
# Restart bot
pm2 restart wa-bot
# Scan QR code barujavascript
// Auto-handle auth failure
client.on('auth_failure', (msg) => {
console.log('Auth failure:', msg);
// Delete auth folder
fs.rmSync('.wwebjs_auth', { recursive: true, force: true });
// Reinitialize
client.initialize();
});Issue 4: Pesan Terkirim Tapi Tidak Terbaca
Gejala: Di log terkirim, tapi customer bilang tidak dapat
Kemungkinan Penyebab:
□ Network issue di sisi customer
□ Nomor salah format
□ Customer block/report
□ WhatsApp issueSolusi:
javascript
// Check message status
client.on('message_ack', (msg, ack) => {
const status = {
0: 'PENDING',
1: 'SENT',
2: 'DELIVERED',
3: 'READ'
};
console.log(`Message to ${msg.to}: ${status[ack]}`);
});
// Validate phone number
function validatePhone(phone) {
// Remove non-digits
const clean = phone.replace(/\D/g, '');
// Check format (Indonesia)
if (clean.startsWith('0')) {
return '62' + clean.slice(1);
}
if (clean.startsWith('62')) {
return clean;
}
console.log('Invalid phone format:', phone);
return null;
}Issue 5: Bot Lambat / Delay
Gejala: Response butuh waktu lama (> 10 detik)
Kemungkinan Penyebab:
□ Server overloaded
□ Heavy processing
□ External API slow
□ Database query slow
□ Memory leakSolusi:
javascript
// Add timing to identify bottleneck
client.on('message', async msg => {
const start = Date.now();
const t1 = Date.now();
const userData = await db.users.findOne({ phone: msg.from });
console.log('DB query:', Date.now() - t1, 'ms');
const t2 = Date.now();
const response = await generateResponse(msg, userData);
console.log('Generate response:', Date.now() - t2, 'ms');
const t3 = Date.now();
await msg.reply(response);
console.log('Send reply:', Date.now() - t3, 'ms');
console.log('Total time:', Date.now() - start, 'ms');
});
// Check memory usage
setInterval(() => {
const used = process.memoryUsage();
console.log('Memory:', Math.round(used.heapUsed / 1024 / 1024), 'MB');
}, 60000);Issue 6: Bot Crash / Restart Terus
Gejala: Bot mati dan restart berulang kali
Kemungkinan Penyebab:
□ Unhandled exception
□ Memory exhausted
□ Infinite loop
□ External dependency failSolusi:
javascript
// Global error handler
process.on('uncaughtException', (error) => {
console.error('Uncaught Exception:', error);
// Log to file/service
fs.appendFileSync('errors.log',
`${new Date().toISOString()} - ${error.stack}\n`
);
});
process.on('unhandledRejection', (reason, promise) => {
console.error('Unhandled Rejection:', reason);
});
// Wrap message handler
client.on('message', async msg => {
try {
await handleMessage(msg);
} catch (error) {
console.error('Error handling message:', error);
// Continue running, don't crash
}
});Issue 7: Only Works for Some Contacts
Gejala: Beberapa orang dapat reply, beberapa tidak
Kemungkinan Penyebab:
□ Whitelist/blacklist filter
□ Group vs private chat setting
□ Business vs personal account
□ Saved contact requirementSolusi:
javascript
// Check filter settings
client.on('message', async msg => {
// Debug contact info
const contact = await msg.getContact();
console.log('Is group:', msg.from.includes('@g.us'));
console.log('Is saved:', contact.isMyContact);
console.log('Is business:', contact.isBusiness);
// Check if filtered out
if (isFiltered(msg)) {
console.log('Message filtered out');
return;
}
// Process...
});
function isFiltered(msg) {
// Example filters
if (msg.from.includes('@g.us') && !ALLOW_GROUPS) return true;
if (WHITELIST.length > 0 && !WHITELIST.includes(msg.from)) return true;
if (BLACKLIST.includes(msg.from)) return true;
return false;
}Diagnostic Commands
Check PM2 Status:
bash
# List all processes
pm2 status
# Check specific bot
pm2 show wa-bot
# View logs
pm2 logs wa-bot --lines 100
# Monitor resources
pm2 monitCheck System:
bash
# Memory
free -m
# Disk
df -h
# CPU
top
# Network
ping google.comCheck WhatsApp Connection:
javascript
// Add health check endpoint
app.get('/health', async (req, res) => {
try {
const state = await client.getState();
res.json({
status: 'ok',
waState: state,
uptime: process.uptime()
});
} catch (error) {
res.status(500).json({
status: 'error',
error: error.message
});
}
});Prevention Tips
✅ PREVENT ISSUES:
1. Monitoring & alerts
- Setup UptimeRobot
- Alert via Telegram/Email
2. Regular health checks
- Ping endpoint every 5 mins
- Log rotation
3. Auto-restart on failure
- PM2 with max_restarts
- Docker restart policy
4. Backup auth session
- Daily backup
- Easy restore
5. Keep dependencies updated
- Regular npm update
- Test after updateFAQ
Bot mendadak minta scan QR, kenapa?
Session expired atau terlogout dari HP. Re-scan dan bot akan jalan lagi.
Log bilang "Evaluation failed", apa artinya?
Biasanya masalah puppeteer/browser. Coba restart atau reinstall dependencies.
Bagaimana cek apakah WhatsApp ban?
Coba login dari HP. Jika muncul peringatan atau temporary ban, berarti kena limit.
Kesimpulan
Troubleshooting = Systematic debugging!
| Step | Action |
|---|---|
| 1 | Check if running |
| 2 | Check logs |
| 3 | Identify error |
| 4 | Apply fix |
| 5 | Test |
| 6 | Prevent recurrence |
Stay calm, debug systematically!