name: setup-departments description: Set up "departments" = forum topics in the company's Telegram group. Use when a user IN A GROUP asks to set up/create departments. Run EXACTLY 1 command, do NOT self-discover.
🚫 ONLY run when the user EXPLICITLY ASKS to "set up/create/update departments". A QUESTION (e.g. "which department am I in?", "what does this department do?", "what departments are there?") is NOT a setup request → answer DIRECTLY from context (current topic name, profile), NEVER run
setup_departments.py(running it by mistake creates duplicate departments). Only create when the user truly wants to CREATE NEW.
When the user (IN A GROUP) wants to set up departments → run EXACTLY 1 command, then report the result. Do NOT read lib source, do NOT run -h, do NOT session_search, do NOT scan ~/.hermes/state.db/channel_directory to guess chat_id. The script handles everything.
python3 lib/setup_departments.py
The script auto: gets chat_id from the session (env), gets the department structure from the user profile, checks the group is a forum + bot is admin, creates topics + pins descriptions. Returns JSON.
stage: already_done → read message: departments already set up, say gently "Các phòng ban đã có sẵn rồi ạ — em không tạo trùng. Anh/chị muốn thêm phòng mới thì cho em tên phòng nhé." Do NOT recreate.ok: true → report: "Em đã dựng xong các phòng: ok: false → read error + hint, relay exactly that meaning to the user, e.g.:stage: context → read the script's ACTUAL error field, don't hardcode "private chat": (a) if error is "first message into a new group / group not yet resolved" → say gently "Em vừa vào nhóm, anh/chị nhắn lại em một câu nữa giúp em nhận diện nhé (lần đầu cần 1 nhịp)."; (b) if truly in a DM → "@nhắc em TRONG nhóm công ty."stage: getChat → "Em chưa vào được nhóm — thêm em vào nhóm giúp em."stage: forum → "Nhóm chưa bật Topics — vào Manage Group bật Topics rồi nhắn lại em."stage: permission → read hint and state CLEARLY: bot is admin but 'Manage Topics' permission not enabled — guide user to Manage Group → Administrators → select bot → enable that toggle. (Common error: admin ≠ automatically having this permission.)stage: departments → ask the user which departments they want, then run: python3 lib/setup_departments.py --departments "Phòng A, Phòng B, Phòng C".Right after departments are set up (ok:true), proactively offer icon customization — this is the moment to show the user the assistant both suggests and executes:
1. Run python3 lib/customize_icons.py suggest → returns JSON suggestions[], each department has emoji + thread_id + custom_emoji_id.
2. Present to the user (partner proposing): list "Phòng X → clarify: [Dùng bộ icon này] [Đổi vài cái].
3. User approves → run python3 lib/customize_icons.py apply --json '<exact suggestions array just received>' → bot changes the real icons (AI executes). Report "đã đổi icon xong".
4. User wants to change one department (e.g. "Marketing thành 🔥") → python3 lib/tg_topics.py icons --find 🔥 to get custom_emoji_id → edit that entry in the array → apply again. (Can also change the department name at the same time via the name field.)
🚫 Icon is SEPARATE (via
custom_emoji_id) — NEVER put emoji in thenamefield (causes duplication: emoji-in-name + icon). Department name is text only; the script strips emoji if any slips in. This demonstrates the "AI 3 roles": guide + partner proposing + executor. Keep it tight, one sentence at a time.
Run: python3 lib/setup_departments.py --departments "<department names, comma-separated>".