跳到內容

自動回覆 API

管理群組的自動回覆功能。

GET /api/channels/:channelId/assistant/config
{
"assistant": {
"enabled": true,
"qa": {
"enabled": true,
"mode": "keyword",
"noMatchReply": null
},
"welcome": {
"enabled": true,
"message": "歡迎加入!"
},
"rules": {
"enabled": true,
"triggerKeywords": ["群規", "規則"]
}
}
}
PUT /api/channels/:channelId/assistant/config
{
"assistant": {
"enabled": true,
"qa": {
"enabled": true,
"mode": "keyword"
}
}
}
模式說明
keyword完全符合關鍵字
fuzzy模糊配對
semantic語意配對(進階方案)

GET /api/channels/:channelId/assistant/qa
{
"updatedAt": "2025-01-15T08:00:00Z",
"updatedBy": "U1234567890",
"items": [
{
"id": "qa_1705312800000_abc123",
"keywords": ["營業時間", "幾點開"],
"question": "營業時間是什麼時候?",
"answer": "我們的營業時間是週一至週五 9:00-18:00,週末休息。",
"createdAt": "2025-01-15T08:00:00Z",
"createdBy": "U1234567890",
"hitCount": 42
}
]
}
POST /api/channels/:channelId/assistant/qa

請求

{
"keywords": ["營業時間", "幾點開", "開店時間"],
"question": "營業時間是什麼時候?",
"answer": "我們的營業時間是週一至週五 9:00-18:00,週末休息。"
}
欄位類型必填說明
keywordsstring[]觸發關鍵字(至少一個)
questionstring問題描述(供管理用)
answerstring回覆內容

回應

回傳更新後的完整規則資料。

PUT /api/channels/:channelId/assistant/qa/:qaId

請求

{
"keywords": ["營業時間"],
"question": "營業時間是?",
"answer": "週一至週五 9:00-18:00(國定假日休息)"
}
DELETE /api/channels/:channelId/assistant/qa/:qaId

回應

{
"success": true
}

GET /api/channels/:channelId/assistant/welcome
{
"updatedAt": "2025-01-15T08:00:00Z",
"updatedBy": "U1234567890",
"messages": [
{
"type": "text",
"content": "歡迎 {displayName} 加入 {groupName}!\n\n請先閱讀群組規則,有問題歡迎發問。"
}
]
}

在歡迎訊息中可使用以下變數:

變數說明範例
{displayName}新成員名稱王小明
{groupName}群組名稱購物討論群
PUT /api/channels/:channelId/assistant/welcome

請求

{
"message": "歡迎 {displayName} 加入!\n\n這裡是 {groupName},請先閱讀置頂公告。"
}

GET /api/channels/:channelId/assistant/rules
{
"updatedAt": "2025-01-15T08:00:00Z",
"updatedBy": "U1234567890",
"content": "群組規則\n\n1. 禁止發送廣告\n2. 請友善發言\n3. 不討論政治話題\n\n違規者將被移出群組"
}
PUT /api/channels/:channelId/assistant/rules

請求

{
"content": "群組規則\n\n1. 禁止發送廣告\n2. 請友善發言\n3. 不討論政治話題"
}

使用者輸入觸發關鍵字時,機器人會回覆群組規則:

{
"triggerKeywords": ["群規", "規則", "群組規則"]
}

PUT /api/channels/:id/assistant/config 中設定。


{
"keywords": ["營業時間", "幾點開", "開店", "打烊"],
"answer": "營業時間:9:00-18:00"
}

建議:

  • 使用多個同義詞
  • 包含常見錯字
  • 簡短明確
歡迎 {displayName} 加入!
快速入門:
1. 閱讀置頂公告
2. 自我介紹一下
3. 有問題請發問
祝你在 {groupName} 玩得開心!

建議:

  • 簡潔友善
  • 提供明確指引