ดูรายละเอียดข้อความในการสนทนา

ดูรายละเอียดข้อความในการสนทนา

ดึงรายละเอียดข้อความทั้งหมดภายในบทสนทนาโดยใช้ conversation_id ผลลัพธ์จะมีทั้ง message_id, คำถามของผู้ใช้, ประเภทข้อความ, เนื้อหาข้อความ, เวลาส่งข้อความ และข้อมูลอื่น ๆ

วิธีการร้องขอ

GET

Endpoint

https://api-${endpoint}.gptbots.ai/v2/messages

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

โปรดดูวิธีการยืนยันตัวตนที่ API Overview

การร้องขอ

ตัวอย่างการร้องขอ

curl -X GET 'https://api-${endpoint}.gptbots.ai/v2/messages?conversation_id=xxxxxx&page=1&page_size=100' \ -H 'Authorization: Bearer ${API Key}'
                      
                      curl -X GET 'https://api-${endpoint}.gptbots.ai/v2/messages?conversation_id=xxxxxx&page=1&page_size=100' \
-H 'Authorization: Bearer ${API Key}'

                    
บล็อกโค้ดนี้ในหน้าต่างลอย

Request Headers

ฟิลด์ ประเภท คำอธิบาย
Authorization Bearer ${API Key} ใช้ Authorization: Bearer ${API Key} สำหรับยืนยันตัวตน รับ API Key ได้จากหน้า API Key

พารามิเตอร์การร้องขอ

ฟิลด์ ประเภท จำเป็นต้องกรอก คำอธิบาย
conversation_id string ใช่ รหัสระบุบทสนทนา
page int ใช่ หมายเลขหน้าที่ต้องการร้องขอ
page_size int ใช่ จำนวนรายการต่อหน้า สูงสุด 100

การตอบกลับ

ตัวอย่างการตอบกลับ

{ "total": 2, "conversation_content": [ { "message_id": "645dd86906931c4a9e0ffb1f", "parent_message_id": "545dd86906931c4a9e0ffb1f", "create_time": 1683871849906, "feedback": "POSITIVE", "source_page": "https://your-site.com/pricing", "sentiment_label": "neutral", "role": "user", "content": [ { "branch_content": [ { "type": "text", "text": "ฉันได้อัปโหลดไฟล์รูปภาพ 2 ไฟล์ กรุณา OCR และส่งกลับเป็น json 2 รายการ" }, { "type": "image", "image": [ { "url": "https://gptbots.ai/example.png", "format": "jpeg", "name": "TAXI1", "size": 1024 }, { "url": "https://gptbots.ai/example.png", "format": "png", "name": "TAXI2", "size": 1024 } ] }, { "type": "audio", "audio": [ { "url": "https://gptbots.ai/example.mp3", "format": "mp3", "name": "example1 audio", "size": 1024 } ] }, { "type": "document", "document": [ { "url": "https://gptbots.ai/example.pdf", "format": "pdf", "name": "example pdf", "size": 1024 } ] } ] } ] }, { "message_id": "745dd86906931c4a9e0ffb1f", "parent_message_id": "645dd86906931c4a9e0ffb1f", "create_time": 1683871849906, "feedback": "POSITIVE", "source_page": "https://your-site.com/pricing", "sentiment_label": "positive", "role": "assistant", "content": [ { "from_component_branch": "1", "branch_content": [ { "type": "text", "text": "สวัสดี มีอะไรให้ช่วยเหลือไหม?" }, { "type": "audio", "audio": [ { "url": "http://gptbots.ai/example.mp3", "transcript": "ข้อความที่ถอดเสียงจากไฟล์เสียง" } ] } ] }, { "from_component_branch": "2", "branch_content": [ { "type": "document", "document": [ { "url": "https://gptbots.ai/example.pdf", "format": "pdf", "name": "example pdf" } ] }, { "type": "image", "image": [ { "url": "https://gptbots.ai/example.png", "format": "png", "name": "TAXI2" } ] } ] } ] } ], "audio_record_url": "https://gptbots.ai/record/full-call.mp3", "user_sender": { "channel_type": "Channel::Whatsapp", "user_id": "+66812345678", "profile": { "name": "John Doe" }, "additional_attributes": {}, "provider": "whatsapp_cloud", "phone_number": "+66900000000" } }
                      
                      {
  "total": 2,
  "conversation_content": [
    {
      "message_id": "645dd86906931c4a9e0ffb1f",
      "parent_message_id": "545dd86906931c4a9e0ffb1f",
      "create_time": 1683871849906,
      "feedback": "POSITIVE",
      "source_page": "https://your-site.com/pricing",
      "sentiment_label": "neutral",
      "role": "user",
      "content": [
        {
          "branch_content": [
            {
              "type": "text",
              "text": "ฉันได้อัปโหลดไฟล์รูปภาพ 2 ไฟล์ กรุณา OCR และส่งกลับเป็น json 2 รายการ"
            },
            {
              "type": "image",
              "image": [
                {
                  "url": "https://gptbots.ai/example.png",
                  "format": "jpeg",
                  "name": "TAXI1",
                  "size": 1024
                },
                {
                  "url": "https://gptbots.ai/example.png",
                  "format": "png",
                  "name": "TAXI2",
                  "size": 1024
                }
              ]
            },
            {
              "type": "audio",
              "audio": [
                {
                  "url": "https://gptbots.ai/example.mp3",
                  "format": "mp3",
                  "name": "example1 audio",
                  "size": 1024
                }
              ]
            },
            {
              "type": "document",
              "document": [
                {
                  "url": "https://gptbots.ai/example.pdf",
                  "format": "pdf",
                  "name": "example pdf",
                  "size": 1024
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "message_id": "745dd86906931c4a9e0ffb1f",
      "parent_message_id": "645dd86906931c4a9e0ffb1f",
      "create_time": 1683871849906,
      "feedback": "POSITIVE",
      "source_page": "https://your-site.com/pricing",
      "sentiment_label": "positive",
      "role": "assistant",
      "content": [
        {
          "from_component_branch": "1",
          "branch_content": [
            {
              "type": "text",
              "text": "สวัสดี มีอะไรให้ช่วยเหลือไหม?"
            },
            {
              "type": "audio",
              "audio": [
                {
                  "url": "http://gptbots.ai/example.mp3",
                  "transcript": "ข้อความที่ถอดเสียงจากไฟล์เสียง"
                }
              ]
            }
          ]
        },
        {
          "from_component_branch": "2",
          "branch_content": [
            {
              "type": "document",
              "document": [
                {
                  "url": "https://gptbots.ai/example.pdf",
                  "format": "pdf",
                  "name": "example pdf"
                }
              ]
            },
            {
              "type": "image",
              "image": [
                {
                  "url": "https://gptbots.ai/example.png",
                  "format": "png",
                  "name": "TAXI2"
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "audio_record_url": "https://gptbots.ai/record/full-call.mp3",
  "user_sender": {
    "channel_type": "Channel::Whatsapp",
    "user_id": "+66812345678",
    "profile": { "name": "John Doe" },
    "additional_attributes": {},
    "provider": "whatsapp_cloud",
    "phone_number": "+66900000000"
  }
}

                    
บล็อกโค้ดนี้ในหน้าต่างลอย

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

ฟิลด์ ประเภท คำอธิบาย
total string จำนวนข้อความทั้งหมดในบทสนทนา
conversation_content JSON Array รายละเอียดข้อความ
message_id string รหัสเฉพาะของแต่ละข้อความ
parent_message_id string รหัสข้อความต้นทาง
create_time long เวลาที่สร้างข้อความ
feedback string ข้อเสนอแนะจากผู้ใช้ มีค่า: POSITIVE, NEGATIVE หากไม่มีข้อเสนอแนะจะเว้นว่าง
source_page string หน้าเว็บต้นทางของข้อความนี้ คือ URL ของหน้าเว็บที่ผู้ใช้อยู่ขณะที่ข้อความถูกสร้างขึ้น ปัจจุบันรองรับเฉพาะช่องทาง Livechat เท่านั้น หากแหล่งที่มาของบทสนทนาไม่ใช่ Livechat ค่านี้จะว่างเปล่า
sentiment_label string ป้ายกำกับอารมณ์ของข้อความ สอดคล้องกับฟิลด์อารมณ์ในบันทึกการสนทนา
role string บทบาทข้อความ: user หรือ assistant
content JSON Array เนื้อหาข้อความ
from_component_branch string รหัสสาขา component ของแหล่งข้อความ (ว่างสำหรับข้อความผู้ใช้และ Agent ทั่วไป)
branch_content JSON Array เนื้อหาสาขาของข้อความ
type string ประเภทเนื้อหาข้อความ: text, image, audio, document, video, file
text string ข้อความแบบข้อความ
image JSON Array ข้อความแบบรูปภาพ
audio JSON Array ข้อความแบบเสียง
document JSON Array ข้อความแบบเอกสาร
video JSON Array ข้อความแบบวิดีโอ
file JSON Array ข้อความแบบไฟล์
audio_record_url string URL ไฟล์บันทึกเสียงของการโทรทั้งสาย มีเฉพาะ Agent เสียง (Audio) เท่านั้น หากไม่มีการบันทึกเสียง จะไม่ส่งฟิลด์นี้กลับ
user_sender JSON Object ข้อมูลช่องทางของผู้ใช้ ระบบจะบันทึกเมื่อบทสนทนาขาเข้ามาจากการเชื่อมต่อช่องทางภายนอก (ปัจจุบันคือ LiveDesk) โดยดึงจากข้อมูลช่องทางของผู้ส่งใน webhook ของช่องทาง (รองรับช่องทางเช่น WhatsApp / LINE) และมีแหล่งข้อมูลเดียวกับตัวแปรโฟลว์ ld_user_sender หากไม่ได้เก็บข้อมูล จะไม่ส่งฟิลด์นี้กลับ ฟิลด์ที่พบบ่อยดูตารางด้านล่าง

ฟิลด์ที่พบบ่อยของ user_sender

ออบเจ็กต์นี้เป็นข้อมูลช่องทางของผู้ใช้ที่ส่งผ่านมาจากช่องทางต้นทาง ฟิลด์จะแตกต่างกันไปตามแต่ละช่องทาง ต่อไปนี้คือฟิลด์ที่พบบ่อย โปรดยึดตามข้อมูลที่ช่องทางส่งกลับจริงเป็นหลัก

ฟิลด์ ประเภท คำอธิบาย
channel_type string ประเภทช่องทาง เช่น Channel::Whatsapp, Channel::Line, Channel::Webwidget เป็นต้น
user_id string รหัสผู้ใช้ฝั่งช่องทาง: WhatsApp เป็นหมายเลขโทรศัพท์/wa_id, LINE เป็น userId, ช่องทางอื่นเป็น identifier
profile JSON Object ข้อมูลโปรไฟล์ผู้ใช้ (เช่น name)
additional_attributes JSON Object แอตทริบิวต์เพิ่มเติมของช่องทาง
provider string provider ของช่องทาง
phone_number string หมายเลขโทรศัพท์ที่ตั้งค่าไว้ฝั่งช่องทาง

การตอบกลับผิดพลาด

ฟิลด์ ประเภท คำอธิบาย
code int รหัสข้อผิดพลาด
message string รายละเอียดข้อผิดพลาด

รหัสข้อผิดพลาด

รหัส ข้อความ
40000 พารามิเตอร์ไม่ถูกต้อง
40005 พารามิเตอร์แบ่งหน้ามากกว่าจำนวนจริง
40127 การยืนยันตัวตนนักพัฒนาไม่สำเร็จ
40356 ไม่พบบทสนทนา
20059 Agent ถูกลบแล้ว