自動回覆 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 | 語意配對(進階方案) |
自動回覆規則
Section titled “自動回覆規則”取得規則列表
Section titled “取得規則列表”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,週末休息。"}| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
| keywords | string[] | 是 | 觸發關鍵字(至少一個) |
| question | string | 否 | 問題描述(供管理用) |
| answer | string | 是 | 回覆內容 |
回應
回傳更新後的完整規則資料。
PUT /api/channels/:channelId/assistant/qa/:qaId請求
{ "keywords": ["營業時間"], "question": "營業時間是?", "answer": "週一至週五 9:00-18:00(國定假日休息)"}DELETE /api/channels/:channelId/assistant/qa/:qaId回應
{ "success": true}取得歡迎訊息
Section titled “取得歡迎訊息”GET /api/channels/:channelId/assistant/welcome{ "updatedAt": "2025-01-15T08:00:00Z", "updatedBy": "U1234567890", "messages": [ { "type": "text", "content": "歡迎 {displayName} 加入 {groupName}!\n\n請先閱讀群組規則,有問題歡迎發問。" } ]}在歡迎訊息中可使用以下變數:
| 變數 | 說明 | 範例 |
|---|---|---|
{displayName} | 新成員名稱 | 王小明 |
{groupName} | 群組名稱 | 購物討論群 |
更新歡迎訊息
Section titled “更新歡迎訊息”PUT /api/channels/:channelId/assistant/welcome請求
{ "message": "歡迎 {displayName} 加入!\n\n這裡是 {groupName},請先閱讀置頂公告。"}取得群組規則
Section titled “取得群組規則”GET /api/channels/:channelId/assistant/rules{ "updatedAt": "2025-01-15T08:00:00Z", "updatedBy": "U1234567890", "content": "群組規則\n\n1. 禁止發送廣告\n2. 請友善發言\n3. 不討論政治話題\n\n違規者將被移出群組"}更新群組規則
Section titled “更新群組規則”PUT /api/channels/:channelId/assistant/rules請求
{ "content": "群組規則\n\n1. 禁止發送廣告\n2. 請友善發言\n3. 不討論政治話題"}使用者輸入觸發關鍵字時,機器人會回覆群組規則:
{ "triggerKeywords": ["群規", "規則", "群組規則"]}在 PUT /api/channels/:id/assistant/config 中設定。
{ "keywords": ["營業時間", "幾點開", "開店", "打烊"], "answer": "營業時間:9:00-18:00"}建議:
- 使用多個同義詞
- 包含常見錯字
- 簡短明確
歡迎訊息設計
Section titled “歡迎訊息設計”歡迎 {displayName} 加入!
快速入門:1. 閱讀置頂公告2. 自我介紹一下3. 有問題請發問
祝你在 {groupName} 玩得開心!建議:
- 簡潔友善
- 提供明確指引