Modul live chat menangani inbound pesan WhatsApp, assignment CS, rotasi, handling gudang, dan capture order otomatis dari pesan.
File kunci
| File | Baris | Peran |
|---|---|---|
app/Http/Controllers/LiveChatController.php | 1.081 | Read chat_list/chat_inbox, rotator CS, order capture, handling gudang |
resources/js/Pages/LiveChat/Index.vue | 6.428 | UI penuh live chat |
app/Models/ChatList.php | 30 | Model — deklarasi MongoDB tapi data di MySQL |
app/Models/ChatHistory.php | 24 | Riwayat sesi chat (MongoDB) |
app/Models/ChatOrder.php | 26 | Order sementara dari chat (MongoDB) |
app/Models/ChatCheckout.php | 24 | Checkout dari chat (MongoDB) |
Alur data inbound
- Engine WA terima pesan → tulis ke
chat_inbox(MySQL) + updatechat_list - Frontend polling
POST {url_api}chat_list(backend Go) → daftar chat - User klik chat →
POST {url_api}chat_inbox(offset/limit) → pesan - Saat
getInbox(Laravel), juga:autoChatOrder(match product) → buatChatOrder;chaptureAddress(parse alamat) → update ChatOrder;saveChatHistory;markReadChat - Rotator CS (
getRotator) saat chat baru:Setting.globalAssignation→ pilih team_id
Chat models — perbedaan
| Model | Sumber data | Peran |
|---|---|---|
ChatList | MySQL (chat_list table, ditulis engine WA) | Daftar percakapan aktif (inbox view) |
ChatHistory | MongoDB | Riwayat sesi chat (open/close, move history) |
ChatOrder | MongoDB | Order sementara dari percakapan |
ChatCheckout | MongoDB | Checkout dari percakapan |
Controller method utama
Read
| Method | Fungsi |
|---|---|
getChatList | Daftar chat_list dengan filter role + keyword + status |
getInbox | Ambil chat_inbox per nohp+instance + autoChatOrder + chaptureAddress |
getChatDetail/{id} | Data customer + reputation |
getRotator | Pilih CS assignment (mode percentage / same) |
checkDeviceIsIntegrasiAgent | Cek device.agent_id (terhubung AI?) |
Write
| Method | Fungsi |
|---|---|
createChatList | Buat ChatList baru |
saveAttachment | Upload file ke S3 |
autoChatOrder | Parse pesan, match product_code/url, buat ChatOrder |
chaptureAddress | Parse “Provinsi: … Kota: …” → update ChatOrder |
requestHandleGudang | Assign ke Gudang, chat_status='handling' |
finishHandleGudang | Selesai handling, kembalikan ke CS |
moveChat | Pindah chat ke CS lain (chat_list + chat_inbox + ChatOrder + Order.team_id) |
finishChat | Tutup sesi |
Route
Web (routes/web.php:139)
| Method | Path | Fungsi |
|---|---|---|
| GET | /live-chat | Halaman utama |
API (routes/api.php:98)
Prefix /livechat:
| Method | Path | Fungsi |
|---|---|---|
| GET | /livechat/get-group | List chat group |
| POST | /livechat/get-new | Deteksi pesan baru |
| POST | /livechat/get-list | Daftar chat_list |
| GET | /livechat/chat-detail/{id} | Detail customer |
| POST | /livechat/get-inbox | Ambil inbox |
| POST | /livechat/finish | Tutup sesi |
| POST | /livechat/handling-gudang | Assign ke gudang |
| POST | /livechat/move | Pindah chat |
| POST | /livechat/get-rotator | CS assignment |
Integrasi
| Service | Endpoint | Untuk |
|---|---|---|
MySQL chat_list & chat_inbox | connectSqlDB($table) | Source of truth pesan |
Engine WA (url_engine) | POST /update-chatlist | Notifikasi saat finish/handling/move |
Backend Go (url_api) | chat_list, chat_inbox, send_message, dll | Frontend panggil langsung via axios |
| AWS S3 | Storage::disk('s3') | Upload attachment |
Temuan
requestHandleGudangbug — loop menimpa$data_inputtiap iterasi tanpa simpan. Asumsi “kirim ke semua gudang” tidak tercapaigetRotatormodesamebug — loop tanpabreak,$team_idselalu berisi team terakhirchaptureAddressparser rapuh —explode(':', $pesan)asumsikan urutan field kaku. FieldAlamat Lengkapyang mengandung:akan rusak- URL engine WA tidak konsisten — LiveChatController pakai
engine.dazo.id, AgentAiController pakaiengine-wa.dazo.id