用戶標籤

本教學將說明如何透過 API 來操作 BotBonnie 平台的標籤,包含建立 / 刪除標籤和標籤資料夾,以及如何將標籤貼到用戶身上等。

建立新標籤

在您的伺服器呼叫 BotBonnie 建立標籤的 API:
POST https://api.botbonnie.com/v1/api/tag/autogen

Request headers

Name
Description
Content-Type
application/json
Authorization
Bearer {API Token}

Request body

Name
Type
Description
Required
botId
String
機器人 ID
o
name
String
標籤名稱
o
type
Number
標籤類型
0:用戶標籤
1:標籤資料夾
o
parentId
Number
標籤資料夾 ID

API 回覆

新增成功

{
"res": "{
"id": "tag-xxxxxx" //建立成功之標籤 ID
}",
"status": 200
}

錯誤

{
"errorMessage": "...",
"errorCode": 500
}

取得標籤內容

在您的伺服器呼叫 BotBonnie 取得標籤的 API:
GET https://api.botbonnie.com/v1/api/tag/{{tagID}}

Query path parameters

Name
Description
tagId
欲查詢的標籤或是標籤資料夾 ID

Request headers

Name
Description
Content-Type
application/json
Authorization
Bearer {API Token}

API 回覆

回應範例

{
"res": {
"created": 1583983892294, // 標籤建立時的 UNIX 時間戳記(毫秒)
"id": "tag--PTfLM4wQ", // 標籤 ID
"name": "測試API標籤 child", // 標籤名稱
"botId": "bot-WDCLEHlTw", // 機器人 ID
"type": 0 // 標籤類型
},
"status": 200
}

刪除標籤

在您的伺服器呼叫 BotBonnie 刪除標籤的 API,刪除標籤時,也會同時拔除所有用戶身上的該標籤紀錄。當刪除的標籤為資料夾,會將其資料夾下的標籤與子資料夾一併刪除。
DELETE https://api.botbonnie.com/v1/api/tag/{{tagID}}

Query path parameters

Name
Description
tagId
欲刪除的標籤或是標籤資料夾 ID

Request headers

Name
Description
Content-Type
application/json
Authorization
Bearer {API Token}

API 回覆

回應範例

{
"res": [
"tag--PTfLM4Q"
], // 此陣列中包含所有被刪除的標籤 ID 與標籤資料夾 ID
"status": 200
}

貼標籤到用戶身上

在您的伺服器呼叫 BotBonnie 用戶標籤 API:
POST https://api.botbonnie.com/v1/api/user/tag

Request headers

Name
Description
Content-Type
application/json
Authorization
Bearer {API Token}

Request body

Name
Type
Description
Required
bot_tag_id
String
標籤 ID
o
bot_uid
String
用戶 ID (加密)
與 bot_raw_uid 擇一
bot_raw_uid
String
用戶 ID (未加密)
與 bot_uid 擇一
bot_pid
String
粉絲頁 ID
o
bot_channel
Number
渠道代號 0:Facebook 1:LINE
o

移除用戶身上的標籤

在您的伺服器呼叫 BotBonnie 用戶標籤 API:
DELETE https://api.botbonnie.com/v1/api/user/tag

Request headers

Name
Description
Content-Type
application/json
Authorization
Bearer {API Token}

Request body

Name
Type
Description
Required
bot_tag_id
String
標籤 ID
o
bot_uid
String
用戶 ID (加密)
與 bot_raw_uid 擇一
bot_raw_uid
String
用戶 ID (未加密)
與 bot_uid 擇一
bot_pid
String
粉絲頁 ID
o
bot_channel
Number
渠道代號 0:Facebook 1:LINE
o

API 回覆

新增 / 刪除成功

{
"res": "ok",
"status": 200
}

錯誤

{
"errorMessage": "...",
"errorCode": 500
}

查詢用戶身上的標籤

在您的伺服器呼叫 BotBonnie 用戶標籤 API:
POST https://api.botbonnie.com/v1/api/user/taglist

Request headers

Name
Description
Content-Type
application/json
Authorization
Bearer {API Token}

Request Body

Name
Type
Description
Required
bot_uid
String
用戶 ID (加密)
與 bot_raw_uid 擇一
bot_raw_uid
String
用戶 ID (未加密)
與 bot_uid 擇一
bot_pid
String
粉絲頁 ID
o
bot_channel
Number
渠道代號 0:Facebook 1:LINE
o

API 回覆

回應範例

{
"res":[
{
"bot_uid":"53f224d55bd378237ad26dd0d79002f7206527ab1e91bd3d84bf05c9c6ac761291",
"bot_raw_uid":"U21ab30ccce78feb456048adeb80cf00a",
"bot_pid":"test_audi",
"bot_channel":1,
"tags":[
{
"id": "tag-4TbbFavFY",
"name": "標籤A",
"timestamp": 1540869097545
},
{
"id": "tag-Aw3IcRKNt",
"name": "標籤B",
"timestamp": 1540869134405
},
{
"id": "tag-bcpe7NStr",
"name": "標籤C",
"timestamp": 1540869152985
}
]
}
]
,"status":200
}