logo
開發者文件
搜尋
獲取對話訊息詳情

獲取對話訊息詳情

使用 conversation_id 參數即可取得對話中的所有訊息詳情。回應內容包含 message_id、用戶提問、訊息類型、訊息內容、訊息時間戳等資訊。

請求方法

GET

端點

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

認證

請參考 API 概述 了解認證指引。

請求

範例請求

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}'

                    
此代碼塊在浮窗中顯示

請求標頭

欄位 類型 說明
Authorization Bearer ${API Key} 使用 Authorization: Bearer ${API Key} 進行認證。API 金鑰可從 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": "我已上傳了兩個圖像文件,請進行 OCR(光學字符識別)並返回兩個 JSON 格式的記錄。" }, { "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": "我已上傳了兩個圖像文件,請進行 OCR(光學字符識別)並返回兩個 JSON 格式的記錄。"
            },
            {
              "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 用戶對訊息的反饋,可能的值包括:POSITIVENEGATIVE。若無反饋則返回空值。
source_page string 該條訊息的來源網頁,即訊息產生時使用者所在的網頁 URL。目前僅 Livechat 渠道支援傳輸該欄位,當對話來源不為 Livechat 時,該值為空。
sentiment_label string 訊息情緒標籤,與對話日誌中的情緒欄位對齊。
role string 訊息角色:userassistant
content JSON Array 訊息內容。
from_component_branch string 訊息來源的組件分支 ID。用戶訊息及一般代理則為空。
branch_content JSON Array 訊息的分支內容。
type string 訊息內容類型:textimageaudiodocumentvideofile
text string 文字訊息內容。
image JSON Array 圖像訊息內容。
audio JSON Array 音訊訊息內容。
document JSON Array 文件訊息內容。
video JSON Array 影片訊息內容。
file JSON Array 檔案訊息內容。
audio_record_url string 語音通話整通錄音檔案 URL,僅語音(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 代理已被刪除