LogoLogo
註冊/登入
  • 使用者手冊
  • 技術人員手冊
  • API 文件
  • AI 助理市集
  • 歡迎來到 MaiAgent
  • 生成式 AI 快速入門
    • 大型語言模型(LLM)
    • RAG 知識庫檢索系統
    • Embedding 模型
    • Reranker 模型
    • Parser 解析工具
    • 圖像辨識支援
    • 使用環境規劃(SaaS/私有雲/地端)
    • GPU 算力硬體規劃
  • 進階生成式 AI 技術
    • Text to SQL
    • Function Calling
    • Canvas
    • AI 安全防護機制
  • AI 助理模組
    • 角色指令
    • 知識庫
    • FAQ 常見問題管理
    • 回覆評估與監測結果
    • AWS Guardrails
  • API 串接
    • 快速上手
    • AI 助理列表
    • 對話與訊息回覆(串流/同步)
    • 建立對話與訊息
    • Webhook
    • 檔案上傳
    • 檔案上傳知識庫
    • 附件上傳
  • Line LIFF 串接
    • 什麼是 LINE LIFF
    • 如何串接
  • Remote MCP 串接
    • Remote MCP 服務概述
    • Composio 串接
  • 其他
    • Google Sheet 串接
    • n8n 串接
    • MaiAgent vs. Dify 比較
Powered by GitBook
On this page
  • 請求格式
  • 請求參數說明
  • Citations 物件參數
  • 請求範例
  • 響應格式
  • 成功響應

Was this helpful?

  1. API 串接

Webhook

Previous建立對話與訊息Next檔案上傳

Last updated 6 months ago

Was this helpful?

需要 開發者提供一個 API 端點,用於接收和處理傳入的 webhook 請求。MaiAgent 在串接方建立訊息後,會將 AI 助理的回覆回傳給此 Webhook 端點

Webhook 流程:

端點: https://<your-api-domain>/maiagent/webhook (由開發者自行設計)

請求方法: POST

請求格式

{
    "id": "string",
    "conversation": "string",
    "sender": {
        "id": "number",
        "name": "string",
        "avatar": "string"
    },
    "type": "string",
    "content": "string",
    "feedback": "null | object",
    "created_at": "string",
    "attachments": "array",
    "citations": "array"
}

請求參數說明

參數
類型
必填
描述

id

string

是

訊息唯一識別碼(UUID 格式)

conversation

string

是

對話識別碼

sender

object

是

發送者資訊

string

是

發送者 ID

string

是

發送者使用者 ID

sender.avatar

string

是

發送者頭像 URL

type

string

是

訊息類型(例如:outgoing)

content

string

是

訊息內容

feedback

null

object

否

createdAt

string

是

訊息創建時間戳(毫秒)

attachments

array

是

附件列表

citations

array

是

引用檔案列表

Citations 物件參數

參數
類型
必填
描述

id

string

是

檔案唯一識別碼

filename

string

是

檔案名稱

file

string

是

檔案 URL

fileType

string

是

檔案類型(例如:jsonl)

size

number

是

檔案大小(位元組)

status

string

是

檔案狀態

document

string

是

文件識別碼

createdAt

string

是

檔案創建時間戳(毫秒)

請求範例

curl -X POST \\
  -H "Content-Type: application/json" \\
  -d '{
    "id": "msg123",
    "conversation": "conv456",
    "sender": {
        "id": 789,
        "name": "測試用戶",
        "avatar": "<https://example.com/avatar.jpg>"
    },
    "type": "outgoing",
    "content": "這是 webhook 測試訊息",
    "feedback": null,
    "created_at": "1728219442000",
    "attachments": [],
    "citations": []
  }' \\
  https://<your-api-domain>/maiagent/webhook

響應格式

成功響應

請回傳 200,讓 MaiAgent 知道 Webhook 成功,否則將啟動 MaiAgent Retry Webhook 的機制

{
    "message": "Webhook 接收成功"
}

sender.id
sender.name