ข้ามไปที่เนื้อหา

Reports (📋) — Agent Performance

วิเคราะห์ประสิทธิภาพทีม — leaderboard, ตารางต่อ agent, CSV export

ภาพรวม

หมายเลขในรูป:

  1. Sidebar — Reports active
  2. Period + Export CSV — download .csv (BOM-encoded รองรับ Thai)
  3. 3 stat cards — เคสปิด 18 / ข้อความส่ง 1,550 / agents active 6
  4. Leaderboard 30 วัน — 🥇 Admin (ปิด 10 / 330 msg) · 🥈 สมชาย (3/540) · 🥉 สมหญิง (2/400)
  5. ตารางรายบุคคล — sortable columns: ข้อความส่ง / สนทนา / ปิดเคส / AVG ตอบแรก / AVG ปิด / msg/case / ปิดเร็ว / MSG bar

URL: /reports ปุ่มเข้าถึง: Dashboard → Reports tab

หน้านี้แสดง:

  • Stat cards — เคสที่ปิด, ข้อความที่ส่ง, agents active
  • 🏆 Leaderboard — top 3 (🥇🥈🥉) ตามจำนวนปิดเคส
  • 📋 ตารางรายบุคคล — ทุก agent + KPIs sortable
  • ⬇ Export CSV — download รายงานเต็ม (BOM-encoded รองรับ Thai)

Period

7 วัน (default) / 30 วัน / 90 วัน — มุมบนขวา

Stat cards

Card Source
✅ เคสที่ปิดแล้ว (30 วัน) COUNT(conversations WHERE closed_at IN period)
📤 ข้อความที่ส่งทั้งหมด COUNT(messages WHERE sender_type='agent')
👥 Agent ที่ active DISTINCT agent_id ที่มี message ใน period

Leaderboard

🥇 สมชาย ใจดี       ปิด 10 เคส · 330 ข้อความ
🥈 สมหญิง รักงาน    ปิด 7 เคส · 280 ข้อความ
🥉 อนุชา พรหมมา     ปิด 5 เคส · 220 ข้อความ

แสดง top 3 ของ period

ตารางรายบุคคล

Columns (sortable):

Column คำอธิบาย
AGENT avatar + name
ข้อความส่ง COUNT messages from agent
สนทนา DISTINCT conversation_id
ปิดเคส COUNT closed_by = agent_id
AVG ตอบแรก mean(first_response_at - first_customer_msg_at)
AVG ปิดเคส mean(closed_at - created_at)
ข้อความ/เคส msgs / conversations
ปิดเร็ว ⚡ percentile of fast closures
MSG BAR visual bar chart

Color coding:

  • AVG ตอบแรก ≤ 15 นาที = 🟢 เขียว
  • ≤ 30 นาที = 🟡 เหลือง
  • 30 นาที = 🔴 แดง

Export CSV

กด ⬇ Export CSV → download reports-YYYY-MM-DD.csv:

  • BOM-encoded (UTF-8 with BOM) → Excel เปิด Thai ถูก
  • All columns + period range header
  • ใช้ทำรายงานสรุปประจำเดือน

Use cases

HR / Manager review:

  • ดูใครปิดเคสมากสุด → bonus / promotion
  • ดูใคร AVG ตอบช้า → coaching
  • เปรียบเทียบ period — ทีมพัฒนาขึ้นไหม

Capacity planning:

  • Volume สูงสุดวันไหน → จัด shift
  • AVG ตอบ + ปิดเคส = customer satisfaction proxy

คำถามที่พบบ่อย

Agent คนใหม่ไม่อยู่ใน table

Reports filter เฉพาะ agent ที่มี message ใน period — agent ใหม่ที่ยังไม่ตอบใครจะไม่ปรากฏ

AVG ปิดเคส แสดง — แทนที่จะเป็นเวลา

Conversation ปิดน้อยกว่า 1 นาที — บางทีระบบ display "—" แทน 0 นาที

Export CSV เปิดด้วย Excel แล้วภาษาไทยเป็น garbled

ตรวจว่าไฟล์มี BOM (3 bytes แรก = EF BB BF) — ถ้าไม่มี = backend bug, แจ้ง DevOps

ที่อ้างอิง

  • Backend: GET /api/reports/agent-performance?days=30
  • Source: Reports.tsx
  • Dashboard (overview): Dashboard