ส่งข้อความ

นักพัฒนาสามารถส่งข้อความไปยังการสนทนาที่ระบุผ่าน API ได้

วิธีคำขอ

POST

ที่อยู่เรียกใช้

https://livedesk-api.engagelab.com/api/v2/accounts/conversations/:conversation_id/messages

การยืนยันตัวตน

ดูรายละเอียดที่ ภาพรวม API เกี่ยวกับวิธีการยืนยันตัวตน

คำขอข้อความตัวอักษรปกติ

ตัวอย่างคำขอ

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": "ข้อความจากเจ้าหน้าที่ ส่งได้ปกติไหม", "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": "ข้อความจากเจ้าหน้าที่ ส่งได้ปกติไหม",  
    "private": false,
    "content_attributes": {
        "in_reply_to": 29   
    }
}'

            
โค้ดนี้โชว์เป็นหน้าต่างลอย

ส่วนหัวคำขอ

ฟิลด์ ชนิด คำอธิบาย
Authorization string ใช้ Authorization: Basic base64(API Key:API Secret) สำหรับการยืนยัน โปรดไปที่หน้าคีย์ API เพื่อรับ API Key และ API Secret และเชื่อมทั้งสองด้วยโคลอนก่อนเข้ารหัส Base64
Content-Type application/json ประเภทข้อมูล สำหรับข้อความตัวอักษรใช้ application/json

พารามิเตอร์เส้นทาง

ฟิลด์ ชนิด จำเป็น คำอธิบาย
conversation_id string ใช่ ID การสนทนา

พารามิเตอร์ในคำขอ

ฟิลด์ ชนิด จำเป็น คำอธิบาย
content String ใช่ เนื้อหาข้อความ
private Boolean ไม่ เป็นข้อความส่วนตัวหรือไม่ ค่าเริ่มต้น false
content_attributes Object ไม่ คุณสมบัติเนื้อหา เช่นระบุ ID ข้อความที่ตอบกลับด้วย in_reply_to

ตัวอย่างการตอบกลับข้อความตัวอักษร

ตอบกลับสำเร็จ

{ "id": 3030, "content": "ข้อความจากเจ้าหน้าที่ ส่งได้ปกติไหม", "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": "ข้อความจากเจ้าหน้าที่ ส่งได้ปกติไหม",
    "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 Int ID ข้อความ
content String เนื้อหาข้อความ
inbox_id Int ID กล่องจดหมาย
conversation_id Int ID การสนทนา
message_type Int ประเภทข้อความ
content_type String ประเภทเนื้อหา
status String สถานะข้อความ เช่น "sent", "delivered"
content_attributes Object คุณสมบัติเนื้อหา
created_at Int เวลาเกิดข้อความ (timestamp)
private Boolean เป็นข้อความส่วนตัวหรือไม่
source_id Int ID แหล่งที่มา
sorting_id Int ID สำหรับจัดเรียง
sender Object ข้อมูลผู้ส่ง
id Int ID ผู้ส่ง
name String ชื่อผู้ส่ง
available_name String ชื่อที่แสดงของผู้ส่ง
avatar_url String URL รูปโปรไฟล์
type String ประเภทผู้ส่ง (เช่น user)
availability_status String สถานะออนไลน์ของผู้ส่ง (เช่น offline)
thumbnail String รูปย่อ

คำขอไฟล์รูปภาพ/เสียง ฯลฯ

ตัวอย่างคำขอ

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=รายละเอียดภาพตามนี้"
              
              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=รายละเอียดภาพตามนี้" 

            
โค้ดนี้โชว์เป็นหน้าต่างลอย

พารามิเตอร์เส้นทาง

ฟิลด์ ชนิด จำเป็น คำอธิบาย
conversation_id string ใช่ ID การสนทนา

ตัวอย่างการตอบกลับไฟล์รูปภาพ/เสียง ฯลฯ

ตอบกลับสำเร็จ

{ "id": 3031, "content": "รายละเอียดภาพตามนี้", "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": "รายละเอียดภาพตามนี้",
    "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 Int ID ข้อความ
content String เนื้อหาข้อความ
inbox_id Int ID กล่องจดหมาย
conversation_id Int ID การสนทนา
message_type Int ประเภทข้อความ
content_type String ประเภทเนื้อหา
status String สถานะข้อความ เช่น "sent", "delivered"
content_attributes Object คุณสมบัติเนื้อหา
created_at Int เวลาเกิดข้อความ (timestamp)
private Boolean เป็นข้อความส่วนตัวหรือไม่
source_id Int ID แหล่งที่มา
sorting_id Int ID สำหรับจัดเรียง
sender Object ข้อมูลผู้ส่ง
id Int ID ผู้ส่ง
name String ชื่อผู้ส่ง
available_name String ชื่อที่แสดงของผู้ส่ง
avatar_url String URL รูปโปรไฟล์
type String ประเภทผู้ส่ง (เช่น user)
availability_status String สถานะออนไลน์ของผู้ส่ง (เช่น offline)
thumbnail String รูปย่อ
attachments Array รายการข้อมูลไฟล์แนบ
id Int ID ไฟล์แนบ
message_id Int ID ข้อความที่เป็นเจ้าของ
file_type String ประเภทไฟล์ (เช่น image)
account_id Int ID บัญชี
extension String นามสกุลไฟล์
data_url String URL ไฟล์
thumb_url String URL รูปย่อ (เฉพาะภาพ)
file_size Int ขนาดไฟล์ (ไบต์)
width Int ความกว้าง (เฉพาะภาพ)
height Int ความสูง (เฉพาะภาพ)
icon
ติดต่อฝ่ายขาย