Panduan Lengkap: Setup Group Mode & Notifikasi Admin di Telegram Bot

Setup Guide - Group Mode dengan Admin Notification
Cara Kerja Bot di Group
📱 GROUP CHAT ├─ User upload foto label ├─ Bot reaction: 👍 (processing) ├─ Bot reaction: ✅ (done) └─ Bot SILENT (tidak spam di group) 💬 ADMIN PRIVATE CHAT ├─ Bot kirim foto original ├─ Bot kirim detail lengkap ├─ Button: Approve/Reject/Edit └─ Admin bisa action langsung
Step 1: Cara Dapat Telegram User ID
Metode 1: Pakai Bot @userinfobot
1. Buka Telegram 2. Search: @userinfobot 3. Klik Start 4. Bot akan kirim: Id: 123456789 ← Copy angka ini
Metode 2: Pakai Bot @getidsbot
1. Search: @getidsbot 2. /start 3. Copy User ID yang muncul
Metode 3: Manual dari Code
Tambahkan temporary di bot:
bot.on('message', (msg) => { console.log(`User: ${msg.from.first_name}`) console.log(`User ID: ${msg.from.id}`) // ← Ini user ID nya })
Step 2: Update Configuration
Edit file bot.js:
const ADMIN_IDS = [ '123456789', // Admin 1 (owner) '987654321', // Admin 2 (staff) '555666777' // Admin 3 (accounting) ]
Step 3: Disable Privacy Mode
Via @BotFather:
1. Chat @BotFather 2. Ketik: /mybots 3. Pilih bot kamu: @orderan25Bot 4. Bot Settings 5. Group Privacy 6. Turn Off (Disable) 7. Done! ✅
Screenshot lokasi:
@BotFather └─ /mybots └─ @orderan25Bot └─ Bot Settings └─ Group Privacy └─ ❌ Turn Off (DISABLE THIS)
Step 4: Add Bot ke Group
1. Buat grup baru atau pakai yang ada 2. Add @orderan25Bot ke grup 3. (Optional) Set bot jadi admin 4. Test: kirim foto label 5. Cek: admin dapat notif di PM
Step 5: Testing Checklist
Test di Group:
- [ ] Upload foto label
- [ ] Bot kasih reaction 👍
- [ ] Bot kasih reaction ✅ (setelah selesai)
- [ ] Group tetap clean (tidak ada text panjang)
- [ ] Command seperti /stats tetap work
Test di Admin PM:
- [ ] Admin dapat foto original
- [ ] Admin dapat detail lengkap
- [ ] Button Approve/Reject/Edit muncul
- [ ] Bisa klik button
- [ ] Data masuk database
Struktur Notifikasi ke Admin
🔔 ORDER BARU MASUK 👤 Uploaded by: Ryan 📍 From Group: -1001234567890 ━━━━━━━━━━━━━━━━━━ 📦 Order: 250928NMFA28U7 📮 Resi: SPXID057236823609 🚚 Kurir: SPX 📤 PENGIRIM: 👤 Diah (Mih IRAH/DARTA) 📞 6285708308785 📍 Pabuaran, JAWA BARAT 📥 PENERIMA: 👤 Matrix Helm 📞 6285708308785 📍 Desa Jatirengang, Dusun 02 Tengah... 🏙️ Pabuaran, KAB. KEDIRI 🗺️ JAWA BARAT 📦 DETAIL PRODUK: • Produk: Kaca Helm Honda Scoopy Lubang Besar • Varian: Hitam Lurus+ Rg baut • Qty: 1 • Berat: 400 gr 💰 COD: Tidak 📅 Kirim: 29-09-2025 ━━━━━━━━━━━━━━━━━━ [✅ Approve] [❌ Reject] [📝 Edit] [🔍 Detail]
Reaction API Notes
Telegram Reaction API work on:
- Telegram Bot API 7.0+
- Belum semua bot bisa (tergantung server)
Fallback otomatis:
- Kalau reaction gagal → bot auto send simple emoji reply
- Tidak perlu khawatir
Environment Variables (Optional)
Buat file .env
:
TELEGRAM_BOT_TOKEN=your_bot_token OCR_MODE=hybrid GEMINI_API_KEY_1=your_key # Admin IDs (comma separated) ADMIN_ID_1=123456789 ADMIN_ID_2=987654321 # Notification mode NOTIFICATION_MODE=dm # 'dm' atau 'group'
Load di code:
require('dotenv').config() const ADMIN_IDS = [ process.env.ADMIN_ID_1, process.env.ADMIN_ID_2, process.env.ADMIN_ID_3 ].filter(id => id)
Multiple Group Support
Bot sudah support multiple groups:
// Setiap group bisa upload // Semua admin dapat notifikasi // Database tracking dari group mana
Query group statistics:
// Cari order dari group tertentu SELECT * FROM orders WHERE notes LIKE '%Group: -1001234567890%'
Advanced: Whitelist Groups
Kalau mau batasi bot hanya work di grup tertentu:
const ALLOWED_GROUPS = [ '-1001234567890', // Grup Order Processing '-1009876543210' // Grup Warehouse ] async function handleImage(bot, msg) { const isGroup = msg.chat.type === 'group' || msg.chat.type === 'supergroup' if (isGroup && !ALLOWED_GROUPS.includes(msg.chat.id.toString())) { await bot.sendMessage(msg.chat.id, '❌ Bot tidak aktif di grup ini.', { reply_to_message_id: msg.message_id } ) return } // ... rest of code }
Troubleshooting
Bot tidak reaction:
- Pastikan privacy mode OFF
- Update bot API version
- Cek log error
- Fallback ke text reply otomatis jalan
Admin tidak dapat notif:
- Pastikan User ID benar
- User harus start bot dulu (
/start
) - Cek bot tidak di-block user
- Cek log ada error kirim message
Foto tidak ter-process:
- Privacy mode sudah OFF?
- Bot ada permission read messages?
- Cek log ekstraksi
- Test dengan foto lebih jelas
Database query lambat:
- Add index di order_number dan resi_number
CREATE INDEX idx_order_number ON orders(order_number); CREATE INDEX idx_resi_number ON orders(resi_number); CREATE INDEX idx_receiver_phone ON orders(receiver_phone);
Production Deployment
Recommended setup:
├─ Bot running di VPS (screen/pm2) ├─ Database backup otomatis (cron) ├─ Log rotation (logrotate) ├─ Monitoring (uptime robot) └─ Admin notification via Telegram
PM2 command:
# Install PM2 npm install -g pm2 # Start bot pm2 start bot.js --name shopee-bot # Auto restart on crash pm2 startup pm2 save # Monitor pm2 monit # Logs pm2 logs shopee-bot
Security Best Practices
- Jangan hardcode token - pakai .env
- Restrict admin actions - validate user ID
- Sanitize database input - prevent SQL injection
- Rate limit uploads - prevent spam
- Encrypt sensitive data - untuk production
Semua sudah setup? Test dengan:
- Upload foto di group
- Cek reaction bot
- Cek admin dapat notif
- Approve/reject order
- Query database:
/cari [keyword]
Done! Bot siap operasional 24/7 🚀