對話與訊息
發送訊息並獲取回應(串流)
POST /api/chatbots/{id}/completions/
參數
參數名稱
必填
類型
說明
id
是
string
A UUID string identifying this chatbot.
請求內容
{
"conversation": "",
"message": {
"content": "捷運能不能吃東西",
"attachments": []
},
"is_streaming": false
}
參數
參數名稱
必填
類型
說明
conversation
否
string
Web Chat ID
message
是
Array
訊息陣列
message[].content
否
String
問題文字
message[].attachments
否
Array
附件
is_streaming
是
bool
串流功能開關
回應內容
{
"conversationId": "4ee4cdb9-ff9b-4f41-99b1-aa2fc2848271",
"content": "我很樂意為您說明捷運系統的飲食規定:\n\n1. 禁止飲食區域:\n- 以各車站閘門前的黃色標線為界\n- 黃色標線以內的區域(包含月台、車廂)嚴格禁止飲食\n- 連白開水和礦泉水都不可以喝\n\n2. 可以飲食的區域:\n- 黃色標線以外的區域可以自由飲食\n- 但請注意不可任意丟棄垃圾\n\n3. 特殊情況:\n- 如因疾病、身體不適等特殊狀況需要喝水、吃糖或吃藥\n- 請先向服務人員尋求協助\n\n4. 違規罰則:\n- 依大眾捷運法規定,違者將處新臺幣1,500元至7,500元罰鍰\n\n5. 宣導措施:\n- 捷運公司透過站內廣播、月台顯示器、標誌等持續宣導\n- 車站人員也會進行稽查取締\n\n這些規定的目的是為了維持捷運環境的整潔,提供所有旅客舒適的搭乘體驗。",
"done": true
}
發送訊息 (建立)
POST /api/v1/messages/
請求內容
{
"conversation": "550e8400-e29b-41d4-a716-446655440000",
"sender": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"avatar": "example_string"
},
"type": "example_string",
"content": "example_string",
"feedback": null,
"attachments": [
{
"type": {},
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf"
}
]
}
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/messages/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。
const axios = require('axios');
// 請求內容 (payload):
const data = {};
// 設定請求標頭
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY',
'Content-Type': 'application/json'
}
};
axios.post("https://api.maiagent.ai/api/v1/messages/", data, config)
.then(response => {
console.log('成功取得回應,以下是數據:');
console.log(response.data);
})
.catch(error => {
console.error('請求發生錯誤,請檢查請求內容與 API Key:');
console.error(error.response?.data || error.message);
});
import requests
import json
url = "https://api.maiagent.ai/api/v1/messages/"
headers = {
"Authorization": "Api-Key YOUR_API_KEY",
"Content-Type": "application/json"
}
# 請求內容 (payload)
data = {}
response = requests.post(url, json=data, headers=headers)
try:
print("成功取得回應,以下是返回數據:")
print(response.json())
except Exception as e:
print("請求出現錯誤,請檢查輸入參數與 API Key:", e)
<?php
require 'vendor/autoload.php';
$client = new GuzzleHttpClient();
try {
$response = $client->post("https://api.maiagent.ai/api/v1/messages/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY',
'Content-Type' => 'application/json'
],
// 請求內容 (payload) 已包含在請求中
'json' => {}
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:
";
print_r($data);
} catch (Exception $e) {
echo '發生錯誤, 請檢查請求細節及 API Key: ' . $e->getMessage();
}
?>
回應內容
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"conversation": "550e8400-e29b-41d4-a716-446655440000",
"sender": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"avatar": "example_string"
},
"type": "example_string",
"content": "example_string",
"feedback": null,
"createdAt": "pattern_example",
"attachments": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf"
}
],
"citations": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf",
"fileType": "example_string",
"size": 0,
"status": {},
"chatbotFileContent": "550e8400-e29b-41d4-a716-446655440000",
"parser": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"provider": "maiagent",
"priority": 0
},
"createdAt": "pattern_example"
}
],
"citationNodes": [
{
"chatbotTextNode": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"charactersCount": 0,
"hitsCount": 0,
"text": "example_string",
"updatedAt": "pattern_example",
"filename": "example.pdf"
},
"score": 0,
"displayScore": "example_string"
}
]
}
發送外部訊息 (建立)
POST /api/v1/messages/outgoing/
請求內容
{
"conversation": "550e8400-e29b-41d4-a716-446655440000",
"sender": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"avatar": "example_string"
},
"type": "example_string",
"content": "example_string",
"feedback": null,
"attachments": [
{
"type": {},
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf"
}
]
}
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/messages/outgoing/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。
const axios = require('axios');
// 請求內容 (payload):
const data = {};
// 設定請求標頭
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY',
'Content-Type': 'application/json'
}
};
axios.post("https://api.maiagent.ai/api/v1/messages/outgoing/", data, config)
.then(response => {
console.log('成功取得回應,以下是數據:');
console.log(response.data);
})
.catch(error => {
console.error('請求發生錯誤,請檢查請求內容與 API Key:');
console.error(error.response?.data || error.message);
});
import requests
import json
url = "https://api.maiagent.ai/api/v1/messages/outgoing/"
headers = {
"Authorization": "Api-Key YOUR_API_KEY",
"Content-Type": "application/json"
}
# 請求內容 (payload)
data = {}
response = requests.post(url, json=data, headers=headers)
try:
print("成功取得回應,以下是返回數據:")
print(response.json())
except Exception as e:
print("請求出現錯誤,請檢查輸入參數與 API Key:", e)
<?php
require 'vendor/autoload.php';
$client = new GuzzleHttpClient();
try {
$response = $client->post("https://api.maiagent.ai/api/v1/messages/outgoing/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY',
'Content-Type' => 'application/json'
],
// 請求內容 (payload) 已包含在請求中
'json' => {}
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:
";
print_r($data);
} catch (Exception $e) {
echo '發生錯誤, 請檢查請求細節及 API Key: ' . $e->getMessage();
}
?>
回應內容
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"conversation": "550e8400-e29b-41d4-a716-446655440000",
"sender": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"avatar": "example_string"
},
"type": "example_string",
"content": "example_string",
"feedback": null,
"createdAt": "pattern_example",
"attachments": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf"
}
],
"citations": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf",
"fileType": "example_string",
"size": 0,
"status": {},
"chatbotFileContent": "550e8400-e29b-41d4-a716-446655440000",
"parser": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"provider": "maiagent",
"priority": 0
},
"createdAt": "pattern_example"
}
],
"citationNodes": [
{
"chatbotTextNode": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"charactersCount": 0,
"hitsCount": 0,
"text": "example_string",
"updatedAt": "pattern_example",
"filename": "example.pdf"
},
"score": 0,
"displayScore": "example_string"
}
]
}
取得訊息列表
GET /api/v1/messages/
參數
參數名稱
必填
類型
說明
conversation
否
string
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/v1/messages/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。
const axios = require('axios');
// 設定請求標頭 (請替換 YOUR_API_KEY)
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY'
}
};
axios.get("https://api.maiagent.ai/api/v1/messages/", config)
.then(response => {
console.log('成功取得回應:');
console.log(response.data);
})
.catch(error => {
console.error('發生錯誤,請檢查 API Key 與請求參數:');
console.error(error.response?.data || error.message);
});
import requests
url = "https://api.maiagent.ai/api/v1/messages/"
headers = {
"Authorization": "Api-Key YOUR_API_KEY"
}
response = requests.get(url, headers=headers)
try:
print("成功取得回應,數據如下:")
print(response.json())
except Exception as e:
print("發生錯誤,請檢查 API 請求:", e)
<?php
require 'vendor/autoload.php';
$client = new GuzzleHttpClient();
try {
$response = $client->get("https://api.maiagent.ai/api/v1/messages/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY'
]
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:
";
print_r($data);
} catch (Exception $e) {
echo '錯誤, 請確認 API Key 與請求配置: ' . $e->getMessage();
}
?>
回應內容
{
"count": 0,
"next": "example_string",
"previous": "example_string",
"results": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"conversation": "550e8400-e29b-41d4-a716-446655440000",
"sender": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"avatar": "example_string"
},
"type": "example_string",
"content": "example_string",
"feedback": null,
"createdAt": "pattern_example",
"attachments": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf"
}
],
"citations": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf",
"fileType": "example_string",
"size": 0,
"status": {},
"chatbotFileContent": "550e8400-e29b-41d4-a716-446655440000",
"parser": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"provider": "maiagent",
"priority": 0
},
"createdAt": "pattern_example"
}
],
"citationNodes": [
{
"chatbotTextNode": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"charactersCount": 0,
"hitsCount": 0,
"text": "example_string",
"updatedAt": "pattern_example",
"filename": "example.pdf"
},
"score": 0,
"displayScore": "example_string"
}
]
}
]
}
取得特定訊息
GET /api/v1/messages/{id}/
參數
參數名稱
必填
類型
說明
id
是
string
A UUID string identifying this 訊息.
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/messages/550e8400-e29b-41d4-a716-446655440000/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。
const axios = require('axios');
// 設定請求標頭 (請替換 YOUR_API_KEY)
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY'
}
};
axios.get("https://api.maiagent.ai/api/v1/messages/550e8400-e29b-41d4-a716-446655440000/", config)
.then(response => {
console.log('成功取得回應:');
console.log(response.data);
})
.catch(error => {
console.error('發生錯誤,請檢查 API Key 與請求參數:');
console.error(error.response?.data || error.message);
});
import requests
url = "https://api.maiagent.ai/api/v1/messages/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("發生錯誤,請檢查 API 請求:", e)
<?php
require 'vendor/autoload.php';
$client = new GuzzleHttpClient();
try {
$response = $client->get("https://api.maiagent.ai/api/v1/messages/550e8400-e29b-41d4-a716-446655440000/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY'
]
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:
";
print_r($data);
} catch (Exception $e) {
echo '錯誤, 請確認 API Key 與請求配置: ' . $e->getMessage();
}
?>
回應內容
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"conversation": "550e8400-e29b-41d4-a716-446655440000",
"sender": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"avatar": "example_string"
},
"type": "example_string",
"content": "example_string",
"feedback": null,
"createdAt": "pattern_example",
"attachments": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf"
}
],
"citations": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf",
"fileType": "example_string",
"size": 0,
"status": {},
"chatbotFileContent": "550e8400-e29b-41d4-a716-446655440000",
"parser": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"provider": "maiagent",
"priority": 0
},
"createdAt": "pattern_example"
}
],
"citationNodes": [
{
"chatbotTextNode": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"charactersCount": 0,
"hitsCount": 0,
"text": "example_string",
"updatedAt": "pattern_example",
"filename": "example.pdf"
},
"score": 0,
"displayScore": "example_string"
}
]
}
建立新的對話
POST /api/v1/conversations/
請求內容
{
"contact": {
"name": "群組名稱",
"avatar": "example_string"
},
"inbox": {
"name": "群組名稱",
"channelType": {},
"unreadConversationsCount": 0
},
"lastMessage": {
"conversation": "550e8400-e29b-41d4-a716-446655440000",
"sender": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"avatar": "example_string"
},
"type": "example_string",
"content": "example_string",
"feedback": null,
"attachments": [
{
"type": {},
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf"
}
]
}
}
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X POST "https://api.maiagent.ai/api/v1/conversations/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。
const axios = require('axios');
// 請求內容 (payload):
const data = {};
// 設定請求標頭
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY',
'Content-Type': 'application/json'
}
};
axios.post("https://api.maiagent.ai/api/v1/conversations/", data, config)
.then(response => {
console.log('成功取得回應,以下是數據:');
console.log(response.data);
})
.catch(error => {
console.error('請求發生錯誤,請檢查請求內容與 API Key:');
console.error(error.response?.data || error.message);
});
import requests
import json
url = "https://api.maiagent.ai/api/v1/conversations/"
headers = {
"Authorization": "Api-Key YOUR_API_KEY",
"Content-Type": "application/json"
}
# 請求內容 (payload)
data = {}
response = requests.post(url, json=data, headers=headers)
try:
print("成功取得回應,以下是返回數據:")
print(response.json())
except Exception as e:
print("請求出現錯誤,請檢查輸入參數與 API Key:", e)
<?php
require 'vendor/autoload.php';
$client = new GuzzleHttpClient();
try {
$response = $client->post("https://api.maiagent.ai/api/v1/conversations/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY',
'Content-Type' => 'application/json'
],
// 請求內容 (payload) 已包含在請求中
'json' => {}
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:
";
print_r($data);
} catch (Exception $e) {
echo '發生錯誤, 請檢查請求細節及 API Key: ' . $e->getMessage();
}
?>
回應內容
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"contact": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"avatar": "example_string",
"createdAt": "pattern_example"
},
"inbox": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"channelType": {},
"unreadConversationsCount": 0
},
"title": "example_string",
"lastMessage": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"conversation": "550e8400-e29b-41d4-a716-446655440000",
"sender": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"avatar": "example_string"
},
"type": "example_string",
"content": "example_string",
"feedback": null,
"createdAt": "pattern_example",
"attachments": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf"
}
],
"citations": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf",
"fileType": "example_string",
"size": 0,
"status": {},
"chatbotFileContent": "550e8400-e29b-41d4-a716-446655440000",
"parser": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"provider": "maiagent",
"priority": 0
},
"createdAt": "pattern_example"
}
],
"citationNodes": [
{
"chatbotTextNode": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"charactersCount": 0,
"hitsCount": 0,
"text": "example_string",
"updatedAt": "pattern_example",
"filename": "example.pdf"
},
"score": 0,
"displayScore": "example_string"
}
]
},
"lastMessageCreatedAt": "pattern_example",
"unreadMessagesCount": 0,
"autoReplyEnabled": false,
"isAutoReplyNow": "example_string",
"lastReadAt": "pattern_example",
"createdAt": "pattern_example",
"isGroupChat": "example_string",
"enableGroupMention": "example_string"
}
取得對話列表
GET /api/v1/conversations/
參數
參數名稱
必填
類型
說明
cursor
否
string
The pagination cursor value.
inbox
否
string
pageSize
否
integer
Number of results to return per page.
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/conversations/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。
const axios = require('axios');
// 設定請求標頭 (請替換 YOUR_API_KEY)
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY'
}
};
axios.get("https://api.maiagent.ai/api/v1/conversations/", config)
.then(response => {
console.log('成功取得回應:');
console.log(response.data);
})
.catch(error => {
console.error('發生錯誤,請檢查 API Key 與請求參數:');
console.error(error.response?.data || error.message);
});
import requests
url = "https://api.maiagent.ai/api/v1/conversations/"
headers = {
"Authorization": "Api-Key YOUR_API_KEY"
}
response = requests.get(url, headers=headers)
try:
print("成功取得回應,數據如下:")
print(response.json())
except Exception as e:
print("發生錯誤,請檢查 API 請求:", e)
<?php
require 'vendor/autoload.php';
$client = new GuzzleHttpClient();
try {
$response = $client->get("https://api.maiagent.ai/api/v1/conversations/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY'
]
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:
";
print_r($data);
} catch (Exception $e) {
echo '錯誤, 請確認 API Key 與請求配置: ' . $e->getMessage();
}
?>
回應內容
{
"next": "example_string",
"previous": "example_string",
"results": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"contact": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"avatar": "example_string",
"createdAt": "pattern_example"
},
"inbox": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"channelType": {},
"unreadConversationsCount": 0
},
"title": "example_string",
"lastMessage": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"conversation": "550e8400-e29b-41d4-a716-446655440000",
"sender": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"avatar": "example_string"
},
"type": "example_string",
"content": "example_string",
"feedback": null,
"createdAt": "pattern_example",
"attachments": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf"
}
],
"citations": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf",
"fileType": "example_string",
"size": 0,
"status": {},
"chatbotFileContent": "550e8400-e29b-41d4-a716-446655440000",
"parser": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"provider": "maiagent",
"priority": 0
},
"createdAt": "pattern_example"
}
],
"citationNodes": [
{
"chatbotTextNode": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"charactersCount": 0,
"hitsCount": 0,
"text": "example_string",
"updatedAt": "pattern_example",
"filename": "example.pdf"
},
"score": 0,
"displayScore": "example_string"
}
]
},
"lastMessageCreatedAt": "pattern_example",
"unreadMessagesCount": 0,
"autoReplyEnabled": false,
"isAutoReplyNow": "example_string",
"lastReadAt": "pattern_example",
"createdAt": "pattern_example",
"isGroupChat": "example_string",
"enableGroupMention": "example_string"
}
]
}
取得特定對話
GET /api/v1/conversations/{id}/
參數
參數名稱
必填
類型
說明
id
是
string
A UUID string identifying this 對話.
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X GET "https://api.maiagent.ai/api/v1/conversations/550e8400-e29b-41d4-a716-446655440000/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。
const axios = require('axios');
// 設定請求標頭 (請替換 YOUR_API_KEY)
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY'
}
};
axios.get("https://api.maiagent.ai/api/v1/conversations/550e8400-e29b-41d4-a716-446655440000/", config)
.then(response => {
console.log('成功取得回應:');
console.log(response.data);
})
.catch(error => {
console.error('發生錯誤,請檢查 API Key 與請求參數:');
console.error(error.response?.data || error.message);
});
import requests
url = "https://api.maiagent.ai/api/v1/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("發生錯誤,請檢查 API 請求:", e)
<?php
require 'vendor/autoload.php';
$client = new GuzzleHttpClient();
try {
$response = $client->get("https://api.maiagent.ai/api/v1/conversations/550e8400-e29b-41d4-a716-446655440000/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY'
]
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:
";
print_r($data);
} catch (Exception $e) {
echo '錯誤, 請確認 API Key 與請求配置: ' . $e->getMessage();
}
?>
回應內容
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"contact": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"avatar": "example_string",
"createdAt": "pattern_example"
},
"inbox": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"channelType": {},
"unreadConversationsCount": 0
},
"title": "example_string",
"lastMessage": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"conversation": "550e8400-e29b-41d4-a716-446655440000",
"sender": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"avatar": "example_string"
},
"type": "example_string",
"content": "example_string",
"feedback": null,
"createdAt": "pattern_example",
"attachments": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"type": {},
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf"
}
],
"citations": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"filename": "example.pdf",
"file": "media/chatbots/chatbot-file/example.pdf",
"fileType": "example_string",
"size": 0,
"status": {},
"chatbotFileContent": "550e8400-e29b-41d4-a716-446655440000",
"parser": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "群組名稱",
"provider": "maiagent",
"priority": 0
},
"createdAt": "pattern_example"
}
],
"citationNodes": [
{
"chatbotTextNode": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"charactersCount": 0,
"hitsCount": 0,
"text": "example_string",
"updatedAt": "pattern_example",
"filename": "example.pdf"
},
"score": 0,
"displayScore": "example_string"
}
]
},
"lastMessageCreatedAt": "pattern_example",
"unreadMessagesCount": 0,
"autoReplyEnabled": false,
"isAutoReplyNow": "example_string",
"lastReadAt": "pattern_example",
"createdAt": "pattern_example",
"isGroupChat": "example_string",
"enableGroupMention": "example_string"
}
Last updated
Was this helpful?