對話 Widget
取得特定 Web Chat
GET /api/web-chats/{id}/
參數
參數名稱
必填
類型
說明
id
✅
string
A UUID string identifying this web chat.
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X GET "https://api.maiagent.ai/api/web-chats/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/web-chats/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/web-chats/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/web-chats/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)
"name": string
"avatar"?: string (uri) // 非必填
"logo"?: string (uri) // 非必填
"description"?: string // 非必填
"cover"?: string (uri) // 非必填
"backUrl"?: string // 非必填
"isActive"?: boolean // 非必填
"enableSpeech": boolean
"displayGreeting": string
"displayConversationStarters": [
string
]
"theme": {
{
"primaryColor"?: string // 非必填
"navbarTextColor"?: string // 非必填
"conversationBackgroundColor"?: string // 非必填
"chatbotMessageTextColor"?: string // 非必填
"userMessageTextColor"?: string // 非必填
"chatbotMessageBackgroundColor"?: string // 非必填
"userMessageBackgroundColor"?: string // 非必填
"chatbotMessageBackgroundShadowEnabled"?: boolean // 非必填
"userMessageBackgroundShadowEnabled"?: boolean // 非必填
}
}
"darkTheme": {
{
"primaryColor"?: string // 非必填
"navbarTextColor"?: string // 非必填
"conversationBackgroundColor"?: string // 非必填
"chatbotMessageTextColor"?: string // 非必填
"userMessageTextColor"?: string // 非必填
"chatbotMessageBackgroundColor"?: string // 非必填
"userMessageBackgroundColor"?: string // 非必填
"chatbotMessageBackgroundShadowEnabled"?: boolean // 非必填
"userMessageBackgroundShadowEnabled"?: boolean // 非必填
}
}
"enableFileUpload"?: boolean // 非必填
"enableDisplayCitations"?: boolean // 非必填
"enableDisplayToolResults"?: boolean // 非必填
"enableShareConversation"?: boolean // 非必填
"enableLocation"?: boolean // 非必填
"enableShowPoweredBy"?: boolean // 非必填
"poweredByLogo"?: string (uri) // 非必填
"enableAnonymous"?: boolean // 非必填
"enableDisplayPreviousConversation"?: boolean // 非必填
"enableDisplayConversationHistory"?: boolean // 非必填
"enableConversationTimer"?: boolean // 非必填
"conversationTimerDuration"?: integer // 計時器逾時時長,範圍 3-60 分鐘 (非必填)
"enableAutoNewConversationOnTimeout"?: boolean // 非必填
"accessType":
{
}
"enableThemeModeToggle"?: boolean // 非必填
"enableDisplayFontSizeSwitch"?: boolean // 非必填
"defaultThemeMode"?: // 非必填
{
}
"enableDownloadCitations"?: boolean // 非必填
"customDomain"?: // 非必填
{
"id": string (uuid)
"domain": string
"status":
{
}
}
"enableDisplayChatbotAvatar"?: boolean // 非必填
"enableDisplayChatbotName"?: boolean // 非必填
"inbox": object
}回應範例值
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "測試 doc",
"avatar": "https://example.com/static/images/default-chatbot-avatar.png",
"logo": null,
"description": "",
"cover": null,
"backUrl": "",
"isActive": true,
"enableSpeech": false,
"displayGreeting": null,
"displayConversationStarters": [],
"theme": {
"primaryColor": "#3854d8",
"dialogColor": "#ddeaf6",
"navbarTextColor": "#ffffff"
},
"enableFileUpload": true,
"enableDisplayCitations": true,
"enableShareConversation": false,
"enableLocation": false,
"enableShowPoweredBy": true,
"poweredByLogo": null,
"accessType": "web",
"inbox": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"name": "測試 doc",
"signAuth": {
"id": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
"signSource": {
"id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"accessType": "keycloak"
},
"signParams": {
"keycloak": {
"url": "example.com",
"realm": "example",
"clientId": "example"
}
}
}
}
}獲取 LLM 使用統計
GET /api/chatbots/{chatbotPk}/llm-usage-statistics/
參數
參數名稱
必填
類型
說明
chatbotPk
✅
string
A UUID string identifying this Chatbot ID
endDate
❌
string
結束日期,格式: YYYY-MM-DD
startDate
✅
string
開始日期,格式: YYYY-MM-DD
timeGranularity
✅
string
時間粒度 (day/month)
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X GET "https://api.maiagent.ai/api/chatbots/550e8400-e29b-41d4-a716-446655440000/llm-usage-statistics/?endDate=example&startDate=example&timeGranularity=day" \
-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/chatbots/550e8400-e29b-41d4-a716-446655440000/llm-usage-statistics/?endDate=example&startDate=example&timeGranularity=day", 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/llm-usage-statistics/?endDate=example&startDate=example&timeGranularity=day"
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/chatbots/550e8400-e29b-41d4-a716-446655440000/llm-usage-statistics/?endDate=example&startDate=example&timeGranularity=day", [
'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
回應結構範例
[
{
"chatbotId": string (uuid)
"wordsCount"?: integer (int64) // 非必填
"llmModelId": string
"llmModelName": string
"llmModelProvider": string
"date": string (date)
"totalWordsCount": integer // 計算特定日期和組織的總詞數
"llmDetails": [ // 獲取相同日期和組織的所有模型記錄
object
]
}
]回應範例值
[
[
{
"totalWordsCount": 511,
"month": "2025-03-01",
"llmDetails": [
{
"chatbotId": "5b646600-f6e0-4f07-aec7-0207a26c0a9b",
"wordsCount": 511,
"llmModelId": "d4282719-f50e-4a82-88d0-953e202a3383",
"llmModelName": "GPT-4o-2024-08-06",
"llmModelProvider": "openai"
}
]
}
]
]狀態碼: 400
回應結構範例
{
"detail"?: string // 非必填
"valid_types"?: [ // 非必填
string
]
}回應範例值
[
[
{
"totalWordsCount": 511,
"month": "2025-03-01",
"llmDetails": [
{
"chatbotId": "5b646600-f6e0-4f07-aec7-0207a26c0a9b",
"wordsCount": 511,
"llmModelId": "d4282719-f50e-4a82-88d0-953e202a3383",
"llmModelName": "GPT-4o-2024-08-06",
"llmModelProvider": "openai"
}
]
}
]
]取得 AI 助理統計數據
GET /api/chatbots/{chatbotPk}/statistics/
參數
參數名稱
必填
類型
說明
chatbotPk
✅
string
A UUID string identifying this Chatbot ID
datetimeFrom
❌
string
開始時間
datetimeTo
❌
string
結束時間
timeGranularity
❌
string
時間粒度 (hour/day/month)
程式碼範例
# 呼叫 API 示例 (Shell)
curl -X GET "https://api.maiagent.ai/api/chatbots/550e8400-e29b-41d4-a716-446655440000/statistics/?datetimeFrom=example&datetimeTo=example&timeGranularity=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/chatbots/550e8400-e29b-41d4-a716-446655440000/statistics/?datetimeFrom=example&datetimeTo=example&timeGranularity=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/chatbots/550e8400-e29b-41d4-a716-446655440000/statistics/?datetimeFrom=example&datetimeTo=example&timeGranularity=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/chatbots/550e8400-e29b-41d4-a716-446655440000/statistics/?datetimeFrom=example&datetimeTo=example&timeGranularity=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
回應結構範例
[
{
"datetime": string (timestamp)
"messagesCount"?: integer // 非必填
"conversationsCount"?: integer // 非必填
"avgMessagesPerConversation": number (double)
"avgLikesPerFeedback": number (double)
}
]回應範例值
[
{
"datetime": "回應字串",
"messagesCount": 456,
"conversationsCount": 456,
"avgMessagesPerConversation": 456,
"avgLikesPerFeedback": 456
}
]啟用或停用特定 AI 助理的評估功能
PATCH /api/chatbots/{id}/enable-evaluation/
參數
參數名稱
必填
類型
說明
id
✅
string
A UUID string identifying this Chatbot.
請求內容
請求參數
欄位
類型
必填
說明
enableEvaluation
boolean
否
請求結構範例
{
"enableEvaluation"?: boolean // 非必填
}請求範例值
{
"enableEvaluation": true
}程式碼範例
# 呼叫 API 示例 (Shell)
curl -X PATCH "https://api.maiagent.ai/api/chatbots/550e8400-e29b-41d4-a716-446655440000/enable-evaluation/" \
-H "Authorization: Api-Key YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"enableEvaluation": true
}'
# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。const axios = require('axios');
// 設定請求標頭
const config = {
headers: {
'Authorization': 'Api-Key YOUR_API_KEY',
'Content-Type': 'application/json'
}
};
// 請求內容 (payload)
const data = {
"enableEvaluation": true
};
axios.patch("https://api.maiagent.ai/api/chatbots/550e8400-e29b-41d4-a716-446655440000/enable-evaluation/", 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/enable-evaluation/"
headers = {
"Authorization": "Api-Key YOUR_API_KEY",
"Content-Type": "application/json"
}
# 請求內容 (payload)
data = {
"enableEvaluation": true
}
response = requests.patch(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->patch("https://api.maiagent.ai/api/chatbots/550e8400-e29b-41d4-a716-446655440000/enable-evaluation/", [
'headers' => [
'Authorization' => 'Api-Key YOUR_API_KEY',
'Content-Type' => 'application/json'
],
'json' => {
"enableEvaluation": true
}
]);
$data = json_decode($response->getBody(), true);
echo "成功取得回應:\n";
print_r($data);
} catch (Exception $e) {
echo '請求發生錯誤: ' . $e->getMessage();
}
?>回應內容
狀態碼: 200
回應結構範例
{
"enableEvaluation"?: boolean // 非必填
}回應範例值
{
"enableEvaluation": false
}Last updated
Was this helpful?
