對話與訊息

發送訊息 (串流)

POST /api/chatbots/{chatbotId}/completions/

參數

參數名稱
必填
類型
說明

chatbotId

string

請求內容

請求參數

欄位
類型
必填
說明

conversation

string (uuid)

對話的唯一識別碼,如果為空則會建立新對話(可選)

message

object

要發送的訊息內容

isStreaming

boolean

是否使用串流模式回應,預設為 false(可選)

請求結構範例

{
  "conversation"?: string (uuid) // 對話的唯一識別碼,如果為空則會建立新對話(可選) (非必填)
  "message": object // 要發送的訊息內容
  "isStreaming"?: boolean // 是否使用串流模式回應,預設為 false(可選) (非必填)
}

請求範例值

{
  "conversation": "550e8400-e29b-41d4-a716-446655440000",
  "message": null,
  "isStreaming": true
}

程式碼範例

# 呼叫 API 示例 (Shell)
curl -X POST --no-buffer "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 '{
    "conversation": "550e8400-e29b-41d4-a716-446655440000",
    "message": null,
    "isStreaming": true
  }'

# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。

# 註意: 此API返回的是串流數據,可以通過以下方式處理:
# 方法1: 使用jq處理每個JSON數據塊
# 例如: curl -X POST --no-buffer "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 '{
    "conversation": "550e8400-e29b-41d4-a716-446655440000",
    "message": null,
    "isStreaming": true
  }' | jq -r .

# 方法2: 使用管道將輸出寫入文件
# 例如: curl -X POST --no-buffer "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 '{
    "conversation": "550e8400-e29b-41d4-a716-446655440000",
    "message": null,
    "isStreaming": true
  }' > response.json

回應內容

狀態碼
說明

200

對話回應內容,若是串流則為事件流


發送訊息 (建立)

POST /api/messages/

請求內容

請求參數

欄位
類型
必填
說明

conversation

string (uuid)

type

string

content

string

contentPayload

object

attachments

array[AttachmentCreateInput]

canvas

object

queryMetadata

object

請求結構範例

{
  "conversation": string (uuid)
  "type"?: string // 非必填
  "content"?: string // 非必填
  "contentPayload"?: object // 非必填
  "attachments"?: [ // 非必填
    {
      "type"?: object // 非必填
      "filename": string
      "file": string (uri)
      "conversation"?: string (uuid) // 非必填
    }
  ]
  "canvas"?:  // 非必填
  {
    "name": string
    "canvasType": object
    "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 並核對請求資料。

回應內容

狀態碼: 201

回應結構範例

{
  "id": string (uuid)
  "conversation": string (uuid)
  "sender": object
  "type"?: string // 非必填
  "content"?: string // 非必填
  "contentPayload"?: object // 非必填
  "feedback": object
  "createdAt": string (timestamp)
  "attachments"?: [ // 非必填
    {
      "id": string (uuid)
      "type"?: object // 非必填
      "filename": string
      "file": string (uri)
      "conversation"?: string (uuid) // 非必填
    }
  ]
  "citations": [
    {
      "id": string (uuid)
      "filename": string // 檔案名稱
      "file": string (uri) // 要上傳的檔案
      "fileType": string
      "knowledgeBase"?: string (uuid) // 非必填
      "size": integer
      "status": object
      "parser": 
      {
        "id": string (uuid)
        "name": string
        "provider": string (enum: maiagent, llama, azure) // * `maiagent` - MaiAgent
* `llama` - Llama
* `azure` - Azure
        "order"?: integer // 非必填
      }
      "labels"?: [ // 非必填
        {
          "id": string (uuid)
          "name"?: string // 非必填
        }
      ]
      "rawUserDefineMetadata"?: object // 非必填
      "createdAt": string (timestamp)
    }
  ]
  "citationNodes": [
    {
      "chatbotTextNode": 
      {
        "id": string (uuid)
        "charactersCount": integer
        "hitsCount": integer
        "text": string
        "updatedAt": string (timestamp)
        "filename": string
        "chatbotFile": string (uuid)
        "pageNumber": integer
      }
      "score"?: number (double) // 非必填
      "displayScore": integer
    }
  ]
  "canvas"?:  // 非必填
  {
    "id": string (uuid)
    "name": string
    "canvasType": object
    "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 並核對請求資料。

回應內容

狀態碼: 201

回應結構範例

{
  "id": string (uuid)
  "contact": 
  {
    "id": string (uuid)
    "name": string
    "avatar"?: string (uri) // 非必填
    "createdAt": string (timestamp)
  }
  "inbox": 
  {
    "id": string (uuid)
    "name": string
    "channelType": object
    "unreadConversationsCount"?: integer // 非必填
    "signAuth"?: object // 非必填
  }
  "title": string
  "lastMessage"?:  // 非必填
  {
    "id": string (uuid)
    "type"?: string // 非必填
    "content"?: string // 非必填
    "contentPayload"?: object // 非必填
    "feedback": object
    "createdAt": string (timestamp)
    "queryMetadata"?: object // 非必填
  }
  "lastMessageCreatedAt": string (timestamp)
  "unreadMessagesCount": integer
  "autoReplyEnabled": boolean
  "isAutoReplyNow": boolean
  "lastReadAt": string (timestamp)
  "createdAt": string (timestamp)
  "isGroupChat": boolean
  "enableGroupMention": boolean
}

回應範例值

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "contact": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "response_string",
    "avatar": "response_string",
    "createdAt": "response_string"
  },
  "inbox": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "response_string",
    "channelType": {},
    "unreadConversationsCount": 456,
    "signAuth": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "signSource": "550e8400-e29b-41d4-a716-446655440000",
      "signParams": {
        "keycloak": {
          "clientId": "response_string",
          "url": "response_string",
          "realm": "response_string"
        },
        "line": {
          "liffId": "response_string"
        },
        "ad": {
          "saml": "response_string"
        }
      }
    }
  },
  "title": "response_string",
  "lastMessage": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "type": "response_string",
    "content": "response_string",
    "contentPayload": null,
    "feedback": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "type": {},
      "suggestion": "response_string",
      "updatedAt": "response_string"
    },
    "createdAt": "response_string",
    "queryMetadata": null
  },
  "lastMessageCreatedAt": "response_string",
  "unreadMessagesCount": 456,
  "autoReplyEnabled": false,
  "isAutoReplyNow": false,
  "lastReadAt": "response_string",
  "createdAt": "response_string",
  "isGroupChat": false,
  "enableGroupMention": false
}

取得訊息列表

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 並核對請求資料。

回應內容

狀態碼: 200

回應結構範例

{
  "count": integer
  "next"?: string (uri) // 非必填
  "previous"?: string (uri) // 非必填
  "results": [
    {
      "id": string (uuid)
      "conversation": string (uuid)
      "sender": object
      "type"?: string // 非必填
      "content"?: string // 非必填
      "contentPayload"?: object // 非必填
      "feedback": object
      "createdAt": string (timestamp)
      "attachments"?: [ // 非必填
        {
          "id": string (uuid)
          "type"?: object // 非必填
          "filename": string
          "file": string (uri)
          "conversation"?: string (uuid) // 非必填
        }
      ]
      "citations": [
        {
          "id": string (uuid)
          "filename": string // 檔案名稱
          "file": string (uri) // 要上傳的檔案
          "fileType": string
          "knowledgeBase"?: string (uuid) // 非必填
          "size": integer
          "status": object
          "parser": 
          {
            "id": string (uuid)
            "name": string
            "provider": string (enum: maiagent, llama, azure) // * `maiagent` - MaiAgent
* `llama` - Llama
* `azure` - Azure
            "order"?: integer // 非必填
          }
          "labels"?: [ // 非必填
            {
              "id": string (uuid)
              "name"?: string // 非必填
            }
          ]
          "rawUserDefineMetadata"?: object // 非必填
          "createdAt": string (timestamp)
        }
      ]
      "citationNodes": [
        {
          "chatbotTextNode": 
          {
            "id": string (uuid)
            "charactersCount": integer
            "hitsCount": integer
            "text": string
            "updatedAt": string (timestamp)
            "filename": string
            "chatbotFile": string (uuid)
            "pageNumber": integer
          }
          "score"?: number (double) // 非必填
          "displayScore": integer
        }
      ]
      "canvas"?:  // 非必填
      {
        "id": string (uuid)
        "name": string
        "canvasType": object
        "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": 456,
        "name": "response_string",
        "avatar": "response_string"
      },
      "type": "response_string",
      "content": "response_string",
      "contentPayload": null,
      "feedback": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "type": {},
        "suggestion": "response_string",
        "updatedAt": "response_string"
      },
      "createdAt": "response_string",
      "attachments": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "type": {},
          "filename": "response_string",
          "file": "response_string",
          "conversation": "550e8400-e29b-41d4-a716-446655440000"
        }
      ],
      "citations": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "filename": "response_string",
          "file": "response_string",
          "fileType": "response_string",
          "knowledgeBase": "550e8400-e29b-41d4-a716-446655440000",
          "size": 456,
          "status": {},
          "parser": {
            "id": "550e8400-e29b-41d4-a716-446655440000",
            "name": "response_string",
            "provider": "maiagent",
            "order": 456
          },
          "labels": [
            {
              "id": "550e8400-e29b-41d4-a716-446655440000",
              "name": "response_string"
            }
          ],
          "rawUserDefineMetadata": null,
          "createdAt": "response_string"
        }
      ],
      "citationNodes": [
        {
          "chatbotTextNode": {
            "id": "550e8400-e29b-41d4-a716-446655440000",
            "charactersCount": 456,
            "hitsCount": 456,
            "text": "response_string",
            "updatedAt": "response_string",
            "filename": "response_string",
            "chatbotFile": "550e8400-e29b-41d4-a716-446655440000",
            "pageNumber": 456
          },
          "score": 456,
          "displayScore": 456
        }
      ],
      "canvas": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "response_string",
        "canvasType": {},
        "title": "response_string",
        "content": "response_string",
        "createdAt": "response_string"
      },
      "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 並核對請求資料。

回應內容

狀態碼: 200

回應結構範例

{
  "id": string (uuid)
  "conversation": string (uuid)
  "sender": object
  "type"?: string // 非必填
  "content"?: string // 非必填
  "contentPayload"?: object // 非必填
  "feedback": object
  "createdAt": string (timestamp)
  "attachments"?: [ // 非必填
    {
      "id": string (uuid)
      "type"?: object // 非必填
      "filename": string
      "file": string (uri)
      "conversation"?: string (uuid) // 非必填
    }
  ]
  "citations": [
    {
      "id": string (uuid)
      "filename": string // 檔案名稱
      "file": string (uri) // 要上傳的檔案
      "fileType": string
      "knowledgeBase"?: string (uuid) // 非必填
      "size": integer
      "status": object
      "parser": 
      {
        "id": string (uuid)
        "name": string
        "provider": string (enum: maiagent, llama, azure) // * `maiagent` - MaiAgent
* `llama` - Llama
* `azure` - Azure
        "order"?: integer // 非必填
      }
      "labels"?: [ // 非必填
        {
          "id": string (uuid)
          "name"?: string // 非必填
        }
      ]
      "rawUserDefineMetadata"?: object // 非必填
      "createdAt": string (timestamp)
    }
  ]
  "citationNodes": [
    {
      "chatbotTextNode": 
      {
        "id": string (uuid)
        "charactersCount": integer
        "hitsCount": integer
        "text": string
        "updatedAt": string (timestamp)
        "filename": string
        "chatbotFile": string (uuid)
        "pageNumber": integer
      }
      "score"?: number (double) // 非必填
      "displayScore": integer
    }
  ]
  "canvas"?:  // 非必填
  {
    "id": string (uuid)
    "name": string
    "canvasType": object
    "title": string
    "content": string
    "createdAt": string (timestamp)
  }
  "queryMetadata"?: object // 非必填
}

回應範例值

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "conversation": "550e8400-e29b-41d4-a716-446655440000",
  "sender": {
    "id": 456,
    "name": "response_string",
    "avatar": "response_string"
  },
  "type": "response_string",
  "content": "response_string",
  "contentPayload": null,
  "feedback": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "type": {},
    "suggestion": "response_string",
    "updatedAt": "response_string"
  },
  "createdAt": "response_string",
  "attachments": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "type": {},
      "filename": "response_string",
      "file": "response_string",
      "conversation": "550e8400-e29b-41d4-a716-446655440000"
    }
  ],
  "citations": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "filename": "response_string",
      "file": "response_string",
      "fileType": "response_string",
      "knowledgeBase": "550e8400-e29b-41d4-a716-446655440000",
      "size": 456,
      "status": {},
      "parser": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "response_string",
        "provider": "maiagent",
        "order": 456
      },
      "labels": [
        {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "name": "response_string"
        }
      ],
      "rawUserDefineMetadata": null,
      "createdAt": "response_string"
    }
  ],
  "citationNodes": [
    {
      "chatbotTextNode": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "charactersCount": 456,
        "hitsCount": 456,
        "text": "response_string",
        "updatedAt": "response_string",
        "filename": "response_string",
        "chatbotFile": "550e8400-e29b-41d4-a716-446655440000",
        "pageNumber": 456
      },
      "score": 456,
      "displayScore": 456
    }
  ],
  "canvas": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "response_string",
    "canvasType": {},
    "title": "response_string",
    "content": "response_string",
    "createdAt": "response_string"
  },
  "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 並核對請求資料。

回應內容

狀態碼: 200

回應結構範例

{
  "next"?: string (uri) // 非必填
  "previous"?: string (uri) // 非必填
  "results": [
    {
      "id": string (uuid)
      "contact": 
      {
        "id": string (uuid)
        "name": string
        "avatar"?: string (uri) // 非必填
        "createdAt": string (timestamp)
      }
      "inbox": 
      {
        "id": string (uuid)
        "name": string
        "channelType": object
        "unreadConversationsCount"?: integer // 非必填
        "signAuth"?: object // 非必填
      }
      "title": string
      "lastMessage"?:  // 非必填
      {
        "id": string (uuid)
        "type"?: string // 非必填
        "content"?: string // 非必填
        "contentPayload"?: object // 非必填
        "feedback": object
        "createdAt": string (timestamp)
        "queryMetadata"?: object // 非必填
      }
      "lastMessageCreatedAt": string (timestamp)
      "unreadMessagesCount": integer
      "autoReplyEnabled": boolean
      "isAutoReplyNow": boolean
      "lastReadAt": string (timestamp)
      "createdAt": string (timestamp)
      "isGroupChat": boolean
      "enableGroupMention": boolean
    }
  ]
}

回應範例值

{
  "next": "http://api.example.org/accounts/?cursor=cD00ODY%3D\"",
  "previous": "http://api.example.org/accounts/?cursor=cj0xJnA9NDg3",
  "results": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "contact": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "response_string",
        "avatar": "response_string",
        "createdAt": "response_string"
      },
      "inbox": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "response_string",
        "channelType": {},
        "unreadConversationsCount": 456,
        "signAuth": {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "signSource": "550e8400-e29b-41d4-a716-446655440000",
          "signParams": {
            "keycloak": {
              "clientId": "response_string",
              "url": "response_string",
              "realm": "response_string"
            },
            "line": {
              "liffId": "response_string"
            },
            "ad": {
              "saml": "response_string"
            }
          }
        }
      },
      "title": "response_string",
      "lastMessage": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "type": "response_string",
        "content": "response_string",
        "contentPayload": null,
        "feedback": {
          "id": "550e8400-e29b-41d4-a716-446655440000",
          "type": {},
          "suggestion": "response_string",
          "updatedAt": "response_string"
        },
        "createdAt": "response_string",
        "queryMetadata": null
      },
      "lastMessageCreatedAt": "response_string",
      "unreadMessagesCount": 456,
      "autoReplyEnabled": false,
      "isAutoReplyNow": false,
      "lastReadAt": "response_string",
      "createdAt": "response_string",
      "isGroupChat": false,
      "enableGroupMention": false
    }
  ]
}

取得特定對話

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 並核對請求資料。

回應內容

狀態碼: 200

回應結構範例

{
  "id": string (uuid)
  "contact": 
  {
    "id": string (uuid)
    "name": string
    "avatar"?: string (uri) // 非必填
    "createdAt": string (timestamp)
  }
  "inbox": 
  {
    "id": string (uuid)
    "name": string
    "channelType": object
    "unreadConversationsCount"?: integer // 非必填
    "signAuth"?: object // 非必填
  }
  "title": string
  "lastMessage"?:  // 非必填
  {
    "id": string (uuid)
    "type"?: string // 非必填
    "content"?: string // 非必填
    "contentPayload"?: object // 非必填
    "feedback": object
    "createdAt": string (timestamp)
    "queryMetadata"?: object // 非必填
  }
  "lastMessageCreatedAt": string (timestamp)
  "unreadMessagesCount": integer
  "autoReplyEnabled": boolean
  "isAutoReplyNow": boolean
  "lastReadAt": string (timestamp)
  "createdAt": string (timestamp)
  "isGroupChat": boolean
  "enableGroupMention": boolean
}

回應範例值

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "contact": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "response_string",
    "avatar": "response_string",
    "createdAt": "response_string"
  },
  "inbox": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "response_string",
    "channelType": {},
    "unreadConversationsCount": 456,
    "signAuth": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "signSource": "550e8400-e29b-41d4-a716-446655440000",
      "signParams": {
        "keycloak": {
          "clientId": "response_string",
          "url": "response_string",
          "realm": "response_string"
        },
        "line": {
          "liffId": "response_string"
        },
        "ad": {
          "saml": "response_string"
        }
      }
    }
  },
  "title": "response_string",
  "lastMessage": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "type": "response_string",
    "content": "response_string",
    "contentPayload": null,
    "feedback": {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "type": {},
      "suggestion": "response_string",
      "updatedAt": "response_string"
    },
    "createdAt": "response_string",
    "queryMetadata": null
  },
  "lastMessageCreatedAt": "response_string",
  "unreadMessagesCount": 456,
  "autoReplyEnabled": false,
  "isAutoReplyNow": false,
  "lastReadAt": "response_string",
  "createdAt": "response_string",
  "isGroupChat": false,
  "enableGroupMention": false
}

取得 AI 助理對話紀錄

GET /api/chatbots/{chatbotPk}/records/

參數

參數名稱
必填
類型
說明

chatbotPk

string

A UUID string identifying this Chatbot ID

botMessage

string

page

integer

A page number within the paginated result set.

pageSize

integer

Number of results to return per page.

userMessage

string

程式碼範例

# 呼叫 API 示例 (Shell)
curl -X GET "https://api.maiagent.ai/api/chatbots/550e8400-e29b-41d4-a716-446655440000/records/?botMessage=example&page=1&pageSize=1&userMessage=example" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。

回應內容

狀態碼: 200

回應結構範例

{
  "count": integer
  "next"?: string (uri) // 非必填
  "previous"?: string (uri) // 非必填
  "results": [
    {
      "id": string (uuid)
      "senderName": string // 返回使用者訊息發送者的名稱
      "feedback": object
      "inputMessage": string
      "condenseMessage": string // 綜合聊天歷史與上下文後,修飾過後的使用者訊息
      "outputMessage": string
      "context": string
      "faithfulnessScore": number (double) // 判斷chatbot回覆是否符合資料庫內容,是否憑空想像
      "displayFaithfulnessScore": integer
      "answerRelevancyScore": number (double) // 判斷chatbot回覆是否與使用者問題相關
      "displayAnswerRelevancyScore": integer
      "contextPrecisionScore": number (double) // 判斷chatbot回覆是否與參考資料相關
      "displayContextPrecisionScore": integer
      "answerCorrectnessScore": number (double) // 判斷chatbot回覆是否正確(需要有標準答案)
      "displayAnswerCorrectnessScore": integer
      "answerSimilarityScore": number (double) // 判斷chatbot回覆是否與標準答案相似
      "displayAnswerSimilarityScore": integer
      "contextRecallScore": number (double) // 判斷chatbot回覆是否能夠從參考資料中召回相關資料
      "displayContextRecallScore": integer
      "replyTime": string
      "createdAt": string (timestamp)
      "error": string // 儲存執行過程中的錯誤訊息
      "processingTime": object // 回傳各個處理階段的時間統計
      "wordsCount": integer // 回傳使用者訊息和 AI 助理回覆的總字數
      "tokens": object // 回傳 token 使用量統計
      "citationNodes": [
        {
          "id": string
          "text": string
        }
      ]
    }
  ]
}

回應範例值

{
  "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",
      "senderName": "response_string",
      "feedback": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "type": {},
        "suggestion": "response_string",
        "updatedAt": "response_string"
      },
      "inputMessage": "response_string",
      "condenseMessage": "response_string",
      "outputMessage": "response_string",
      "context": "response_string",
      "faithfulnessScore": 456,
      "displayFaithfulnessScore": 456,
      "answerRelevancyScore": 456,
      "displayAnswerRelevancyScore": 456,
      "contextPrecisionScore": 456,
      "displayContextPrecisionScore": 456,
      "answerCorrectnessScore": 456,
      "displayAnswerCorrectnessScore": 456,
      "answerSimilarityScore": 456,
      "displayAnswerSimilarityScore": 456,
      "contextRecallScore": 456,
      "displayContextRecallScore": 456,
      "replyTime": "response_string",
      "createdAt": "response_string",
      "error": "response_string",
      "processingTime": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "回應範例名稱",
        "description": "回應範例描述"
      },
      "wordsCount": 456,
      "tokens": {
        "id": "550e8400-e29b-41d4-a716-446655440000",
        "name": "回應範例名稱",
        "description": "回應範例描述"
      },
      "citationNodes": [
        {
          "id": "response_string",
          "text": "response_string"
        }
      ]
    }
  ]
}

對話紀錄匯出為 Excel 檔案

GET /api/chatbots/{chatbotPk}/records/export-excel/

參數

參數名稱
必填
類型
說明

chatbotPk

string

A UUID string identifying this Chatbot ID

程式碼範例

# 呼叫 API 示例 (Shell)
curl -X GET "https://api.maiagent.ai/api/chatbots/550e8400-e29b-41d4-a716-446655440000/records/export-excel/" \
  -H "Authorization: Api-Key YOUR_API_KEY"

# 請確認在執行前替換 YOUR_API_KEY 並核對請求資料。

回應內容

狀態碼
說明

200

Excel 檔案下載


Last updated

Was this helpful?