對話與訊息
發送訊息 (串流)
POST /api/chatbots/{chatbotId}/completions/
參數
chatbotId
✅
string
請求內容
請求參數
conversation
string (uuid)
否
對話的唯一識別碼,如果為空則會建立新對話(可選)
message
object (含 6 個屬性: content, contentPayload, queryMetadata...)
是
要發送的訊息內容
message.content
string
是
訊息的文字內容
message.contentPayload
object
否
訊息的額外內容負載,JSON 格式(可選)
message.queryMetadata
object
否
查詢元數據,JSON 格式(可選)
message.metadata
object
否
訊息的環境元數據,例如時區等資訊,JSON 格式(可選)
message.attachments
array[AttachmentInput]
否
訊息的附件列表(可選)
message.sender
string (uuid)
否
發送者的 Contact ID(可選)
isStreaming
boolean
否
是否使用串流模式回應,預設為 false(可選)
請求結構範例
{
"conversation"?: string (uuid) // 對話的唯一識別碼,如果為空則會建立新對話(可選) (非必填)
"message": // 要發送的訊息內容
{
"content": string // 訊息的文字內容
"contentPayload"?: object // 訊息的額外內容負載,JSON 格式(可選) (非必填)
"queryMetadata"?: object // 查詢元數據,JSON 格式(可選) (非必填)
"metadata"?: object // 訊息的環境元數據,例如時區等資訊,JSON 格式(可選) (非必填)
"attachments"?: [ // 訊息的附件列表(可選) (非必填)
{
"id": string (uuid) // 附件的唯一識別碼
"type": // 附件類型,可選值:image(圖片)、video(影片,開發中,尚未支援)、audio(音訊)、sticker(貼圖,開發中,尚未支援)、other(其他)
* `image` - Image
* `video` - Video
* `audio` - Audio
* `sticker` - Sticker
* `other` - Other
{
}
"filename": string // 附件的檔案名稱
"file": string (uri) // 附件檔案的 URL 位址
}
]
"sender"?: string (uuid) // 發送者的 Contact ID(可選) (非必填)
}
"isStreaming"?: boolean // 是否使用串流模式回應,預設為 false(可選) (非必填)
}請求範例值
{
"message": {
"content": "你好,請介紹一下你自己"
},
"is_streaming": true
}程式碼範例
# 呼叫 API 示例 (Shell)
curl -X POST "https://api.maiagent.ai/api/chatbots/550e8400-e29b-41d4-a716-446655440000/completions/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"message": {
"content": "你好,請介紹一下你自己"
},
"is_streaming": true
}'
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。const axios = require('axios');
// 設定請求標頭
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY',
'Content-Type': 'application/json'
}
};
// 請求內容 (payload)
const data = {
"message": {
"content": "你好,請介紹一下你自己"
},
"is_streaming": true
};
axios.post("https://api.maiagent.ai/api/chatbots/550e8400-e29b-41d4-a716-446655440000/completions/", data, config)
.then(response => {
console.log('成功取得回應:');
console.log(response.data);
})
.catch(error => {
console.error('請求發生錯誤:');
console.error(error.response?.data || error.message);
});import requests
url = "https://api.maiagent.ai/api/chatbots/550e8400-e29b-41d4-a716-446655440000/completions/"
headers = {
"Authorization": "Api-Key YOUR_API_KEY",
"Content-Type": "application/json"
}
# 請求內容 (payload)
data = {
"message": {
"content": "你好,請介紹一下你自己"
},
"is_streaming": true
}
response = requests.post(url, json=data, headers=headers)
try:
print("成功取得回應:")
print(response.json())
except Exception as e:
print("請求發生錯誤:", e)<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
try {
$response = $client->post("https://api.maiagent.ai/api/chatbots/550e8400-e29b-41d4-a716-446655440000/completions/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY',
'Content-Type' => 'application/json'
],
'json' => {
"message": {
"content": "你好,請介紹一下你自己"
},
"is_streaming": true
}
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:\n";
print_r($data);
} catch (Exception $e) {
echo '請求發生錯誤: ' . $e->getMessage();
}
?>回應內容
200
對話回應內容,若是串流則為事件流
400
請求參數錯誤,可能原因包括:Contact ID 不屬於該組織
發送訊息 (建立)
POST /api/messages/
請求內容
請求參數
conversation
string (uuid)
是
type
string
否
content
string
否
contentPayload
object
否
attachments
array[AttachmentCreateInput]
否
canvas
object
否
canvas.name
string
是
canvas.canvasType
object
是
canvas.title
string
是
canvas.content
string
是
queryMetadata
object
否
請求結構範例
{
"conversation": string (uuid)
"type"?: string // 非必填
"content"?: string // 非必填
"contentPayload"?: object // 非必填
"attachments"?: [ // 非必填
{
"type"?: // 非必填
{
}
"filename": string
"file": string (uri)
"conversation"?: string (uuid) // 非必填
}
]
"canvas"?: { // 非必填
{
"name": string
"canvasType":
{
}
"title": string
"content": string
}
}
"queryMetadata"?: object // 非必填
}請求範例值
{
"conversation": "c96a0fb9-d106-4b16-8706-3906533bafa2",
"sender": {
"id": 2.992461161002561e+38,
"name": "jessiekuo",
"avatar": "https://autox-media-dev.playma.app/static/images/default-user-avatar.png"
},
"type": "incoming",
"content": "這是一條測試訊息",
"contentPayload": {
"content": "這是一條測試訊息",
"items": [
{
"type": "text",
"text": "這是一條測試訊息",
"startTimestamp": null,
"citations": []
}
],
"metadata": null
},
"feedback": "like",
"createdAt": "1748314926000",
"attachments": [],
"citations": [],
"citationNodes": [],
"canvas": {
"id": "034eecd7-e0f4-46e9-88cb-4fefdb5b7ddd",
"name": "system-architecture-diagram",
"canvasType": "markdown",
"title": "系統架構圖",
"content": "```mermaid\ngraph TD\n A[用戶] --> B[前端界面]\n B --> C[API層]\n C --> D[數據庫]\n```",
"createdAt": "1748314926000"
}
}程式碼範例
# 呼叫 API 示例 (Shell)
curl -X POST "https://api.maiagent.ai/api/messages/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"conversation": "c96a0fb9-d106-4b16-8706-3906533bafa2",
"sender": {
"id": 2.992461161002561e+38,
"name": "jessiekuo",
"avatar": "https://autox-media-dev.playma.app/static/images/default-user-avatar.png"
},
"type": "incoming",
"content": "這是一條測試訊息",
"contentPayload": {
"content": "這是一條測試訊息",
"items": [
{
"type": "text",
"text": "這是一條測試訊息",
"startTimestamp": null,
"citations": []
}
],
"metadata": null
},
"feedback": "like",
"createdAt": "1748314926000",
"attachments": [],
"citations": [],
"citationNodes": [],
"canvas": {
"id": "034eecd7-e0f4-46e9-88cb-4fefdb5b7ddd",
"name": "system-architecture-diagram",
"canvasType": "markdown",
"title": "系統架構圖",
"content": "```mermaid\ngraph TD\n A[用戶] --> B[前端界面]\n B --> C[API層]\n C --> D[數據庫]\n```",
"createdAt": "1748314926000"
}
}'
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。const axios = require('axios');
// 設定請求標頭
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY',
'Content-Type': 'application/json'
}
};
// 請求內容 (payload)
const data = {
"conversation": "c96a0fb9-d106-4b16-8706-3906533bafa2",
"sender": {
"id": 2.992461161002561e+38,
"name": "jessiekuo",
"avatar": "https://autox-media-dev.playma.app/static/images/default-user-avatar.png"
},
"type": "incoming",
"content": "這是一條測試訊息",
"contentPayload": {
"content": "這是一條測試訊息",
"items": [
{
"type": "text",
"text": "這是一條測試訊息",
"startTimestamp": null,
"citations": []
}
],
"metadata": null
},
"feedback": "like",
"createdAt": "1748314926000",
"attachments": [],
"citations": [],
"citationNodes": [],
"canvas": {
"id": "034eecd7-e0f4-46e9-88cb-4fefdb5b7ddd",
"name": "system-architecture-diagram",
"canvasType": "markdown",
"title": "系統架構圖",
"content": "```mermaid\ngraph TD\n A[用戶] --> B[前端界面]\n B --> C[API層]\n C --> D[數據庫]\n```",
"createdAt": "1748314926000"
}
};
axios.post("https://api.maiagent.ai/api/messages/", data, config)
.then(response => {
console.log('成功取得回應:');
console.log(response.data);
})
.catch(error => {
console.error('請求發生錯誤:');
console.error(error.response?.data || error.message);
});import requests
url = "https://api.maiagent.ai/api/messages/"
headers = {
"Authorization": "Api-Key YOUR_API_KEY",
"Content-Type": "application/json"
}
# 請求內容 (payload)
data = {
"conversation": "c96a0fb9-d106-4b16-8706-3906533bafa2",
"sender": {
"id": 2.992461161002561e+38,
"name": "jessiekuo",
"avatar": "https://autox-media-dev.playma.app/static/images/default-user-avatar.png"
},
"type": "incoming",
"content": "這是一條測試訊息",
"contentPayload": {
"content": "這是一條測試訊息",
"items": [
{
"type": "text",
"text": "這是一條測試訊息",
"startTimestamp": null,
"citations": []
}
],
"metadata": null
},
"feedback": "like",
"createdAt": "1748314926000",
"attachments": [],
"citations": [],
"citationNodes": [],
"canvas": {
"id": "034eecd7-e0f4-46e9-88cb-4fefdb5b7ddd",
"name": "system-architecture-diagram",
"canvasType": "markdown",
"title": "系統架構圖",
"content": "```mermaid\ngraph TD\n A[用戶] --> B[前端界面]\n B --> C[API層]\n C --> D[數據庫]\n```",
"createdAt": "1748314926000"
}
}
response = requests.post(url, json=data, headers=headers)
try:
print("成功取得回應:")
print(response.json())
except Exception as e:
print("請求發生錯誤:", e)<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
try {
$response = $client->post("https://api.maiagent.ai/api/messages/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY',
'Content-Type' => 'application/json'
],
'json' => {
"conversation": "c96a0fb9-d106-4b16-8706-3906533bafa2",
"sender": {
"id": 2.992461161002561e+38,
"name": "jessiekuo",
"avatar": "https://autox-media-dev.playma.app/static/images/default-user-avatar.png"
},
"type": "incoming",
"content": "這是一條測試訊息",
"contentPayload": {
"content": "這是一條測試訊息",
"items": [
{
"type": "text",
"text": "這是一條測試訊息",
"startTimestamp": null,
"citations": []
}
],
"metadata": null
},
"feedback": "like",
"createdAt": "1748314926000",
"attachments": [],
"citations": [],
"citationNodes": [],
"canvas": {
"id": "034eecd7-e0f4-46e9-88cb-4fefdb5b7ddd",
"name": "system-architecture-diagram",
"canvasType": "markdown",
"title": "系統架構圖",
"content": "```mermaid\ngraph TD\n A[用戶] --> B[前端界面]\n B --> C[API層]\n C --> D[數據庫]\n```",
"createdAt": "1748314926000"
}
}
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:\n";
print_r($data);
} catch (Exception $e) {
echo '請求發生錯誤: ' . $e->getMessage();
}
?>回應內容
狀態碼: 201
回應結構範例
{
"id": string (uuid)
"conversation": string (uuid)
"sender":
{
"id": string (uuid)
"name": string
"avatar": string
"email"?: string (email) // 非必填
"phoneNumber"?: string // 非必填
}
"type"?: string // 非必填
"content"?: string // 非必填
"contentPayload"?: object // 非必填
"feedback":
{
"id": string (uuid)
"type":
{
}
"suggestion"?: string // 非必填
"updatedAt": string (timestamp)
}
"createdAt": string (timestamp)
"attachments"?: [ // 非必填
{
"id": string (uuid)
"type"?: // 非必填
{
}
"filename": string
"file": string (uri)
"conversation"?: string (uuid) // 非必填
}
]
"citations": [
{
"id": string (uuid)
"filename": string // 檔案名稱
"file": string (uri) // 要上傳的檔案
"fileType": string
"knowledgeBase"?: // 非必填
{
"id": string (uuid)
"name": string
}
"size": integer
"status":
{
}
"parser": {
{
"id": string (uuid)
"name": string
"provider":
{
}
"order"?: integer // 非必填
}
}
"labels"?: [ // 非必填
{
"id": string (uuid)
"name": string
}
]
"rawUserDefineMetadata"?: object // 非必填
"vectorStorageSize": integer // Size of vectors for this file in Elasticsearch (bytes)
"chunksCount": integer // Number of chunks/nodes generated from this file
"createdAt": string (timestamp)
}
]
"citationNodes": [
{
"chatbotTextNode": {
{
"id": string (uuid)
"charactersCount": integer
"hitsCount": integer
"text": string
"updatedAt": string (timestamp)
"filename": string
"chatbotFile": string (uuid)
"knowledgeBaseFile": string (uuid) // 與 get_chatbot_file 相同,提供向後兼容
"pageNumber": integer
}
}
"score"?: number (double) // 非必填
"displayScore": integer
}
]
"canvas"?: { // 非必填
{
"id": string (uuid)
"name": string
"canvasType":
{
}
"title": string
"content": string
"createdAt": string (timestamp)
}
}
"queryMetadata"?: object // 非必填
}回應範例值
{
"conversation": "c96a0fb9-d106-4b16-8706-3906533bafa2",
"sender": {
"id": 2.992461161002561e+38,
"name": "jessiekuo",
"avatar": "https://autox-media-dev.playma.app/static/images/default-user-avatar.png"
},
"type": "incoming",
"content": "這是一條測試訊息",
"contentPayload": {
"content": "這是一條測試訊息",
"items": [
{
"type": "text",
"text": "這是一條測試訊息",
"startTimestamp": null,
"citations": []
}
],
"metadata": null
},
"feedback": "like",
"createdAt": "1748314926000",
"attachments": [],
"citations": [],
"citationNodes": [],
"canvas": {
"id": "034eecd7-e0f4-46e9-88cb-4fefdb5b7ddd",
"name": "system-architecture-diagram",
"canvasType": "markdown",
"title": "系統架構圖",
"content": "```mermaid\ngraph TD\n A[用戶] --> B[前端界面]\n B --> C[API層]\n C --> D[數據庫]\n```",
"createdAt": "1748314926000"
}
}建立新的對話
POST /api/conversations/
請求內容
請求參數
webChat
string (uuid)
是
請求結構範例
{
"webChat": string (uuid)
}請求範例值
{
"webChat": "550e8400-e29b-41d4-a716-446655440000"
}程式碼範例
# 呼叫 API 示例 (Shell)
curl -X POST "https://api.maiagent.ai/api/conversations/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"webChat": "550e8400-e29b-41d4-a716-446655440000"
}'
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。const axios = require('axios');
// 設定請求標頭
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY',
'Content-Type': 'application/json'
}
};
// 請求內容 (payload)
const data = {
"webChat": "550e8400-e29b-41d4-a716-446655440000"
};
axios.post("https://api.maiagent.ai/api/conversations/", data, config)
.then(response => {
console.log('成功取得回應:');
console.log(response.data);
})
.catch(error => {
console.error('請求發生錯誤:');
console.error(error.response?.data || error.message);
});import requests
url = "https://api.maiagent.ai/api/conversations/"
headers = {
"Authorization": "Api-Key YOUR_API_KEY",
"Content-Type": "application/json"
}
# 請求內容 (payload)
data = {
"webChat": "550e8400-e29b-41d4-a716-446655440000"
}
response = requests.post(url, json=data, headers=headers)
try:
print("成功取得回應:")
print(response.json())
except Exception as e:
print("請求發生錯誤:", e)<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
try {
$response = $client->post("https://api.maiagent.ai/api/conversations/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY',
'Content-Type' => 'application/json'
],
'json' => {
"webChat": "550e8400-e29b-41d4-a716-446655440000"
}
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:\n";
print_r($data);
} catch (Exception $e) {
echo '請求發生錯誤: ' . $e->getMessage();
}
?>回應內容
狀態碼: 201
回應結構範例
{
"id": string (uuid)
"contact": { // 輕量級 Contact Serializer,用於 Conversation List view
只包含 List view 必要的欄位,移除 inboxes 和 mcp_credentials
以避免 N+1 查詢問題
{
"id": string (uuid)
"name": string
"avatar"?: string (uri) // 非必填
"sourceId"?: string // 非必填
}
}
"inbox": {
{
"id": string (uuid)
"name": string
"channelType": string (enum: line, telegram, teams, web, messenger, instagram) // * `line` - LINE
* `telegram` - Telegram
* `teams` - Teams
* `web` - Web
* `messenger` - Messenger
* `instagram` - Instagram
"unreadConversationsCount"?: integer // 非必填
"signAuth"?: // 非必填
{
"id": string (uuid)
"signSource": string (uuid)
"signParams": {
{
"keycloak":
{
"clientId": string
"url": string
"realm": string
}
"line":
{
"liffId": string
}
"ad":
{
"saml": string
}
}
}
}
}
}
"title": string
"lastMessage"?: { // 非必填
{
"id": string (uuid)
"type"?: string // 非必填
"content"?: string // 非必填
"contentPayload"?: object // 非必填
"feedback":
{
"id": string (uuid)
"type":
{
}
"suggestion"?: string // 非必填
"updatedAt": string (timestamp)
}
"createdAt": string (timestamp)
"queryMetadata"?: object // 非必填
}
}
"lastMessageCreatedAt": string (timestamp)
"unreadMessagesCount": integer
"autoReplyEnabled": boolean
"isAutoReplyNow": boolean
"lastReadAt": string (timestamp)
"createdAt": string (timestamp)
"isGroupChat": boolean
"enableGroupMention"?: boolean // 非必填
"enableLoadingAnimation"?: boolean // 非必填
"queryMetadata"?: object // 非必填
"toolMask"?: object // 記錄每個工具的啟用/停用狀態 {tool_id: bool} (非必填)
"llm": string (uuid)
"ipAddress": string
"ipCountryCode": string
"ipRecordedAt": string (timestamp)
}回應範例值
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"contact": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "回應字串",
"avatar": "https://example.com/file.jpg",
"sourceId": "回應字串"
},
"inbox": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "回應字串",
"channelType": "line",
"unreadConversationsCount": 456,
"signAuth": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"signSource": "550e8400-e29b-41d4-a716-446655440000",
"signParams": {
"keycloak": {
"clientId": "回應字串",
"url": "回應字串",
"realm": "回應字串"
},
"line": {
"liffId": "回應字串"
},
"ad": {
"saml": "回應字串"
}
}
}
},
"title": "回應字串",
"lastMessage": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": "回應字串",
"content": "回應字串",
"contentPayload": null,
"feedback": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"suggestion": "回應字串",
"updatedAt": "回應字串"
},
"createdAt": "回應字串",
"queryMetadata": null
},
"lastMessageCreatedAt": "回應字串",
"unreadMessagesCount": 456,
"autoReplyEnabled": false,
"isAutoReplyNow": false,
"lastReadAt": "回應字串",
"createdAt": "回應字串",
"isGroupChat": false,
"enableGroupMention": false,
"enableLoadingAnimation": false,
"queryMetadata": null,
"toolMask": null,
"llm": "550e8400-e29b-41d4-a716-446655440000",
"ipAddress": "回應字串",
"ipCountryCode": "回應字串",
"ipRecordedAt": "回應字串"
}取得訊息列表
GET /api/messages/
參數
conversation
✅
string
對話 ID
cursor
❌
string
The pagination cursor value.
pageSize
❌
integer
Number of results to return per page.
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X GET "https://api.maiagent.ai/api/messages/?conversation=example&cursor=example&pageSize=1" \
-H "Authorization: Api-Key YOUR_API_KEY"
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。const axios = require('axios');
// 設定請求標頭
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY'
}
};
axios.get("https://api.maiagent.ai/api/messages/?conversation=example&cursor=example&pageSize=1", config)
.then(response => {
console.log('成功取得回應:');
console.log(response.data);
})
.catch(error => {
console.error('請求發生錯誤:');
console.error(error.response?.data || error.message);
});import requests
url = "https://api.maiagent.ai/api/messages/?conversation=example&cursor=example&pageSize=1"
headers = {
"Authorization": "Api-Key YOUR_API_KEY"
}
response = requests.get(url, headers=headers)
try:
print("成功取得回應:")
print(response.json())
except Exception as e:
print("請求發生錯誤:", e)<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
try {
$response = $client->get("https://api.maiagent.ai/api/messages/?conversation=example&cursor=example&pageSize=1", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY'
]
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:\n";
print_r($data);
} catch (Exception $e) {
echo '請求發生錯誤: ' . $e->getMessage();
}
?>回應內容
狀態碼: 200
回應結構範例
{
"count": integer
"next"?: string (uri) // 非必填
"previous"?: string (uri) // 非必填
"results": [
{
"id": string (uuid)
"conversation": string (uuid)
"sender":
{
"id": string (uuid)
"name": string
"avatar": string
"email"?: string (email) // 非必填
"phoneNumber"?: string // 非必填
}
"type"?: string // 非必填
"content"?: string // 非必填
"contentPayload"?: object // 非必填
"feedback":
{
"id": string (uuid)
"type":
{
}
"suggestion"?: string // 非必填
"updatedAt": string (timestamp)
}
"createdAt": string (timestamp)
"attachments"?: [ // 非必填
{
"id": string (uuid)
"type"?: // 非必填
{
}
"filename": string
"file": string (uri)
"conversation"?: string (uuid) // 非必填
}
]
"citations": [
{
"id": string (uuid)
"filename": string // 檔案名稱
"file": string (uri) // 要上傳的檔案
"fileType": string
"knowledgeBase"?: // 非必填
{
"id": string (uuid)
"name": string
}
"size": integer
"status":
{
}
"parser": {
{
"id": string (uuid)
"name": string
"provider":
{
}
"order"?: integer // 非必填
}
}
"labels"?: [ // 非必填
{
"id": string (uuid)
"name": string
}
]
"rawUserDefineMetadata"?: object // 非必填
"vectorStorageSize": integer // Size of vectors for this file in Elasticsearch (bytes)
"chunksCount": integer // Number of chunks/nodes generated from this file
"createdAt": string (timestamp)
}
]
"citationNodes": [
{
"chatbotTextNode": {
{
"id": string (uuid)
"charactersCount": integer
"hitsCount": integer
"text": string
"updatedAt": string (timestamp)
"filename": string
"chatbotFile": string (uuid)
"knowledgeBaseFile": string (uuid) // 與 get_chatbot_file 相同,提供向後兼容
"pageNumber": integer
}
}
"score"?: number (double) // 非必填
"displayScore": integer
}
]
"canvas"?: { // 非必填
{
"id": string (uuid)
"name": string
"canvasType":
{
}
"title": string
"content": string
"createdAt": string (timestamp)
}
}
"queryMetadata"?: object // 非必填
}
]
}回應範例值
{
"count": 123,
"next": "http://api.example.org/accounts/?page=4",
"previous": "http://api.example.org/accounts/?page=2",
"results": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"conversation": "550e8400-e29b-41d4-a716-446655440000",
"sender": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "回應字串",
"avatar": "回應字串",
"email": "[email protected]",
"phoneNumber": "回應字串"
},
"type": "回應字串",
"content": "回應字串",
"contentPayload": null,
"feedback": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"suggestion": "回應字串",
"updatedAt": "回應字串"
},
"createdAt": "回應字串",
"attachments": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"filename": "回應字串",
"file": "https://example.com/file.jpg",
"conversation": "550e8400-e29b-41d4-a716-446655440000"
}
],
"citations": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"filename": "回應字串",
"file": "https://example.com/file.jpg",
"fileType": "回應字串",
"knowledgeBase": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "回應字串"
},
"size": 456,
"status": {},
"parser": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "回應字串",
"provider": {},
"order": 456
},
"labels": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "回應字串"
}
],
"rawUserDefineMetadata": null,
"vectorStorageSize": 456,
"chunksCount": 456,
"createdAt": "回應字串"
}
],
"citationNodes": [
{
"chatbotTextNode": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"charactersCount": 456,
"hitsCount": 456,
"text": "回應字串",
"updatedAt": "回應字串",
"filename": "回應字串",
"chatbotFile": "550e8400-e29b-41d4-a716-446655440000",
"knowledgeBaseFile": "550e8400-e29b-41d4-a716-446655440000",
"pageNumber": 456
},
"score": 456,
"displayScore": 456
}
],
"canvas": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "回應字串",
"canvasType": {},
"title": "回應字串",
"content": "回應字串",
"createdAt": "回應字串"
},
"queryMetadata": null
}
]
}取得特定訊息
GET /api/messages/{id}/
參數
id
✅
string
A UUID string identifying this 訊息.
conversation
✅
string
對話 ID
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X GET "https://api.maiagent.ai/api/messages/550e8400-e29b-41d4-a716-446655440000/?conversation=example" \
-H "Authorization: Api-Key YOUR_API_KEY"
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。const axios = require('axios');
// 設定請求標頭
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY'
}
};
axios.get("https://api.maiagent.ai/api/messages/550e8400-e29b-41d4-a716-446655440000/?conversation=example", config)
.then(response => {
console.log('成功取得回應:');
console.log(response.data);
})
.catch(error => {
console.error('請求發生錯誤:');
console.error(error.response?.data || error.message);
});import requests
url = "https://api.maiagent.ai/api/messages/550e8400-e29b-41d4-a716-446655440000/?conversation=example"
headers = {
"Authorization": "Api-Key YOUR_API_KEY"
}
response = requests.get(url, headers=headers)
try:
print("成功取得回應:")
print(response.json())
except Exception as e:
print("請求發生錯誤:", e)<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
try {
$response = $client->get("https://api.maiagent.ai/api/messages/550e8400-e29b-41d4-a716-446655440000/?conversation=example", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY'
]
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:\n";
print_r($data);
} catch (Exception $e) {
echo '請求發生錯誤: ' . $e->getMessage();
}
?>回應內容
狀態碼: 200
回應結構範例
{
"id": string (uuid)
"conversation": string (uuid)
"sender":
{
"id": string (uuid)
"name": string
"avatar": string
"email"?: string (email) // 非必填
"phoneNumber"?: string // 非必填
}
"type"?: string // 非必填
"content"?: string // 非必填
"contentPayload"?: object // 非必填
"feedback":
{
"id": string (uuid)
"type":
{
}
"suggestion"?: string // 非必填
"updatedAt": string (timestamp)
}
"createdAt": string (timestamp)
"attachments"?: [ // 非必填
{
"id": string (uuid)
"type"?: // 非必填
{
}
"filename": string
"file": string (uri)
"conversation"?: string (uuid) // 非必填
}
]
"citations": [
{
"id": string (uuid)
"filename": string // 檔案名稱
"file": string (uri) // 要上傳的檔案
"fileType": string
"knowledgeBase"?: // 非必填
{
"id": string (uuid)
"name": string
}
"size": integer
"status":
{
}
"parser": {
{
"id": string (uuid)
"name": string
"provider":
{
}
"order"?: integer // 非必填
}
}
"labels"?: [ // 非必填
{
"id": string (uuid)
"name": string
}
]
"rawUserDefineMetadata"?: object // 非必填
"vectorStorageSize": integer // Size of vectors for this file in Elasticsearch (bytes)
"chunksCount": integer // Number of chunks/nodes generated from this file
"createdAt": string (timestamp)
}
]
"citationNodes": [
{
"chatbotTextNode": {
{
"id": string (uuid)
"charactersCount": integer
"hitsCount": integer
"text": string
"updatedAt": string (timestamp)
"filename": string
"chatbotFile": string (uuid)
"knowledgeBaseFile": string (uuid) // 與 get_chatbot_file 相同,提供向後兼容
"pageNumber": integer
}
}
"score"?: number (double) // 非必填
"displayScore": integer
}
]
"canvas"?: { // 非必填
{
"id": string (uuid)
"name": string
"canvasType":
{
}
"title": string
"content": string
"createdAt": string (timestamp)
}
}
"queryMetadata"?: object // 非必填
}回應範例值
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"conversation": "550e8400-e29b-41d4-a716-446655440000",
"sender": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "回應字串",
"avatar": "回應字串",
"email": "[email protected]",
"phoneNumber": "回應字串"
},
"type": "回應字串",
"content": "回應字串",
"contentPayload": null,
"feedback": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"suggestion": "回應字串",
"updatedAt": "回應字串"
},
"createdAt": "回應字串",
"attachments": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"filename": "回應字串",
"file": "https://example.com/file.jpg",
"conversation": "550e8400-e29b-41d4-a716-446655440000"
}
],
"citations": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"filename": "回應字串",
"file": "https://example.com/file.jpg",
"fileType": "回應字串",
"knowledgeBase": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "回應字串"
},
"size": 456,
"status": {},
"parser": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "回應字串",
"provider": {},
"order": 456
},
"labels": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "回應字串"
}
],
"rawUserDefineMetadata": null,
"vectorStorageSize": 456,
"chunksCount": 456,
"createdAt": "回應字串"
}
],
"citationNodes": [
{
"chatbotTextNode": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"charactersCount": 456,
"hitsCount": 456,
"text": "回應字串",
"updatedAt": "回應字串",
"filename": "回應字串",
"chatbotFile": "550e8400-e29b-41d4-a716-446655440000",
"knowledgeBaseFile": "550e8400-e29b-41d4-a716-446655440000",
"pageNumber": 456
},
"score": 456,
"displayScore": 456
}
],
"canvas": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "回應字串",
"canvasType": {},
"title": "回應字串",
"content": "回應字串",
"createdAt": "回應字串"
},
"queryMetadata": null
}取得對話列表
GET /api/conversations/
參數
cursor
❌
string
The pagination cursor value.
inbox
✅
string
對話平台 ID
keyword
❌
string
關鍵字搜尋
pageSize
❌
integer
Number of results to return per page.
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X GET "https://api.maiagent.ai/api/conversations/?cursor=example&inbox=example&keyword=example&pageSize=1" \
-H "Authorization: Api-Key YOUR_API_KEY"
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。const axios = require('axios');
// 設定請求標頭
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY'
}
};
axios.get("https://api.maiagent.ai/api/conversations/?cursor=example&inbox=example&keyword=example&pageSize=1", config)
.then(response => {
console.log('成功取得回應:');
console.log(response.data);
})
.catch(error => {
console.error('請求發生錯誤:');
console.error(error.response?.data || error.message);
});import requests
url = "https://api.maiagent.ai/api/conversations/?cursor=example&inbox=example&keyword=example&pageSize=1"
headers = {
"Authorization": "Api-Key YOUR_API_KEY"
}
response = requests.get(url, headers=headers)
try:
print("成功取得回應:")
print(response.json())
except Exception as e:
print("請求發生錯誤:", e)<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
try {
$response = $client->get("https://api.maiagent.ai/api/conversations/?cursor=example&inbox=example&keyword=example&pageSize=1", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY'
]
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:\n";
print_r($data);
} catch (Exception $e) {
echo '請求發生錯誤: ' . $e->getMessage();
}
?>回應內容
狀態碼: 200
回應結構範例
{
"count": integer
"next"?: string (uri) // 非必填
"previous"?: string (uri) // 非必填
"results": [
{
"id": string (uuid)
"contact": { // 輕量級 Contact Serializer,用於 Conversation List view
只包含 List view 必要的欄位,移除 inboxes 和 mcp_credentials
以避免 N+1 查詢問題
{
"id": string (uuid)
"name": string
"avatar"?: string (uri) // 非必填
"sourceId"?: string // 非必填
}
}
"inbox": {
{
"id": string (uuid)
"name": string
"channelType": string (enum: line, telegram, teams, web, messenger, instagram) // * `line` - LINE
* `telegram` - Telegram
* `teams` - Teams
* `web` - Web
* `messenger` - Messenger
* `instagram` - Instagram
"unreadConversationsCount"?: integer // 非必填
"signAuth"?: // 非必填
{
"id": string (uuid)
"signSource": string (uuid)
"signParams": {
{
"keycloak":
{
"clientId": string
"url": string
"realm": string
}
"line":
{
"liffId": string
}
"ad":
{
"saml": string
}
}
}
}
}
}
"title": string
"lastMessage"?: { // 非必填
{
"id": string (uuid)
"type"?: string // 非必填
"content"?: string // 非必填
"contentPayload"?: object // 非必填
"feedback":
{
"id": string (uuid)
"type":
{
}
"suggestion"?: string // 非必填
"updatedAt": string (timestamp)
}
"createdAt": string (timestamp)
"queryMetadata"?: object // 非必填
}
}
"lastMessageCreatedAt": string (timestamp)
"unreadMessagesCount": integer
"autoReplyEnabled": boolean
"isAutoReplyNow": boolean
"lastReadAt": string (timestamp)
"createdAt": string (timestamp)
"isGroupChat": boolean
"enableGroupMention"?: boolean // 非必填
"enableLoadingAnimation"?: boolean // 非必填
"queryMetadata"?: object // 非必填
"toolMask"?: object // 記錄每個工具的啟用/停用狀態 {tool_id: bool} (非必填)
"llm": string (uuid)
"ipAddress": string
"ipCountryCode": string
"ipRecordedAt": string (timestamp)
}
]
}回應範例值
{
"count": 123,
"next": "http://api.example.org/accounts/?page=4",
"previous": "http://api.example.org/accounts/?page=2",
"results": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"contact": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "回應字串",
"avatar": "https://example.com/file.jpg",
"sourceId": "回應字串"
},
"inbox": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "回應字串",
"channelType": "line",
"unreadConversationsCount": 456,
"signAuth": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"signSource": "550e8400-e29b-41d4-a716-446655440000",
"signParams": {
"keycloak": {
"clientId": "回應字串",
"url": "回應字串",
"realm": "回應字串"
},
"line": {
"liffId": "回應字串"
},
"ad": {
"saml": "回應字串"
}
}
}
},
"title": "回應字串",
"lastMessage": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": "回應字串",
"content": "回應字串",
"contentPayload": null,
"feedback": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"suggestion": "回應字串",
"updatedAt": "回應字串"
},
"createdAt": "回應字串",
"queryMetadata": null
},
"lastMessageCreatedAt": "回應字串",
"unreadMessagesCount": 456,
"autoReplyEnabled": false,
"isAutoReplyNow": false,
"lastReadAt": "回應字串",
"createdAt": "回應字串",
"isGroupChat": false,
"enableGroupMention": false,
"enableLoadingAnimation": false,
"queryMetadata": null,
"toolMask": null,
"llm": "550e8400-e29b-41d4-a716-446655440000",
"ipAddress": "回應字串",
"ipCountryCode": "回應字串",
"ipRecordedAt": "回應字串"
}
]
}取得特定對話
GET /api/conversations/{id}/
參數
id
✅
string
A UUID string identifying this 對話.
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X GET "https://api.maiagent.ai/api/conversations/550e8400-e29b-41d4-a716-446655440000/" \
-H "Authorization: Api-Key YOUR_API_KEY"
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。const axios = require('axios');
// 設定請求標頭
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY'
}
};
axios.get("https://api.maiagent.ai/api/conversations/550e8400-e29b-41d4-a716-446655440000/", config)
.then(response => {
console.log('成功取得回應:');
console.log(response.data);
})
.catch(error => {
console.error('請求發生錯誤:');
console.error(error.response?.data || error.message);
});import requests
url = "https://api.maiagent.ai/api/conversations/550e8400-e29b-41d4-a716-446655440000/"
headers = {
"Authorization": "Api-Key YOUR_API_KEY"
}
response = requests.get(url, headers=headers)
try:
print("成功取得回應:")
print(response.json())
except Exception as e:
print("請求發生錯誤:", e)<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
try {
$response = $client->get("https://api.maiagent.ai/api/conversations/550e8400-e29b-41d4-a716-446655440000/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY'
]
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:\n";
print_r($data);
} catch (Exception $e) {
echo '請求發生錯誤: ' . $e->getMessage();
}
?>回應內容
狀態碼: 200
回應結構範例
{
"id": string (uuid)
"contact": { // 輕量級 Contact Serializer,用於 Conversation List view
只包含 List view 必要的欄位,移除 inboxes 和 mcp_credentials
以避免 N+1 查詢問題
{
"id": string (uuid)
"name": string
"avatar"?: string (uri) // 非必填
"sourceId"?: string // 非必填
}
}
"inbox": {
{
"id": string (uuid)
"name": string
"channelType": string (enum: line, telegram, teams, web, messenger, instagram) // * `line` - LINE
* `telegram` - Telegram
* `teams` - Teams
* `web` - Web
* `messenger` - Messenger
* `instagram` - Instagram
"unreadConversationsCount"?: integer // 非必填
"signAuth"?: // 非必填
{
"id": string (uuid)
"signSource": string (uuid)
"signParams": {
{
"keycloak":
{
"clientId": string
"url": string
"realm": string
}
"line":
{
"liffId": string
}
"ad":
{
"saml": string
}
}
}
}
}
}
"title": string
"lastMessage"?: { // 非必填
{
"id": string (uuid)
"type"?: string // 非必填
"content"?: string // 非必填
"contentPayload"?: object // 非必填
"feedback":
{
"id": string (uuid)
"type":
{
}
"suggestion"?: string // 非必填
"updatedAt": string (timestamp)
}
"createdAt": string (timestamp)
"queryMetadata"?: object // 非必填
}
}
"lastMessageCreatedAt": string (timestamp)
"unreadMessagesCount": integer
"autoReplyEnabled": boolean
"isAutoReplyNow": boolean
"lastReadAt": string (timestamp)
"createdAt": string (timestamp)
"isGroupChat": boolean
"enableGroupMention"?: boolean // 非必填
"enableLoadingAnimation"?: boolean // 非必填
"queryMetadata"?: object // 非必填
"toolMask"?: object // 記錄每個工具的啟用/停用狀態 {tool_id: bool} (非必填)
"llm": string (uuid)
"ipAddress": string
"ipCountryCode": string
"ipRecordedAt": string (timestamp)
}回應範例值
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"contact": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "回應字串",
"avatar": "https://example.com/file.jpg",
"sourceId": "回應字串"
},
"inbox": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "回應字串",
"channelType": "line",
"unreadConversationsCount": 456,
"signAuth": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"signSource": "550e8400-e29b-41d4-a716-446655440000",
"signParams": {
"keycloak": {
"clientId": "回應字串",
"url": "回應字串",
"realm": "回應字串"
},
"line": {
"liffId": "回應字串"
},
"ad": {
"saml": "回應字串"
}
}
}
},
"title": "回應字串",
"lastMessage": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": "回應字串",
"content": "回應字串",
"contentPayload": null,
"feedback": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"suggestion": "回應字串",
"updatedAt": "回應字串"
},
"createdAt": "回應字串",
"queryMetadata": null
},
"lastMessageCreatedAt": "回應字串",
"unreadMessagesCount": 456,
"autoReplyEnabled": false,
"isAutoReplyNow": false,
"lastReadAt": "回應字串",
"createdAt": "回應字串",
"isGroupChat": false,
"enableGroupMention": false,
"enableLoadingAnimation": false,
"queryMetadata": null,
"toolMask": null,
"llm": "550e8400-e29b-41d4-a716-446655440000",
"ipAddress": "回應字串",
"ipCountryCode": "回應字串",
"ipRecordedAt": "回應字串"
}Last updated
Was this helpful?
