🤖 What Does This Bot Do?
| # | Function | Description |
|---|---|---|
| 1 | DM Support CORE | Receives user DMs and forwards them to an operator group as threaded conversations |
| 2 | Feedback Logging TRACK | Records WORKS / FAILS feedback from users for daily reports |
| 3 | Admin Ops ADMIN | Reply to users, check profiles, broadcast — all from the group |
| 4 | Unreplied Tracking MONITOR | Tracks messages that haven't been answered yet so nothing gets missed |
🔀 Message Flow
User → Operator Group
USER (DM to bot)
│
│ 1. User sends a message to the bot in private chat
│
▼
BOT ENGINE
│
│ 2. Bot creates / finds the user's thread in the DM group
│ → Each user gets their own thread (not mixed in one timeline)
│ → Anchor message = user profile (name, username, ID)
│
│ 3. Bot forwards user's message into that thread
│ → Tracks message in unreplied_tracking.json
│ → Saves user info in known_users.jsonl
│
▼
DM OPERATOR GROUP
│
│ 4. Admins see the message in the user's dedicated thread
│ → Ready to reply
Admin → User (Reply)
DM OPERATOR GROUP
│
│ 1. Admin replies to a user's message in the thread
│
▼
BOT ENGINE
│
│ 2. Bot detects the reply → resolves user_id from thread map
│ 3. Bot sends admin's message to the user's DM
│ 4. Marks all pending messages from that user as replied
│
▼
USER (DM)
│
│ User receives the reply directly from the bot
Edit & Delete Sync (Bidirectional)
| Action | Direction | Result |
|---|---|---|
| User edits DM | User → Group | Message in thread auto-updates |
| Admin edits reply in group | Group → User | Message in user's DM auto-updates |
| Admin deletes reply in group | Group → User | Message in user's DM auto-deleted |
| Edit sync fails | — | Bot posts "✏️ User edited message" notification in thread |
| User changes profile | Auto-detect | Thread anchor updated + "🔄 Profile changed..." notification |
| Admin reacts to message | Group | Auto-marks user's message as replied |
💬 Operator Groups
| # | Group | Purpose |
|---|---|---|
| 1 | DM Operator Group MAIN | User messages land here as threads. Admins reply from here. |
| 2 | Log Group LOG | Compact feedback logs (WORKS/FAILS). Not for replying to users. |
📁 Data Storage
storage/
│
├── sent_messages.jsonl → Log of set messages sent
├── feedback_events.jsonl → WORKS / FAILS feedback log
├── daily_reports.jsonl → Sent daily report history
├── known_users.jsonl → All detected users (id, name, username, last seen)
├── dm_threads.json → user_id → thread anchor map (persists across restarts)
└── unreplied_tracking.json → Pending messages awaiting admin reply
reports/ → Daily CSV report files
⌨️ Bot Commands
User Commands
/start PUBLIC
Starts the bot interaction. Bot sends a welcome message prompting the user to describe their problem. User can then chat freely with the bot.
Bot: "Hello! Please explain to us your problem, and prepare your anydesk. Just talk to me!"
Admin Commands ADMIN ONLY
Only the configured REPORT_USER_ID can use these. Non-admins get rejected.
/reportnow REPORT
Force-send the daily report immediately instead of waiting for the scheduled time.
/users [count] LOOKUP
List known users with their user_id, username, name, and last seen time. Default shows recent users.
/users
/users 50
/whois <user_id> LOOKUP
Live profile lookup from Telegram API. Shows username, first/last name, bot/verified/scam/fake flags, and profile link. Can also be used by replying to a user's message in the thread.
/whois 7956767415
/dm <user_id> <message> MESSAGE
Send a direct personal message to a specific user without using the thread system.
/dm 7956767415 Halo, ini admin ya. Mau bantu follow up.
/broadcast <message> MASS
Send a message to all known users (except admin). Can also reply to any message and type
/broadcast to use that message as content. Cannot be undone./broadcast Halo semuanya, ada update penting hari ini.
/unreplied [count] MONITOR
Show list of unanswered user messages (max 72h). Each entry includes a direct link to the message in the DM group. Ordered from oldest waiting. Default: 30 results.
/unreplied
/unreplied 50
/mark_replied TRACK
Must reply to a user's message in the DM group thread. Marks that message (and all other pending messages from the same user) as replied.
/clear_replied CLEANUP
Remove all tracking entries that are already marked as replied. Cleans up accumulated data.
/purge_old [hours] CLEANUP
Delete tracking entries older than N hours (default: 72h).
/purge_old
/purge_old 48
📋 How-To Guides
Reply to a User (Easiest Method)
💬 Reply via DM Group Thread
- Open the DM operator group
- Find the user's thread (each user has a dedicated thread)
- Click Reply on the user's message in that thread
- Type your response and Send
- Done! Bot delivers it to the user's DM automatically
Tips:
No need to copy-paste user_id when replying from the thread.
You can also give a reaction (emoji) to mark a message as handled without replying.
Editing your reply in the group also updates it in the user's DM.
Contact a User Manually (Without Thread)
📨 Direct DM via Command
- Get user_id — run
/usersor/whoisfrom a thread reply - Send DM —
/dm <user_id> <your message>
/users
→ found user ID: 7956767415
/dm 7956767415 Halo, saya dari tim support. Ada yang bisa dibantu?
Broadcast (Safe Procedure)
📡 Mass Message to All Users
- Write your draft message
- Test first — send to 1 user via
/dmto check formatting - If OK — run
/broadcast <message> - Check the summary: total targets, sent count, fail count
⚠️ Warning: Broadcast cannot be undone. Always test with
/dm first to prevent typos going to all users.
📅 Daily Routine
🌅 Morning / Afternoon
- Run
/unrepliedto check pending messages - Monitor the DM operator group for new threads
- Reply to user threads as they come in
🌆 Evening
- Check feedback log in the log group
- Run
/unrepliedagain for a double-check
🌙 End of Day
- Wait for the automatic daily report, or run
/reportnow - Run
/clear_repliedto clean up tracking data
🔧 Troubleshooting
Click any problem to expand the solution.
🚫 Admin replied in group but user didn't receive it
▶
- Check reply target — Make sure you replied to the correct message in the user's thread (not a random message)
- Not blank — Message must have content (not empty)
- User blocked bot? — If user blocked the bot, delivery will fail silently
- Bot console — Check error logs for delivery failures
📨 Can't send /dm to a specific user
▶
- User blocked bot — Bot can't DM users who blocked it
- Never started — User must have pressed
/startat least once - Deactivated account — Telegram account may be deleted or deactivated
- Wrong user_id — Double-check with
/whois
🔄 Username / name changed — will it break?
▶
- No breakage — Bot uses
user_id(numeric), not username - Auto-update — Thread anchor is automatically updated with new name
- Notification — Bot sends "🔄 Profile changed..." in the thread
❌ Admin sent wrong reply to user
▶
- Delete the message in the DM group → it auto-deletes in user's DM
- Edit the message in the DM group → it auto-edits in user's DM
- Both operations are synced bidirectionally
📋 Too many unreplied messages piling up
▶
- Run
/unrepliedto see the full list with direct links - Click links to jump directly to each pending message
- After handling, reply in thread or use
/mark_replied - React with emoji to bulk-acknowledge messages as handled
- Run
/clear_repliedto clean up resolved entries - Run
/purge_old 48to remove stale entries (>48h)
📊 Daily report not being sent
▶
- Bot running? — Verify the bot process is active
- Manual trigger — Use
/reportnowto force-send - Check logs — Look at
daily_reports.jsonlfor last sent timestamp - REPORT_USER_ID — Ensure the admin ID is correctly configured
🔇 Feedback not logging
▶
- Button callback — Check if ✅ / ❌ buttons are properly set up
- Log group — Verify bot has permission to post in the log group
- Storage — Check
feedback_events.jsonlis writable
⚡ Quick Reference Cheat Sheet
If you forget everything else, remember this table.
| I want to... | Do this |
|---|---|
| Reply to a user | Reply to their message in the DM group thread |
| Check who someone is | /whois <user_id> |
| DM someone directly | /dm <user_id> <message> |
| Mass message everyone | /broadcast <message> |
| See all known users | /users |
| See unanswered messages | /unreplied |
| Mark message as handled | /mark_replied (reply to msg) or give a reaction |
| Clean up tracking | /clear_replied |
| Remove old entries | /purge_old or /purge_old 48 |
| Fix a wrong reply | Edit or Delete message in group → syncs to user |
| Force daily report | /reportnow |
📌 Team Rules (Prevent Chaos)
- Always reply via thread in the DM group — never DM users outside the bot
- Never broadcast without testing on 1 user via
/dmfirst - Use
/whoiswhen unsure about a user's identity - Use
/usersto track active users - Check
/unrepliedat least 2x daily (morning & evening) - Give a reaction if a message is handled but doesn't need a text reply