Endpoint notification dipanggil oleh backend Dazo untuk mendorong event ke frontend via Socket.IO. Endpoint ini adalah relay — engine tidak menyimpan data, hanya meneruskan ke client yang terhubung.
POST /api/push-notif — Push notifikasi
Handler: NotificationController.pushNotif (src/controller/NotificationController.ts:7)
Emit ke: room store_id → event pushnotif
Request fields
| Field | Wajib | Tipe | Catatan |
|---|---|---|---|
id | ✅ | string | ID notifikasi |
store_id | ✅ | string | ID store — dipakai sebagai room Socket.IO |
type | ✅ | string | Tipe notifikasi |
roles | ✅ | string | Comma-separated, mis. "admin,cs" — di-split jadi array |
team_ids | ✅ | string | Comma-separated, mis. "1,2,3" — di-split jadi array |
created_at | ✅ | string | Timestamp |
notification | ✅ | string|object | JSON string atau object — di-parse jika string |
data | ✅ | string|object | JSON string atau object — di-parse jika string |
Contoh request
{
"id": "notif-1",
"store_id": "store-456",
"type": "new_order",
"roles": "admin,cs",
"team_ids": "1,2",
"created_at": "2024-01-15T10:30:00Z",
"notification": { "title": "Order Baru", "body": "Order #123" },
"data": { "order_id": "123", "amount": 150000 }
}Response
{
"success": true,
"message": "Berhasil Push Notif!",
"data": { "result": true, "message": "Berhasil Push Notif!" }
}Socket payload (yang di-emit)
{
"id": "notif-1",
"store_id": "store-456",
"type": "new_order",
"roles": ["admin", "cs"],
"team_ids": ["1", "2"],
"created_at": "2024-01-15T10:30:00Z",
"notification": { "title": "Order Baru", "body": "Order #123" },
"readers": [],
"data": { "order_id": "123", "amount": 150000 }
}POST /api/update-chatlist — Update chat list
Handler: NotificationController.updateChatlist (src/controller/NotificationController.ts:19)
Emit ke: room instance → event updatechatlist + updatechatlist_bubble
Request fields
| Field | Wajib | Tipe | Catatan |
|---|---|---|---|
team_origin | ✅ | string | Team asal |
team_destination | ✅ | string | Team tujuan |
nohp | ✅ | string | Nomor HP |
instance | ✅ | string | instanceId — dipakai sebagai room Socket.IO |
actionid | ✅ | string | ID aksi |
mode | ✅ | string | Mode |
data | ✅ | string|object | JSON string atau object — di-parse jika string |
Contoh request
{
"team_origin": "team-1",
"team_destination": "team-2",
"nohp": "628123456789",
"instance": "0c1a968c-...",
"actionid": "action-1",
"mode": "assign",
"data": { "chat_id": "chat-1" }
}Socket payload (yang di-emit)
{
"type": "updatechatlist",
"team_origin": "team-1",
"team_destination": "team-2",
"nohp": "628123456789",
"instance": "0c1a968c-...",
"actionid": "action-1",
"mode": "assign",
"data": { "chat_id": "chat-1" }
}Event dipancarkan dua kali — updatechatlist dan updatechatlist_bubble (pola _bubble). Lihat Realtime Events.
POST /api/update-teamchat — Update team chat
Handler: NotificationController.updateTeamChat (src/controller/NotificationController.ts:30)
Emit ke: global (semua client) → event updateTeamchat
Request fields
| Field | Wajib | Tipe | Catatan |
|---|---|---|---|
type | ✅ | string | Tipe pesan |
id | ✅ | string | ID pesan |
message | ✅ | string | Isi pesan |
name | ✅ | string | Nama pengirim |
image | ✅ | string | URL gambar |
team_id | ✅ | string | ID team |
data | ✅ | string | JSON string |
partisipan | ✅ | string | JSON string |
mode | ✅ | string | Mode |
reader | ✅ | string | Status reader |
date | ✅ | any | Timestamp |
Contoh request
{
"type": "text",
"id": "msg-1",
"message": "Halo tim!",
"name": "Budi",
"image": "",
"team_id": "team-1",
"data": "{}",
"partisipan": "[\"628111\",\"628222\"]",
"mode": "send",
"reader": "",
"date": "2024-01-15T10:30:00Z"
}Socket payload (yang di-emit)
{
"type": "text",
"id": "msg-1",
"message": "Halo tim!",
"name": "Budi",
"image": "",
"team_id": "team-1",
"partisipan": "[\"628111\",\"628222\"]",
"mode": "send",
"reader": "",
"date": "2024-01-15T10:30:00Z"
}POST /api/submit-pixel — Submit Facebook Pixel
Handler: NotificationController.submitPixel (src/controller/NotificationController.ts:42)
Emit ke: — (tidak emit Socket.IO, kirim ke Facebook Graph API)
Request fields
| Field | Wajib | Tipe | Catatan |
|---|---|---|---|
pixel_data | ✅ | string | JSON string array — [{ code, event_name, nohp, access_token }] |
Contoh request
{
"pixel_data": "[{\"code\":\"123\",\"event_name\":\"Purchase\",\"nohp\":\"628123456789\",\"access_token\":\"EAAG...\"}]"
}Response
{
"success": true,
"message": "Berhasi Submit Pixel",
"data": { "result": true, "message": "Berhasil Submit Pixel" }
}Aksi service
NotificationService.submitPixel (src/service/notificationService.ts:147-161):
JSON.parse(pixel_data)→ array- Loop setiap element → panggil
submitPixelFunction(element) submitPixelFunctionkirim ke Facebook Graph API v19.0:
const pixel_uri = `https://graph.facebook.com/v19.0/${data.code}/events`;
const data_post = {
data: [{
action_source: 'chat',
event_id: data.event_name,
event_name: data.event_name,
event_time: Math.floor(Date.now() / 1000),
event_source_url: 'https://dazo.id',
user_data: { ph: data.nohp }
}],
access_token: data.access_token
};
await axios.post(pixel_uri, data_post, options);Catatan
- Semua endpoint notification return
success: trueselain service throw error — error handling minimal rolesdanteam_idsdi-push-notif harus comma-separated string (bukan array)updateTeamchatadalah satu-satunya event global — tidak perlu join roomsubmit-pixeltidak emit Socket.IO — hanya kirim ke Facebook- Tidak ada validasi shape payload — backend Dazo diharapkan kirim format yang benar
Langkah berikutnya
- Detail event Socket.IO? Baca Realtime Events.
- Webhook keluar? Baca Webhook Reference.
- Kembali ke API Reference.