獲取對話訊息詳情
獲取對話訊息詳情
使用 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",
"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",
"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"
}
]
}
]
}
]
}
]
}
{
"total": 2,
"conversation_content": [
{
"message_id": "645dd86906931c4a9e0ffb1f",
"parent_message_id": "545dd86906931c4a9e0ffb1f",
"create_time": 1683871849906,
"feedback": "POSITIVE",
"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",
"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"
}
]
}
]
}
]
}
]
}
此代碼塊在浮窗中顯示
成功回應
| 欄位 | 類型 | 說明 |
|---|---|---|
| total | string | 對話中訊息的總數量。 |
| conversation_content | JSON Array | 訊息詳情。 |
| message_id | string | 訊息的唯一識別碼。 |
| parent_message_id | string | 上層訊息的唯一識別碼。 |
| create_time | long | 訊息建立的時間戳。 |
| feedback | string | 用戶對訊息的反饋,可能的值包括:POSITIVE 和 NEGATIVE。若無反饋則返回空值。 |
| role | string | 訊息角色:user 或 assistant。 |
| content | JSON Array | 訊息內容。 |
| from_component_branch | string | 訊息來源的組件分支 ID。用戶訊息及一般代理則為空。 |
| 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 | 檔案訊息內容。 |
錯誤回應
| 欄位 | 類型 | 說明 |
|---|---|---|
| code | int | 錯誤碼。 |
| message | string | 錯誤詳情。 |
錯誤碼
| 錯誤碼 | 訊息 |
|---|---|
| 40000 | 無效參數 |
| 40005 | 分頁參數超出實際數量 |
| 40127 | 開發者認證失敗 |
| 40356 | 對話不存在 |
| 20059 | 代理已被刪除 |
