查詢問題分類與情緒
查詢問題分類與情緒
查詢使用者問題已儲存的分類與情緒。一般與進階辨識模式共用此介面。
請求方式
GET
調用地址
https://api-sg.gptbots.ai/v1/question-category-results
調用鑑權
使用該 Agent 的 API 金鑰。專案方案須同時支援 API 整合與問題辨識。請選用組織所在資料中心的位址。 API 總覽
調用頻率
與專案其他分析 API 共用每分鐘額度,超額傳回 40008。
請求
請求示例
curl -X GET "https://api-sg.gptbots.ai/v1/question-category-results?message_id=66b2c3d4e5f6000100000010&page_size=5" \
-H "Authorization: Bearer your_apikey"
curl -X GET "https://api-sg.gptbots.ai/v1/question-category-results?message_id=66b2c3d4e5f6000100000010&page_size=5" \
-H "Authorization: Bearer your_apikey"
此代碼塊在浮窗中顯示
curl -X GET "https://api-sg.gptbots.ai/v1/question-category-results?conversation_id=66b2c3d4e5f6000100000001&page=1&page_size=20" \
-H "Authorization: Bearer your_apikey"
curl -X GET "https://api-sg.gptbots.ai/v1/question-category-results?conversation_id=66b2c3d4e5f6000100000001&page=1&page_size=20" \
-H "Authorization: Bearer your_apikey"
此代碼塊在浮窗中顯示
curl -X GET "https://api-sg.gptbots.ai/v1/question-category-results?start_time=1763913600000&end_time=1764000000000&page=1&page_size=20" \
-H "Authorization: Bearer your_apikey"
curl -X GET "https://api-sg.gptbots.ai/v1/question-category-results?start_time=1763913600000&end_time=1764000000000&page=1&page_size=20" \
-H "Authorization: Bearer your_apikey"
此代碼塊在浮窗中顯示
請求頭
| 欄位 | 類型 | 描述 |
|---|---|---|
| Authorization | string | Bearer your_apikey |
請求參數
擇一使用問題訊息 ID、對話 ID 或起訖時間。時間範圍包含起訖點,最長 31 天,僅傳回方案日誌保留期間內可見的問題。
依訊息查詢時 page 須為 1,最多傳回一筆;系統仍會驗證並傳回收到的 page_size。傳入回答 ID 或查無可見問題時,total 為 0,items 為空陣列。
| 欄位 | 類型 | 必填 | 描述 |
|---|---|---|---|
| message_id | string | 擇一 | 問題訊息 ID |
| conversation_id | string | 擇一 | 對話 ID |
| start_time | long | 擇一 | 開始時間,Unix 毫秒 |
| end_time | long | 擇一 | 結束時間,Unix 毫秒 |
| page | int | 否 | 頁碼從 1 起,預設 1。 |
| page_size | int | 否 | 每頁 1~100 筆,預設 20。 |
回應
回應範例
{
"total": 1,
"page": 1,
"page_size": 5,
"items": [
{
"message_id": "66b2c3d4e5f6000100000010",
"conversation_id": "66b2c3d4e5f6000100000001",
"question_time": 1764000000000,
"categories": [
{
"id": "66a1b2c3d4e5f60001000002",
"name": "退款進度",
"parent_id": "66a1b2c3d4e5f60001000001"
}
],
"sentiment": "negative"
}
]
}
{
"total": 1,
"page": 1,
"page_size": 5,
"items": [
{
"message_id": "66b2c3d4e5f6000100000010",
"conversation_id": "66b2c3d4e5f6000100000001",
"question_time": 1764000000000,
"categories": [
{
"id": "66a1b2c3d4e5f60001000002",
"name": "退款進度",
"parent_id": "66a1b2c3d4e5f60001000001"
}
],
"sentiment": "negative"
}
]
}
此代碼塊在浮窗中顯示
成功響應
| 欄位 | 類型 | 描述 |
|---|---|---|
| total | long | 符合條件的可見問題總數 |
| page | int | 頁碼從 1 起,預設 1。 |
| page_size | int | 每頁 1~100 筆,預設 20。 |
| items | array | 本頁資料 |
| message_id | string | 問題訊息 ID |
| conversation_id | string | 對話 ID |
| question_time | long | 問題建立時間,Unix 毫秒 |
| categories | array | 命中的子分類 |
| id | string | 分類 ID |
| name | string | 目前的分類名稱。已停用的項目仍可顯示。 |
| parent_id | string | 父分類 ID,第一層為 null。 |
| sentiment | string | 使用者情緒 (none, very_negative, negative, neutral, positive, very_positive). |
依對話或時間查詢時按問題時間、訊息 ID 遞減排序。沒有命中分類的問題仍會傳回,categories 為空陣列。
歷史結果顯示目前的分類名稱。刪除後該分類的命中會消失;如需保留,請將 enabled 設為 false。
單筆查詢未命中的回應範例(傳入 page_size=5)
{
"total": 0,
"page": 1,
"page_size": 5,
"items": []
}
{
"total": 0,
"page": 1,
"page_size": 5,
"items": []
}
此代碼塊在浮窗中顯示
失敗響應
| 字段 | 類型 | 描述 |
|---|---|---|
| code | int | 錯誤碼。 |
| message | string | 錯誤描述信息。 |
錯誤碼
| Code | Message |
|---|---|
| 40000 | 參數無效 |
| 40008 | 超出分析 API 每分鐘額度 |
| 40100 | 目前的 Agent 無權操作該資源 |
| 40101 | 缺少 Authorization 標頭 |
| 40127 | Agent API 金鑰無效 |
| 20055 | Agent 未啟用 API |
| 40353 | 方案未開通所需功能 |
| 50000 | 服務內部錯誤 |
