D
Modul

Live Chat

UI live chat dengan CS rotasi, auto-capture order, dan integrasi engine WA. God component 6.428 baris.

Modul live chat menangani inbound pesan WhatsApp, assignment CS, rotasi, handling gudang, dan capture order otomatis dari pesan.

File kunci

FileBarisPeran
app/Http/Controllers/LiveChatController.php1.081Read chat_list/chat_inbox, rotator CS, order capture, handling gudang
resources/js/Pages/LiveChat/Index.vue6.428UI penuh live chat
app/Models/ChatList.php30Model — deklarasi MongoDB tapi data di MySQL
app/Models/ChatHistory.php24Riwayat sesi chat (MongoDB)
app/Models/ChatOrder.php26Order sementara dari chat (MongoDB)
app/Models/ChatCheckout.php24Checkout dari chat (MongoDB)

Alur data inbound

  1. Engine WA terima pesan → tulis ke chat_inbox (MySQL) + update chat_list
  2. Frontend polling POST {url_api}chat_list (backend Go) → daftar chat
  3. User klik chat → POST {url_api}chat_inbox (offset/limit) → pesan
  4. Saat getInbox (Laravel), juga: autoChatOrder (match product) → buat ChatOrder; chaptureAddress (parse alamat) → update ChatOrder; saveChatHistory; markReadChat
  5. Rotator CS (getRotator) saat chat baru: Setting.globalAssignation → pilih team_id

Chat models — perbedaan

ModelSumber dataPeran
ChatListMySQL (chat_list table, ditulis engine WA)Daftar percakapan aktif (inbox view)
ChatHistoryMongoDBRiwayat sesi chat (open/close, move history)
ChatOrderMongoDBOrder sementara dari percakapan
ChatCheckoutMongoDBCheckout dari percakapan

Controller method utama

Read

MethodFungsi
getChatListDaftar chat_list dengan filter role + keyword + status
getInboxAmbil chat_inbox per nohp+instance + autoChatOrder + chaptureAddress
getChatDetail/{id}Data customer + reputation
getRotatorPilih CS assignment (mode percentage / same)
checkDeviceIsIntegrasiAgentCek device.agent_id (terhubung AI?)

Write

MethodFungsi
createChatListBuat ChatList baru
saveAttachmentUpload file ke S3
autoChatOrderParse pesan, match product_code/url, buat ChatOrder
chaptureAddressParse “Provinsi: … Kota: …” → update ChatOrder
requestHandleGudangAssign ke Gudang, chat_status='handling'
finishHandleGudangSelesai handling, kembalikan ke CS
moveChatPindah chat ke CS lain (chat_list + chat_inbox + ChatOrder + Order.team_id)
finishChatTutup sesi

Route

Web (routes/web.php:139)

MethodPathFungsi
GET/live-chatHalaman utama

API (routes/api.php:98)

Prefix /livechat:

MethodPathFungsi
GET/livechat/get-groupList chat group
POST/livechat/get-newDeteksi pesan baru
POST/livechat/get-listDaftar chat_list
GET/livechat/chat-detail/{id}Detail customer
POST/livechat/get-inboxAmbil inbox
POST/livechat/finishTutup sesi
POST/livechat/handling-gudangAssign ke gudang
POST/livechat/movePindah chat
POST/livechat/get-rotatorCS assignment

Integrasi

ServiceEndpointUntuk
MySQL chat_list & chat_inboxconnectSqlDB($table)Source of truth pesan
Engine WA (url_engine)POST /update-chatlistNotifikasi saat finish/handling/move
Backend Go (url_api)chat_list, chat_inbox, send_message, dllFrontend panggil langsung via axios
AWS S3Storage::disk('s3')Upload attachment

Temuan

  • requestHandleGudang bug — loop menimpa $data_input tiap iterasi tanpa simpan. Asumsi “kirim ke semua gudang” tidak tercapai
  • getRotator mode same bug — loop tanpa break, $team_id selalu berisi team terakhir
  • chaptureAddress parser rapuhexplode(':', $pesan) asumsikan urutan field kaku. Field Alamat Lengkap yang mengandung : akan rusak
  • URL engine WA tidak konsisten — LiveChatController pakai engine.dazo.id, AgentAiController pakai engine-wa.dazo.id