Kirim Pesan
Developer dapat mengirim pesan ke conversation_id tertentu melalui API.
Metode Permintaan
POST
URL Permintaan
https://livedesk-api.engagelab.com/api/v2/accounts/conversations/:conversation_id/messages
Autentikasi
Untuk detailnya, lihat panduan autentikasi di Ikhtisar API.
Permintaan Teks Biasa
Contoh Permintaan
curl -X POST 'https://livedesk-api.engagelab.com/api/v2/accounts/conversations/:conversation_id/messages' \
-H 'Content-Type: application/json' \
-H 'Authorization: Basic base64(api_key:api_secret)' \
-d '{
"content": "Layanan pelanggan sedang mengirim pesan. Apakah ini normal?",
"private": false,
"content_attributes": {
"in_reply_to": 29
}
}'
curl -X POST 'https://livedesk-api.engagelab.com/api/v2/accounts/conversations/:conversation_id/messages' \
-H 'Content-Type: application/json' \
-H 'Authorization: Basic base64(api_key:api_secret)' \
-d '{
"content": "Layanan pelanggan sedang mengirim pesan. Apakah ini normal?",
"private": false,
"content_attributes": {
"in_reply_to": 29
}
}'
Tampilkan blok kode ini di jendela mengambang
Header Permintaan
| Field | Type | Description |
|---|---|---|
| Authorization | string | Autentikasi menggunakan Authorization: Basic base64(API Key:API Secret). Buka halaman API Keys untuk mendapatkan API Key dan API Secret, gabungkan keduanya dengan tanda titik dua, lalu encode ke dalam Base64. |
| Content-Type | application/json | Tipe data. Gunakan application/json untuk pesan teks biasa. |
Parameter Path
| Field | Type | Required | Description |
|---|---|---|---|
| conversation_id | string | Yes | ID percakapan. |
Parameter Body Permintaan
| Field | Type | Required | Description |
|---|---|---|---|
| content | String | Yes | Konten pesan. |
| private | Boolean | No | Menentukan apakah pesan bersifat privat. Nilai default adalah false. |
| content_attributes | Object | No | Atribut konten. Misalnya, saat membalas pesan, gunakan field in_reply_to untuk menentukan ID pesan. |
Contoh Respons Teks Biasa
Contoh Respons
{
"id": 3030,
"content": "Layanan pelanggan sedang mengirim pesan. Apakah ini normal?",
"inbox_id": 79,
"conversation_id": 141,
"message_type": 1,
"content_type": "text",
"status": "sent",
"content_attributes": {},
"created_at": 1762331029,
"private": false,
"source_id": null,
"sorting_id": 4,
"sender": {
"id": 3,
"name": "TEST",
"available_name": "TEST",
"avatar_url": "",
"type": "user",
"availability_status": "offline",
"thumbnail": ""
}
}
{
"id": 3030,
"content": "Layanan pelanggan sedang mengirim pesan. Apakah ini normal?",
"inbox_id": 79,
"conversation_id": 141,
"message_type": 1,
"content_type": "text",
"status": "sent",
"content_attributes": {},
"created_at": 1762331029,
"private": false,
"source_id": null,
"sorting_id": 4,
"sender": {
"id": 3,
"name": "TEST",
"available_name": "TEST",
"avatar_url": "",
"type": "user",
"availability_status": "offline",
"thumbnail": ""
}
}
Tampilkan blok kode ini di jendela mengambang
Parameter Respons
| Field | Type | Description |
|---|---|---|
| id | Int | ID pesan. |
| content | String | Konten pesan. |
| inbox_id | Int | ID kotak masuk. |
| conversation_id | Int | ID percakapan. |
| message_type | Int | Tipe pesan. |
| content_type | String | Tipe konten. |
| status | String | Status pesan, seperti sent atau delivered. |
| content_attributes | Object | Atribut konten. |
| created_at | Int | Timestamp pembuatan pesan. |
| private | Boolean | Menentukan apakah pesan bersifat privat. |
| source_id | Int | ID sumber. |
| sorting_id | Int | ID pengurutan. |
| sender | Object | Informasi pengirim. |
| sender.id | Int | ID pengirim. |
| sender.name | String | Nama pengirim. |
| sender.available_name | String | Nama tampilan pengirim. |
| sender.avatar_url | String | URL avatar pengirim. |
| sender.type | String | Tipe pengirim, seperti user. |
| sender.availability_status | String | Status online pengirim, seperti offline. |
| sender.thumbnail | String | Thumbnail pengirim. |
Permintaan Gambar, Audio, dan File Lainnya
Contoh Permintaan
curl -X POST "https://livedesk.engagelab.com/api/v2/accounts/conversations/:conversation_id/messages" \
-H "Authorization: Basic base64(api_key:api_secret)" \
-F "attachments[]=@attachments[]=@/path/to/your/file.jpg" \
-F "content=Gambar detail di bawah"
curl -X POST "https://livedesk.engagelab.com/api/v2/accounts/conversations/:conversation_id/messages" \
-H "Authorization: Basic base64(api_key:api_secret)" \
-F "attachments[]=@attachments[]=@/path/to/your/file.jpg" \
-F "content=Gambar detail di bawah"
Tampilkan blok kode ini di jendela mengambang
Parameter Path
| Field | Type | Required | Description |
|---|---|---|---|
| conversation_id | string | Yes | ID percakapan. |
Contoh Respons Gambar, Audio, dan File Lainnya
Contoh Respons
{
"id": 3031,
"content": "Gambar detail di bawah",
"inbox_id": 79,
"conversation_id": 141,
"message_type": 1,
"content_type": "text",
"status": "sent",
"content_attributes": {},
"created_at": 1762331762,
"private": false,
"source_id": null,
"sorting_id": 5,
"sender": {
"id": 3,
"name": "Wenjie Yu",
"available_name": "Wenjie Yu",
"avatar_url": "",
"type": "user",
"availability_status": "offline",
"thumbnail": ""
},
"attachments": [
{
"id": 199,
"message_id": 3031,
"file_type": "image",
"account_id": 14,
"extension": null,
"data_url": "https://livedesk.engagelab.com/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBamNUIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--727ba7469d64f90790d242c743f254b5c9013fe1/android-icon-48x48.png",
"thumb_url": "https://livedesk.engagelab.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBamNUIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--727ba7469d64f90790d242c743f254b5c9013fe1/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBTU0lJY0c1bkJqb0dSVlE2RTNKbGMybDZaVjkwYjE5bWFXeHNXd2RwQWZvdyIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--63c890cbf173eb3dc92a8786fcc3e120c329852d/android-icon-48x48.png",
"file_size": 589136,
"width": null,
"height": null
}
]
}
{
"id": 3031,
"content": "Gambar detail di bawah",
"inbox_id": 79,
"conversation_id": 141,
"message_type": 1,
"content_type": "text",
"status": "sent",
"content_attributes": {},
"created_at": 1762331762,
"private": false,
"source_id": null,
"sorting_id": 5,
"sender": {
"id": 3,
"name": "Wenjie Yu",
"available_name": "Wenjie Yu",
"avatar_url": "",
"type": "user",
"availability_status": "offline",
"thumbnail": ""
},
"attachments": [
{
"id": 199,
"message_id": 3031,
"file_type": "image",
"account_id": 14,
"extension": null,
"data_url": "https://livedesk.engagelab.com/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBamNUIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--727ba7469d64f90790d242c743f254b5c9013fe1/android-icon-48x48.png",
"thumb_url": "https://livedesk.engagelab.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBamNUIiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--727ba7469d64f90790d242c743f254b5c9013fe1/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBTU0lJY0c1bkJqb0dSVlE2RTNKbGMybDZaVjkwYjE5bWFXeHNXd2RwQWZvdyIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--63c890cbf173eb3dc92a8786fcc3e120c329852d/android-icon-48x48.png",
"file_size": 589136,
"width": null,
"height": null
}
]
}
Tampilkan blok kode ini di jendela mengambang
Parameter Respons
| Field | Type | Description |
|---|---|---|
| id | Int | ID pesan. |
| content | String | Konten pesan. |
| inbox_id | Int | ID kotak masuk. |
| conversation_id | Int | ID percakapan. |
| message_type | Int | Tipe pesan. |
| content_type | String | Tipe konten. |
| status | String | Status pesan, seperti sent atau delivered. |
| content_attributes | Object | Atribut konten. |
| created_at | Int | Timestamp pembuatan pesan. |
| private | Boolean | Menentukan apakah pesan bersifat privat. |
| source_id | Int | ID sumber. |
| sorting_id | Int | ID pengurutan. |
| sender | Object | Informasi pengirim. |
| sender.id | Int | ID pengirim. |
| sender.name | String | Nama pengirim. |
| sender.available_name | String | Nama tampilan pengirim. |
| sender.avatar_url | String | URL avatar pengirim. |
| sender.type | String | Tipe pengirim, seperti user. |
| sender.availability_status | String | Status online pengirim, seperti offline. |
| sender.thumbnail | String | Thumbnail pengirim. |
| attachments | Array | Daftar informasi lampiran. |
| attachments.id | Int | ID lampiran. |
| attachments.message_id | Int | ID pesan terkait. |
| attachments.file_type | String | Tipe file, seperti image. |
| attachments.account_id | Int | ID akun. |
| attachments.extension | String | Ekstensi file. |
| attachments.data_url | String | URL file. |
| attachments.thumb_url | String | URL thumbnail (khusus tipe gambar). |
| attachments.file_size | Int | Ukuran file dalam byte. |
| attachments.width | Int | Lebar file (khusus tipe gambar). |
| attachments.height | Int | Tinggi file (khusus tipe gambar). |
Contoh Permintaan Pesan Template WhatsApp
Contoh Permintaan
curl -X POST 'https://livedesk.engagelab.com/api/v2/accounts/conversations/:conversation_id/messages'\
-H 'Content-Type: application/json' \
-H 'Authorization: Basic base64(api_key:api_secret)'\
-d '{
"content": "Tampilkan teks untuk UI chat",
"message_type": "outgoing",
"template_params": {
"name": "order_update",
"namespace": "optional_namespace",
"language": "en_US",
"category": "MARKETING",
"processed_params": {
"1": "John",
"2": "dikirim"
},
"header_params": {
"type": "text",
"text_variables": {
"1": "Pesanan #456" }
},
"footer_params": {
"text_variables": { "1": "Acme Corp" }
},
"button_params": [
{
"index": 0,
"sub_type": "url",
"text": "track/12345"
}
]
}
}'
curl -X POST 'https://livedesk.engagelab.com/api/v2/accounts/conversations/:conversation_id/messages'\
-H 'Content-Type: application/json' \
-H 'Authorization: Basic base64(api_key:api_secret)'\
-d '{
"content": "Tampilkan teks untuk UI chat",
"message_type": "outgoing",
"template_params": {
"name": "order_update",
"namespace": "optional_namespace",
"language": "en_US",
"category": "MARKETING",
"processed_params": {
"1": "John",
"2": "dikirim"
},
"header_params": {
"type": "text",
"text_variables": {
"1": "Pesanan #456" }
},
"footer_params": {
"text_variables": { "1": "Acme Corp" }
},
"button_params": [
{
"index": 0,
"sub_type": "url",
"text": "track/12345"
}
]
}
}'
Tampilkan blok kode ini di jendela mengambang
Parameter Path
| Field | Type | Required | Description |
|---|---|---|---|
| conversation_id | string | Yes | ID percakapan. |
Parameter Body Permintaan
| Field | Type | Required | Description |
|---|---|---|---|
| content | String | Yes | Konten pesan yang ditampilkan di antarmuka chat. |
| message_type | String | Yes | Tipe pesan. Saat mengirim pesan template, atur ke outgoing. |
| template_params | Object | Yes | Objek parameter pesan template. |
| template_params.name | String | Yes | Nama template. |
| template_params.namespace | String | No | Namespace template (digunakan oleh WhatsApp Cloud / 360Dialog). |
| template_params.language | String | Yes | Kode bahasa template, seperti en_US. |
| template_params.category | String | No | Kategori template, seperti MARKETING. |
| template_params.processed_params | Object | No | Nilai variabel body template. Key adalah posisi variabel ("1", "2") atau nama variabel. |
| template_params.header_params | Object | No | Parameter komponen header template. Lihat penjelasan di bawah. |
| template_params.footer_params | Object | No | Parameter komponen footer template. Lihat penjelasan di bawah. |
| template_params.button_params | Array | No | Parameter komponen tombol template. Lihat penjelasan di bawah. |
Deskripsi Parameter header_params
Struktur header_params bervariasi tergantung pada tipe header:
Tipe teks:
{
"type": "text",
"text_variables": { "1": "Pesanan #456" }
}
{
"type": "text",
"text_variables": { "1": "Pesanan #456" }
}
Tampilkan blok kode ini di jendela mengambang
Tipe gambar:
{
"type": "image",
"media_url": "https://example.com/image.jpg"
}
{
"type": "image",
"media_url": "https://example.com/image.jpg"
}
Tampilkan blok kode ini di jendela mengambang
Tipe video:
{
"type": "video",
"media_url": "https://example.com/video.mp4"
}
{
"type": "video",
"media_url": "https://example.com/video.mp4"
}
Tampilkan blok kode ini di jendela mengambang
Tipe file:
{
"type": "document",
"media_url": "https://example.com/invoice.pdf",
"filename": "invoice.pdf"
}
{
"type": "document",
"media_url": "https://example.com/invoice.pdf",
"filename": "invoice.pdf"
}
Tampilkan blok kode ini di jendela mengambang
Tipe lokasi:
{
"type": "location",
"location": {
"latitude": 37.7749,
"longitude": -122.4194,
"name": "Kantor Pusat Acme",
"address": "123 Main St, San Francisco"
}
}
{
"type": "location",
"location": {
"latitude": 37.7749,
"longitude": -122.4194,
"name": "Kantor Pusat Acme",
"address": "123 Main St, San Francisco"
}
}
Tampilkan blok kode ini di jendela mengambang
| Field | Type | Required | Description |
|---|---|---|---|
| type | String | Yes | Tipe header. Nilai yang didukung: text, image, video, document, location. |
| text_variables | Object | No | Digunakan untuk tipe teks. Key adalah posisi variabel, dan value adalah konten pengganti. |
| media_url | String | No | Digunakan untuk tipe media. URL file media. |
| filename | String | No | Digunakan untuk tipe file. Nama file. |
| location | Object | No | Digunakan untuk tipe lokasi. |
| location.latitude | Float | Yes | Latitude. |
| location.longitude | Float | Yes | Longitude. |
| location.name | String | No | Nama lokasi. |
| location.address | String | No | Alamat lokasi. |
Deskripsi Parameter footer_params
{
"text_variables": { "1": "Acme Corp" }
}
{
"text_variables": { "1": "Acme Corp" }
}
Tampilkan blok kode ini di jendela mengambang
| Field | Type | Required | Description |
|---|---|---|---|
| text_variables | Object | No | Key adalah posisi variabel, dan value adalah konten pengganti. |
Deskripsi Parameter button_params
[
{
"index": 0,
"sub_type": "url",
"text": "track/12345"
},
{
"index": 1,
"sub_type": "quick_reply",
"payload": "OPT_OUT"
}
]
[
{
"index": 0,
"sub_type": "url",
"text": "track/12345"
},
{
"index": 1,
"sub_type": "quick_reply",
"payload": "OPT_OUT"
}
]
Tampilkan blok kode ini di jendela mengambang
| Field | Type | Required | Description |
|---|---|---|---|
| index | Int | Yes | Indeks tombol, dimulai dari 0. |
| sub_type | String | Yes | Tipe tombol. Nilai yang didukung: url, quick_reply. |
| text | String | No | Digunakan untuk tombol tipe URL. Sufiks URL atau path pengalihan. |
| payload | String | No | Digunakan untuk tombol tipe quick_reply. Konten payload yang dikembalikan. |
Contoh Respons
Respons Berhasil
{
"id": 123,
"content": "Tampilkan teks untuk UI chat",
"message_type": 1,
"status": "sent",
"additional_attributes": {
"template_params": {
"name": "order_update",
"language": "en_US",
"category": "MARKETING"
}
}
}
{
"id": 123,
"content": "Tampilkan teks untuk UI chat",
"message_type": 1,
"status": "sent",
"additional_attributes": {
"template_params": {
"name": "order_update",
"language": "en_US",
"category": "MARKETING"
}
}
}
Tampilkan blok kode ini di jendela mengambang
Respons Gagal
{
"id": 123,
"status": "failed",
"content_attributes": {
"external_error": "131047: Re-engagement message is not allowed"
}
}
{
"id": 123,
"status": "failed",
"content_attributes": {
"external_error": "131047: Re-engagement message is not allowed"
}
}
Tampilkan blok kode ini di jendela mengambang
Parameter Respons
| Field | Type | Description |
|---|---|---|
| id | Int | ID pesan. |
| content | String | Konten pesan. |
| message_type | Int | Tipe pesan. |
| status | String | Status pesan, seperti sent, delivered, atau failed. |
| additional_attributes | Object | Atribut tambahan. |
| additional_attributes.template_params | Object | Informasi tentang parameter template yang dikirim. |
| content_attributes | Object | Atribut konten. Berisi informasi kesalahan saat pengiriman gagal. |
| content_attributes.external_error | String | Informasi kesalahan eksternal yang dikembalikan saat pengiriman pesan gagal. |
Coba Ulang Pesan yang Gagal
Jika status pesan adalah failed, gunakan endpoint berikut untuk mereset status pesan dan mengirimkannya kembali:
URL Permintaan
POST https://livedesk-api.engagelab.com/api/v2/accounts/conversations/:conversation_id/messages/:message_id/retry
Parameter Path
| Field | Type | Required | Description |
|---|---|---|---|
| conversation_id | string | Yes | ID percakapan. |
| message_id | string | Yes | ID pesan. |










