# 文件說明

此為技術文件。行銷或客服同仁，請參考[教學手冊](https://blog.botbonnie.com/%e6%95%99%e5%ad%b8%e6%94%bb%e7%95%a5/)。

如有任何問題，請聯繫 <hi@botbonnie.com> ，由專人為您服務。


# 帳號綁定

本教學將說明如何在對話訊息流程中引導用戶綁定企業的個人帳號，並在用戶完成登入後，提供用戶個人化服務功能。例如：訂單查詢、點數查詢等。

## 1. 何謂綁定帳號？

綁定帳號可將 BotBonnie 中的用戶 ID 與企業用戶 ID 綁定，用戶綁定完成之後，企業可以藉由 JSON API 識別對話中的用戶是企業資料庫中的哪一名註冊用戶，進而提供個人化的服務。

BotBonnie 提供進階套件 **帳號綁定**，並在套件中預設之 **開始綁定** 模組設定有 **登入** 按鈕。藉由在對話視窗中登入企業會員帳號，即可將 BotBonnie 之 **userId** 與企業用戶 ID 綁定。

### 1.1 「登入」按鈕設定

請於 BotBonnie 後台設定綁定帳號的按鈕，並填入基本的設定。

| 設定名稱       | 類型  | 描述                                            |
| ---------- | --- | --------------------------------------------- |
| **登入轉址網址** | URL | 企業登入網頁網址，當用戶點擊 **登入** 時會以 webview 形式在對話介面中開啟。 |

### 1.2  網址參數

當用戶按下 **登入** 按鈕時，用戶會在訊息視窗內開啟您的登入網址，BotBonnie 會根據 LINE / Messenger 添加網址參數。

#### **LINE 網址參數(query string)**：

| Name          | Type   | Description                                                                          |
| ------------- | ------ | ------------------------------------------------------------------------------------ |
| **userId**    | String | 用戶 ID                                                                                |
| **pageId**    | String | LINE OA ID                                                                           |
| **carry**     | String | BotBonnie 用來判斷往後流程的參數(僅用於 **BotBonnie Redirect**)                                    |
| **linkToken** | String | LINE 產生之 **一次性** 驗證權杖，每個帳號綁定按鈕只可綁定(點擊)一次, 有效時間 **10** 分鐘(僅用於 **BotBonnie Redirect**) |

#### **Messenger 網址參數(query string)**：

| Name                        | Type   | Description                                                 |
| --------------------------- | ------ | ----------------------------------------------------------- |
| **userId**                  | String | 用戶 ID                                                       |
| **pageId**                  | String | FB 粉專 ID                                                    |
| **carry**                   | String | BotBonnie 用來判斷往後流程的參數(僅用於 **BotBonnie Redirect**)           |
| **redirect\_uri**           | String | Messenger 指定綁定完成後需重導向之網址(僅用於 **BotBonnie Redirect**)        |
| **account\_linking\_token** | String | Messenger 產生之短期權杖，有效時間 **5** 分鐘(僅用於 **BotBonnie Redirect**) |

記得將 **userId** 存入您的資料庫內，爾後的個人化服務可依此資料做用戶識別。

## 2. 處理「綁定帳號成功」

### 2.1. 網址重新導向

當用戶綁定（登入）成功時，建議您提供一個頁面告知用戶已登入成功，並重導向至 **BotBonnie Redirect**, 重導向時須根據 LINE / Messenger 平台帶入網址參數, BotBonnie 會依據平台幫用戶重新導向。

**BotBonnie Redirect**:

```
https://rd.botbonnie.com/account/link?{query}
```

#### **帶入 LINE 網址參數(query string)**：

| Name          | Type                            | Description                                                                                                                                                                     | Required |
| ------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| **carry**     | String                          | BotBonnie 用來判斷往後流程的參數                                                                                                                                                           | o        |
| **linkToken** | String                          | LINE 產生之 **一次性** 驗證權杖，每個帳號綁定按鈕只可綁定(點擊)一次, 有效期間 **10** 分鐘                                                                                                                        | o        |
| **nonce**     | String ( 10 \~ 255 characters ) | 使用用戶在企業內之相對應 ID 產生之[不重複字串](https://developers.line.biz/en/docs/messaging-api/linking-accounts/#verifying-user-id)，ex: 使用 secure random function 產生 128 bytes 之隨機碼並轉換成 base64 字串 | o        |

#### **帶入 Messenger 網址參數(query string)**：

| Name                        | Type   | Description                     | Required |
| --------------------------- | ------ | ------------------------------- | -------- |
| **carry**                   | String | BotBonnie 用來判斷往後流程的參數           | o        |
| **redirect\_uri**           | String | Messenger 指定綁定完成後需重導向之網址        | o        |
| **account\_linking\_token** | String | Messenger 產生之短期權杖，有效時間 **5** 分鐘 | o        |
| **authorization\_code**     | String | 企業用戶 ID                         | o        |

## 3. 處理「解除綁定帳號成功」

有兩種情況會使 BotBonnie 與用戶的帳號解除綁定，第一種是用戶主動在對話式介面中點擊解除綁定帳號按鈕，第二種是企業主動透過 API 方式通知 BotBonnie 解除與用戶的帳號綁定關係。

### 3.1 企業主動解除與用戶的帳號綁定

企業也可以主動解除與用戶的帳號綁定，請呼叫 BotBonnie API，通知我們進行以下動作：

1. 解除用戶帳號綁定狀態
2. 觸發動作

在您的伺服器呼叫 BotBonnie API ：

```
POST https://api.botbonnie.com/v1/api/accountLink/unlink
```

#### **Request headers**

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

* [如何取得 `API Token`](/chang-jian-wen-ti/ru-he-qu-de-api-token) ？

#### **Request body**

| Name              | Type   | Description                     | Required |
| ----------------- | ------ | ------------------------------- | -------- |
| **bot\_id**       | String | 機器人的 ID                         | o        |
| **bot\_raw\_uid** | String | 用戶 ID (請帶入網址參數中相對應之 **userId**) | o        |
| **bot\_pid**      | String | 粉絲頁 ID                          | o        |
| **bot\_channel**  | Number | 渠道代號   `0`：Facebook `1`：LINE    | o        |
| **actions**       | Array  | 觸發動作                            | x        |

#### **actions：**

* 儲存用戶參數

  ```
  {
    "type": "saveParams",
    "name": "age",
    "value": "18"
  }
  ```
* 新增標籤

  ```
  {
    "type": "addTag",
    "value": "tag-4VW8DDgwu", // 請至 BotBonnie 後台設定標籤後，再帶入相對應之 tag ID
  }
  ```
* 移除標籤

  ```
  {
    "type": "removeTag",
    "value": "tag-4VW8DDgwu", // 請至 BotBonnie 後台設定標籤後，再帶入相對應之 tag ID
  }
  ```
* 通知專員

  ```
  {
    "type": "notifyAgent",
    "message": "用戶已解除綁定" // OPTIONAL
  }
  ```

## 4. 提供個人化服務

### 4.1. 準備個人化服務 API

BotBonnie 在呼叫您的個人化服務 API 時，會在 Request Body 內攜帶 **用戶識別資料**，並在 Request Header 攜帶 `X-Hub-Signature` 確保來源安全性，而您的個人化服務 API 需回傳 BotBonnie 特定訊息 JSON 格式。

詳細使用方法可參考[如何使用 JSON 訊息](/jiao-xue-fan-li/ru-he-shi-yong-json-xun-xi)。

### 4.2. 放置個人化服務按鈕

在對話腳本內，放置個人化服務按鈕，連結至含有「JSON 訊息（JSON API）」的模組，並將您的個人化服務 API 網址填上即可。


# 用戶推播

本教學將說明對用戶推播的兩種方式，分別適用於不同的場景。您可以依照需求選擇適合的推播方式。

## 1. 使用 BotBonnie 後台進行推播

透過 BotBonnie 的後台，您可以使用網站介面填寫下列資料以進行大範圍的訊息廣播：

* 粉絲頁 或 LINE 官方帳號
* (Messenger 推播時）填寫推播標籤，標示推播內容的種類，必須符合 Facebook 政策。
* 推播的模組

此種推播方式適用於對所有（或是特定用戶族群）廣播訊息，網站的介面會顯示預估觸及人數，方便您預估推播的成效。

## 2. 使用 push API 進行推播

當您需要對特定用戶推送個人化訊息時，就需要整合與 BotBonnie 的推播 API。

根據您服務的商業邏輯，可以在適當的時機於您的伺服器呼叫 BotBonnie 推播 API，**請不要在客戶端（client side）呼叫 API**，以避免您的 API token 遭到竊取。

### 訊息內容

您可以選擇推送單一特定訊息，或是先在 BotBonnie 後台建立好模組，以模組 ID 來推送。

* 特定訊息：單一訊息格式請使用 JSON object，請參閱 [JSON 訊息](/jiao-xue-fan-li/ru-he-shi-yong-json-xun-xi)。
* 模組訊息：請在 `Request body` 中以 `bot_mid` 指定模組 ID。

### 何謂訊息類別（category)？

BotBonnie 透過類別來歸類個人化推播訊息，以便在報表中提供您各種類的訊息數量。若沒有填寫，在報表中會將該訊息統一歸類在`未知的類別`。

您可以根據您的商業邏輯自行命名分類的名稱，常見的例如：`product_arrived`、`refund`...等等。

在您的伺服器呼叫 BotBonnie 推播 API：

```
POST https://api.botbonnie.com/v1/api/message/push
```

**Request headers**

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

* [如何取得 `API Token`](/chang-jian-wen-ti/ru-he-qu-de-api-token) ？

**Request body**

| Name                      | Type   | Description                                                                                                                                                                                                                                                                                     | Required           |
| ------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
| **bot\_id**               | String | 機器人的 ID                                                                                                                                                                                                                                                                                         | o                  |
| **bot\_uid** (deprecated) | 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                  |
| **bot\_mid**              | String | 模組 ID                                                                                                                                                                                                                                                                                           | 與 message 擇一       |
| **message**               | Object | 訊息內容                                                                                                                                                                                                                                                                                            | 與 bot\_mid 擇一      |
| **type**                  | String | <p>推播內容之標籤，可使用之類型如下：</p><p><strong><code>POST\_PURCHASE\_UPDATE</code></strong>：購買商品更新資訊</p><p><strong><code>CONFIRMED\_EVENT\_UPDATE</code></strong>：排定活動更新訊息</p><p><strong><code>ACCOUNT\_UPDATE</code></strong>：帳號更新</p><p><strong><code>UPDATE</code></strong>：一般更新訊息，僅能在用戶互動後 24 小時內推播</p> | 推播渠道為 Facebook 時必填 |
| **category**              | String | 訊息類別   限 20 個字元以下                                                                                                                                                                                                                                                                               |                    |

* [訊息格式請參閱 JSON 訊息](/jiao-xue-fan-li/ru-he-shi-yong-json-xun-xi/zhi-yuan-de-xun-xi-ge-shi)


# 用戶標籤

本教學將說明如何透過 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}` |

* [如何取得 `API Token`](/chang-jian-wen-ti/ru-he-qu-de-api-token) ？

#### **Request body**

| Name         | Type   | Description                                                      | Required |
| ------------ | ------ | ---------------------------------------------------------------- | -------- |
| **botId**    | String | 機器人 ID                                                           | o        |
| **name**     | String | 標籤名稱                                                             | o        |
| **type**     | Number | <p>標籤類型</p><p><code>0</code>：用戶標籤</p><p><code>1</code>：標籤資料夾</p> | 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，刪除標籤時，也會同時拔除所有用戶身上的該標籤紀錄。當刪除的標籤為資料夾，會將其資料夾下的標籤與子資料夾一併刪除。<br>

```
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 | <p>渠道代號  <br><code>0</code>：Facebook<br><code>1</code>：LINE</p> | 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 | <p>渠道代號  <br><code>0</code>：Facebook<br><code>1</code>：LINE</p> | 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 | <p>渠道代號  <br><code>0</code>：Facebook<br><code>1</code>：LINE</p> | 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
}
```


# 用戶參數

本教學將說明如何透過 API 來操作 BotBonnie 平台的用戶參數，目前提供對用戶增加參數的 API。

## 新增用戶身上的參數

在您的伺服器呼叫 BotBonnie 用戶標籤 API：

```
POST https://api.botbonnie.com/v1/api/user/params
```

### **Request headers**

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

### **Request body**

| Name              | Type   | Description                  | Required |
| ----------------- | ------ | ---------------------------- | -------- |
| **bot\_raw\_uid** | String | 用戶 ID                        | o        |
| **bot\_id**       | String | 機器人 ID                       | o        |
| **bot\_pid**      | String | 粉絲頁 ID                       | o        |
| **bot\_channel**  | Number | 渠道代號   `0`：Facebook `1`：LINE | o        |
| **params**        | Object | 參數物件，範例如下                    | o        |

### Params 範例物件

#### 新增或修改參數值

```javascript
{
    "gender": "male" // 範例：新增或修改性別參數，值為 male
}
```

```javascript
{
    "gender": {
        "value": "male"
    } // 範例: 使用 object 來新增或修改性別參數值
}
```

## 刪除用戶身上的參數

在您的伺服器呼叫 BotBonnie 用戶標籤 API：

```
DELETE https://api.botbonnie.com/v1/api/user/params
```

### **Request headers**

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

### **Request body**

| Name              | Type   | Description                  | Required |
| ----------------- | ------ | ---------------------------- | -------- |
| **bot\_raw\_uid** | String | 用戶 ID                        | o        |
| **bot\_id**       | String | 機器人 ID                       | o        |
| **bot\_pid**      | String | 粉絲頁 ID                       | o        |
| **bot\_channel**  | Number | 渠道代號   `0`：Facebook `1`：LINE | o        |
| **params**        | Object | 參數物件，範例如下                    | o        |

### Params 範例物件

```javascript
{
    "gender": {
        "groupId": ""
    }
}
```


# 用戶資料

本教學將說明如何透過 API 來取得一個機器人下所有用戶的基本資料。

## 取得用戶資料

在您的伺服器呼叫 BotBonnie 用戶資料 API：

```
GET https://api.botbonnie.com/v1/api/bot/customers
```

### **Request headers**

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

* [如何取得 `API Token`](/chang-jian-wen-ti/ru-he-qu-de-api-token) ？

### **Query parameters**

| Name      | Description                                                                            | Required |
| --------- | -------------------------------------------------------------------------------------- | -------- |
| **botId** | 機器人 ID                                                                                 | o        |
| **limit** | 單次呼叫欲截取的筆數 \[1-3086]                                                                   | o        |
| **from**  | 13 碼的 timestamp，抓取「最後互動時間」在這個 timestamp 之後的用戶（如果沒有帶則沒有限制）                              | x        |
| **next**  | 截取下一頁用的 key，從前一頁的 [Res 物件](/jiao-xue-fan-li/user-data#res-wu-jian) 中取得（如果沒有帶則會回第一頁的資料） | x        |

### **Response body**

| Name       | Type   | Description                                                  |
| ---------- | ------ | ------------------------------------------------------------ |
| **res**    | Object | 用戶 ID，見 [**Res 物件**](/jiao-xue-fan-li/user-data#res-wu-jian) |
| **status** | Number | HTTP Status                                                  |

#### Res 物件

| Name        | Type           | Description                                                          |
| ----------- | -------------- | -------------------------------------------------------------------- |
| **records** | Array\[Record] | 所有用戶的資料，見 [**Record 物件**](/jiao-xue-fan-li/user-data#record-wu-jian) |
| **next**    | String         | 截取下一頁所需的 key                                                         |

#### Record 物件

| Name           | Type          | Description                                                          |
| -------------- | ------------- | -------------------------------------------------------------------- |
| **id**         | String        | 用戶的 LINE / FB Messenger ID                                           |
| **name**       | String        | 用戶的姓名                                                                |
| **platform**   | String        | 值為 FB / LINE                                                         |
| **pageId**     | String        | FB 粉專或 LINE 官方帳號 ID                                                  |
| **status**     | Number        | 用戶的狀態，值的定義分別為  1: 運行中  2: 暫停中  3: 已停止  4: 被封鎖  5:主動封鎖                |
| **created**    | Number        | 初次互動時間，為 13 碼的 timestamp                                             |
| **lastActive** | Number        | 上次互動時間，為 13 碼的 timestamp                                             |
| **pic**        | String        | 大頭照的連結                                                               |
| **tags**       | Array\[Tag]   | 用戶身上的標籤列表，見 [**Tag 物件**](/jiao-xue-fan-li/user-data#tag-wu-jian)     |
| **params**     | Array\[Param] | 用戶身上的參數列表，見 [**Param 物件**](/jiao-xue-fan-li/user-data#param-wu-jian) |
| **email**      | String        | 用戶的個人信箱                                                              |
| **gender**     | String        | 用戶的性別，男 / 女                                                          |
| **birthday**   | String        | 用戶的生日，YYYY-MM-DD 的格式                                                |
| **phone**      | String        | 用戶的電話                                                                |
| **extId**      | String        | 帳號綁定完取得的 ID                                                          |

#### Tag 物件

| Name          | Type   | Description                    |
| ------------- | ------ | ------------------------------ |
| **id**        | String | 標籤 ID                          |
| **name**      | String | 標籤名稱                           |
| **timestamp** | Number | 最後一次被貼上此標籤的時間，為 13 碼 timestamp |
| **count**     | Number | 被貼上此標籤的次數                      |

#### Param 物件

| Name          | Type   | Description                |
| ------------- | ------ | -------------------------- |
| **name**      | String | 參數名稱                       |
| **value**     | String | 參數值                        |
| **timestamp** | Number | 此參數被設定的時間，為 13 碼 timestamp |

### 範例

#### 取得第一頁

**Request**

```
GET https://api.botbonnie.com/v1/api/bot/customers?botId=bot-n3WIChboi&limit=1
```

**Response body**

```javascript
{
    "res": {
        "records": [
            {
                "id": "",
                "name": "陳邦尼",
                "platform": "FB",
                "pageId": "",
                "status": 1,
                "created": 1576728847151,
                "lastActive": 1598512257867,
                "params": [
                    {
                        "name": "birthday",
                        "value": "2020-06-02",
                        "timestamp": 1594897339883
                    },
                    {
                        "name": "location",
                        "value": "???",
                        "timestamp": 1594897345660
                    },
                    {
                        "name": "phone",
                        "value": "0999999999",
                        "timestamp": 1594897335025
                    }
                ],
                "birthday": "1999-09-09",
                "email": "",
                "phone": "0900123456",
                "tags": [],
                "pic": ""
            }
        ],
        "next": "895c79bac725e96ab2dc3ed8a7162909b7dc974323125e32fbfb1bd7b8711ea84ebf41e152ddd3fae7b34161fde046ea47382164336abb151369071ba926729d2a6d6927e18182dff7da0513bb81506b0c641fc8c175f224896664de912b1ac9cc0e7bfa3a6f30"
        // 用來取得第二頁的 key
    },
    "status": 200
}
```

#### 取得第二頁

**Request**

```
GET https://api.botbonnie.com/v1/api/bot/customers?botId=bot-n3WIChboi&limit=1&next=895c79bac725e96ab2dc3ed8a7162909b7dc974323125e32fbfb1bd7b8711ea84ebf41e152ddd3fae7b34161fde046ea47382164336abb151369071ba926729d2a6d6927e18182dff7da0513bb81506b0c641fc8c175f224896664de912b1ac9cc0e7bfa3a6f30
```

**Response body**

```javascript
{
    "res": {
        "records": [
            {
                "id": "",
                "name": "孫邦尼",
                "platform": "FB",
                "pageId": "",
                "status": 1,
                "created": 1579664574373,
                "lastActive": 1596705419231,
                "params": [],
                "tags": [
                    {
                        "id": "",
                        "name": "推播",
                        "timestamp": 1584502439638,
                        "count": 2
                    }
                ],
                "pic": ""
            }
        ],
        "next": "895c79bac725e96ab2dc3ed8a7162909b7d2954224145a3cf1fe1dd7b8711ea84ebf41ed50dad3fbefba4460f5e640ef4d3a2164336abb151369071ba926729d2a6d6927e18182dff7da0513bb81506b0c641fc8c175f224896664de912b1ac9cc0e7bfa3a6f30"
    },
    "status": 200
}
```


# 用戶訊息

本教學將說明如何透過 API 來取得一個機器人下的用戶訊息紀錄。

## Get Message history

<mark style="color:blue;">`GET`</mark> `https://api.botbonnie.com/v1/api/message/history`

#### Query Parameters

| Name     | Type    | Description                          |
| -------- | ------- | ------------------------------------ |
| botId    | string  | 機器人 ID                               |
| pageId   | string  | 粉專 ID                                |
| platform | integer | 粉專平台 facebook 填 0, line 填 1          |
| userId   | string  | 欲查詢的使用者ID                            |
| from     | integer | 13 碼 timestamp 預設為 0                 |
| to       | integer | 13 碼 timestamp 預設為 current timestamp |
| limit    | integer | 回傳的訊息筆數，最大 100，預設 100                |
| desc     | boolean | true 為以時間做降冪排序，預設為 true              |

#### Headers

| Name          | Type   | Description          |
| ------------- | ------ | -------------------- |
| Authorization | string | Bearer `{API Token}` |

{% tabs %}
{% tab title="200 Cake successfully retrieved." %}

```
{
    "res": {
        "messages": [
            {
                "category": "conversation",
                "type": "reply",
                "data": {
                    "quickReplies": [],
                    "text": "文字內容",
                    "type": "text"
                },
                "timestamp": 1623918332624,
                "mid": "0_29612160-1bd1-4358-aee7-9a0ff605cae6"
            },
            {
                "category": "conversation",
                "type": "click",
                "timestamp": 1623918331847,
                "senderId": "xxxxxx",
                "data": {
                    "type": "click",
                    "title": "快速回覆"
                }
            }
        ],
        "desc": true
    },
    "status": 200
}
```

{% endtab %}
{% endtabs %}

{% content-ref url="/pages/-LB5E-0YYIeQoHCeUJy4" %}
[如何取得 API Token？](/chang-jian-wen-ti/ru-he-qu-de-api-token)
{% endcontent-ref %}

### **Response body**

| Name       | Type   | Description                                                       |
| ---------- | ------ | ----------------------------------------------------------------- |
| **res**    | Object | 見[ **Res 物件**](/jiao-xue-fan-li/user-message-history#res-wu-jian) |
| **status** | Number | HTTP Status                                                       |

#### Res 物件

| Name         | Type            | Description                                                                      |
| ------------ | --------------- | -------------------------------------------------------------------------------- |
| **messages** | Array\[Message] | 用戶訊息資料，見[ Message **物件**](/jiao-xue-fan-li/user-message-history#message-wu-jian) |
| **desc**     | Boolean         | 是否為降冪排序                                                                          |

#### Message 物件

| Name           | Type    | Description                                                         |
| -------------- | ------- | ------------------------------------------------------------------- |
| **category**   | String  | 紀錄分類                                                                |
| **type**       | String  | 紀錄類型                                                                |
| **data**       | Object  | 訊息內容， [Data 物件](/jiao-xue-fan-li/user-message-history#data-wu-jian) |
| **timestamp**  | Integer | 紀錄發生時間，13 碼 timestamp                                               |
| **operatorId** | Number  | 回覆的操作者  ID，只有在後台即時訊息單獨回覆使用者時才會存在                                    |
| **senderId**   | Number  | 使用者 ID                                                              |

#### Data 物件

| Name             | Type               | Description                                                                       |
| ---------------- | ------------------ | --------------------------------------------------------------------------------- |
| **type**         | String             | 訊息類型                                                                              |
| **text**         | String             | 訊息文字                                                                              |
| **payload**      | String             | 訊息內容                                                                              |
| **quickReplies** | Array\[quickReply] | 快速回復按鈕， [QuickReply 物件](/jiao-xue-fan-li/user-message-history#quickreply-wu-jian) |
| **buttons**      | Array\[button]     | 按鈕列表，[Button 物件](/jiao-xue-fan-li/user-message-history#button-wu-jian)            |
| **link**         | String             | url                                                                               |
| **cards**        | Array\[card]       | 輪播卡片，[ Card 物件](/jiao-xue-fan-li/user-message-history#card-wu-jian)               |

#### QuickReply 物件

| Name      | Type   | Description |
| --------- | ------ | ----------- |
| **title** | String | 按鈕文字        |
| **type**  | String | 按鈕類型        |

#### Button 物件

| Name      | Type   | Description |
| --------- | ------ | ----------- |
| **title** | String | 按鈕文字        |
| **type**  | String | 按鈕類型        |

#### Card 物件

| Name                   | Type           | Description                                                             |
| ---------------------- | -------------- | ----------------------------------------------------------------------- |
| **title**              | String         | 標題                                                                      |
| **subtitle**           | String         | 描述文字                                                                    |
| **imageUrl**           | String         | 圖片網址                                                                    |
| **imageClickShortUrl** | String         | 圖片點擊的縮址 url                                                             |
| **imageClickOrignUrl** | String         | 圖片點擊設定的 url                                                             |
| **buttons**            | Array\[button] | 按鈕列表，[ Button 物件](/jiao-xue-fan-li/user-message-history#button-wu-jian) |

### 範例 Message object 訊息

使用者行為的紀錄類別包含 click, text, image, video, audio, file, sticker, follow, unfollow, open\_url&#x20;

reply 則為機器人回覆紀錄，push 為推播紀錄

reply/push 會包含的訊息種類有 text, image, video, audio, gallery (輪播訊息), imagemap (圖文訊息)

#### click Type

為使用者點擊按鈕時產生的事件紀錄

```
{
    "category": "conversation",
    "type": "click",
    "timestamp": 1623046482461,
    "senderId": "xxxxxxx",
    "data": {
        "type": "click",
        "title": "被點擊的按鈕文字"
    }
}
```

#### text Type

使用者發送文字訊息時的事件紀錄

```
{
    "category": "conversation",
    "type": "text",
    "timestamp": 1623907684961,
    "senderId": "xxxxxxx",
    "data": {
        "type": "text",
        "payload": "使用者輸入的文字"
    }
}
```

#### image/video/audio/file Type

使用者傳送圖片影片音訊檔案的類型的訊息時的事件紀錄

```
{
    "category": "conversation",
    "type": "audio/video/image/file",
    "timestamp": 1623907089811,
    "senderId": "xxxxxx",
    "data": {
        "type": "audio/video/image/file",
        "payload": "xxxxxx" // content message id
    },
    "mid": "14239393100682"
}
```

#### sticker Type

使用者傳送貼圖訊息時的事件紀錄

```
{
    "category": "conversation",
    "type": "sticker",
    "timestamp": 1615965080838,
    "senderId": "xxxxxx",
    "data": {
        "type": "sticker",
        "payload": {
            "packageId": "xxxx",
            "stickerId": "xxxxxx"
        }
    }
}
```

#### follow/unfollow Type

使用者追蹤官方帳號或封鎖時的事件紀錄

```
{
    "category": "system",
    "type": "follow/unfollow",
    "timestamp": 1622626402433
}
```

#### open\_url Type

使用者開啟 url 時的事件紀錄&#x20;

```
{
    "category": "system",
    "type": "open_url",
    "timestamp": 1620206520431,
    "data": {
        "type": "open_url",
        "link": "https://www.botbonnie.com"
    }
}
```

#### Reply/Push Type with data of text type

回覆文字訊息的紀錄

```
{
    "category": "conversation",
    "type": "reply/push",
    "data": {
        "quickReplies": [
            {
                "title": "快速回覆",
                "type": "text",
                "payload": "{\"fm\":\"module-xxxxxx\",\"to\":\"module-xxxxx\",\"id\":\"qr_0\",\"bid\":\"bot-xxxxxxx\",\"bv\":\"PROD\",\"ti\":\"快速回覆\"}"
            }
        ],
        "type": "text",
        "text": "文字訊息內容"
    },
    "timestamp": 1622198735278,
    "mid": "0_0_92d674b9-cdd0-4357-a8de-dd6b58d9b021",
    "operatorId": "xxxxxxx"
}
```

#### Reply/Push Type with data of  image/video/audio type

回覆影像/影片/音訊的訊息紀錄

```
{
    "category": "conversation",
    "type": "reply",
    "data": {
        "type": "video",
        "videoUrl": "https://xxxxxxx", // exist in video
        "imageUrl": "https://xxxxxxx", // exist in image
        "audioUrl": "https://xxxxxxx"  // exist in audio
    },
    "timestamp": 1623907690653,
    "mid": "3_3_857803a6-de80-4def-a2e3-56134db79b1f"
}
```

#### Reply/Push Type with data of imagemap type

回覆圖文訊息的紀錄

```
{
    "category": "conversation",
    "type": "reply",
    "data": {
        "baseUrl": "https://xxxxx", //image
        "quickReplies": [],
        "buttons": [
            {
                "area": {
                    "x": 0,
                    "width": 1040,
                    "y": 0,
                    "height": 1040
                },
                "type": "web_url",
                "value": "https://xxxxxx",
                "shortUrl": "https://xxxxxxxxxxx",
                "originUrl": "https://xxxxxxxx"
            }
        ],
        "size": {
            "width": 1040,
            "height": 1040
        },
        "text": "圖文訊息",
        "type": "imagemap"
    },
    "timestamp": 1623915747419,
    "mid": "4_4_00a3323f-4a1e-4d3a-a8ec-593969091c4a"
}
```

#### Reply/Push Type with data of gallery type

回覆輪播訊息的紀錄

```
{
    "category": "conversation",
    "type": "reply",
    "data": {
        "cards": [
            {
                "imageClickShortUrl": "https://xxxxxx",
                "buttons": [],
                "imageClickUrl": "https://xxxxxx",
                "subtitle": "描述",
                "imageUrl": "https://xxxxx",
                "title": "卡片 1 標題",
                "imageClickOriginUrl": "https://xxxxxx"
            },
            {
                "imageClickShortUrl": "https://xxxxxx",
                "buttons": [],
                "imageClickUrl": "https://xxxxxx",
                "subtitle": "描述",
                "imageUrl": "https://xxxxx",
                "title": "卡片 2 標題",
                "imageClickOriginUrl": "https://xxxxxx"
            }
        ],
        "type": "gallery",
        "imageStyle": "horizontal"
    },
    "timestamp": 1623907690652,
    "mid": "2_2_857803a6-de80-4def-a2e3-56134db79b1f"
}
```


# 如何使用 JSON 訊息？

BotBonnie 提供特殊的**JSON 訊息**格式，可以利用此種訊息格式，串接您的服務，由您的伺服器動態提供不同的訊息內容。僅需提供您的 `JSON API URL`，在呼叫您的 API 時，BotBonnie 會自動帶入以下資料：

* 在 Request Body 帶入**用戶識別資料**
* 在 Request Header 帶入 `X-Hub-Signature` 做安全性驗證

而您的 API 需回傳 BotBonnie 特定訊息 JSON 格式。

## 1. JSON 訊息範例

* [訊息範例請參考支援的訊息格式](/jiao-xue-fan-li/ru-he-shi-yong-json-xun-xi/zhi-yuan-de-xun-xi-ge-shi)

## 2. 用戶識別資料

BotBonnie 會在 Request POST body 自動帶入**用戶識別資料**，可搭配[帳號串接](/jiao-xue-fan-li/zhang-hao-bang-ding)使用。

| 參數名稱                                                     | 類型      | 描述                              |
| -------------------------------------------------------- | ------- | ------------------------------- |
| **bot\_id**                                              | String  | 機器人的 ID                         |
| <p><strong>bot\_uid</strong></p><p>(deprecated)</p>      | String  | 用戶 ID (加密)                      |
| **bot\_raw\_uid**                                        | String  | 用戶 ID (未加密)                     |
| **bot\_pid**                                             | String  | 粉絲頁 ID                          |
| **bot\_channel**                                         | Number  | 渠道代號  （`0`：Facebook / `1`：LINE） |
| <p><strong>bot\_isLinked</strong></p><p>(deprecated)</p> | Boolean | 用戶目前是否已經帳號連結 （`true` / `false`） |

## 3. 取得額外資料

當您的 JSON API 需要使用者的相關資料時，可以在 JSON API 網址中加上相關參數，BotBonnie 會在 Request POST body 中將相關的資訊一併傳送至您的伺服器。

```
https://yourdomian.com?fields=user,userParams
```

您可以在 `JSON API URL` 上攜帶額外網址參數來獲取 BotBonnie 提供的額外資訊。 目前支援的網址參數類型如下：

| 參數名稱         | 類型     | 支援的種類                                                     |
| ------------ | ------ | --------------------------------------------------------- |
| **`fields`** | String | `user`: 提供當下的用戶資料 `user_params`: 提供儲存於 BotBonnie 端的自訂用戶參數 |

範例的 Body 如下：

```
{ 
  "bot_id": "bot-xxxxx",
  "bot_uid": "3xxxxxxxxxxxd",
  "bot_raw_uid": "2xxxxxxxxxxxx0",
  "bot_pid": "1234779123812",
  "bot_channel": 0,
  "bot_isLinked": true,
  "user": {
    "id": "3xxxxxxxxxxxd",
    "rawId": "2xxxxxxxxxxxx0",
    "created": 1505360797321,
    "name": "陳邦妮",
    "gender": "female",
    "last_name": "陳",
    "pic": "https://scontent.xx.fbcdn.net/v/t31.0-1/p960x960/1800025_10202073294786135_45024857_o.jpg?oh=85252db7049dbf99de251175d03a6d46&oe=5A604B50",
    "locale": "zh_TW",
    "first_name": "邦妮",
    "timezone": 8 
  },
  "userParams": {
    "input": "你好",
    ...
  }
  ...
}
```

#### user

所有與用戶相關的資訊

| 鍵值           | 數值                                                                                  | 必定存在 |
| ------------ | ----------------------------------------------------------------------------------- | ---- |
| `id`         | <p>BotBonnie 認定之用戶 ID (加密)<br>ex: <code>3e69e881732e38b290e39a28b87403bd</code></p> | o    |
| `rawId`      | <p>BotBonnie 認定之用戶 ID (未加密)<br>ex: <code>2452158751517100</code></p>                | o    |
| `created`    | BotBonnie 建立此用戶的時間，unixtime 以毫秒表示 ex: `1505360797321`                               | o    |
| `name`       | 用戶全名 ex: `陳邦妮`                                                                      |      |
| `last_name`  | 用戶姓氏 ex: `陳`                                                                        |      |
| `first_name` | 用戶名稱 ex: `邦妮`                                                                       |      |
| `gender`     | 用戶性別 `male` or `female`                                                             |      |
| `pic`        | 用戶大頭照網址                                                                             |      |
| `locale`     | 用戶所在地區 ex: `zh_TW`                                                                  |      |
| `timezone`   | 用戶時區 ex: `8`                                                                        |      |

#### userParams

企業儲存於用戶身上額外的參數

| 鍵值      | 數值                | 必定存在 |
| ------- | ----------------- | ---- |
| `input` | 觸發此 JsonAPI 的用戶輸入 |      |

## 4. 來源安全性驗證

BotBonnie 會在 Request Header 帶入 `X-Hub-Signature` 確保來源安全性。

`X-Hub-Signature` 是為了驗證 POST 請求是來自 BotBonnie 伺服器，而不是來自惡意用戶。我們使用 SHA1 將 `API Secret` 與原始請求做雜湊，您可以在您的伺服器做來源驗證。

### 4.1 如何取得 `API Secret` ？

BotBonnie 提供每個 bot 專屬的 `API Secert`。可進入 bot 主控台，點選「設定 > 進階設定」，即可取得此 bot 的 `API Secert`。

### 4.2 如何驗證 `X-Hub-Signature` ？

假設您有一個基本的伺服器監聽 webhooks 。

```javascript
var express = require('express')
var bodyParser = require('body-parser')
var crypto = require('crypto')

// Express error-handling middleware function.
// Read more: http://expressjs.com/en/guide/error-handling.html
function abortOnError(err, req, res, next) {
  if (err) {
    console.log(err)
    res.status(400).send({ error: "Invalid signature." })
  } else {
    next()
  }
}

var app = express();
var listener = app.listen(process.env.PORT ? process.env.PORT : 3000)

// body-parser is the first Express middleware.
app.use(bodyParser.json({ verify: verifyRequest }))

// Add an error-handling Express middleware function 
// to prevent returning sensitive information.
app.use(abortOnError)

app.post('/webhook/', function (req, res) {
  res.status(200).send("done!")
})
```

使用 `API Secret` 與原始請求做驗證。

```javascript
// Calculate the X-Hub-Signature header value.
function getSignature(buf) {
  var hmac = crypto.createHmac("sha1", process.env.BOTBONNIE_API_SECRET)
  hmac.update(buf, "utf-8")
  return "sha1=" + hmac.digest("hex")
}

// Verify function compatible with body-parser to retrieve the request payload.
// Read more: https://github.com/expressjs/body-parser#verify
function verifyRequest(req, res, buf, encoding) {
  var expected = req.headers['x-hub-signature']
  var calculated = getSignature(buf)
  console.log("X-Hub-Signature:", expected, "Content:", "-" + buf.toString('utf8') + "-")
  if (expected !== calculated) {
    throw new Error("Invalid signature.")
  } else {
    console.log("Valid signature!")
  }
}
```


# 支援的訊息格式

## 1.1 輪播訊息 Gallery

用於傳送可水平捲動的輪播項目，每個項目都由圖像、簡短說明及按鈕所組成，可搭配快速回覆選單。

For sending a carousel-like message. Each carousel item has an image, short description, and buttons.\
QuickReplies are optional.

```javascript
{
  "type": "gallery",
  "cards": [
    {
      "title": "title1",
      "subtitle": "subtitle1",
      "imageUrl": "https://i.imgur.com/hAGm4iF.jpg"
    },
    {
      "title": "title2",
      "subtitle": "subtitle2",
      "imageUrl": "https://i.imgur.com/hAGm4iF.jpg",
      "buttons": [
        {
          "title": "btn1",
          "type": "postback",
          "value": "module-ry49xXQU2"
        },
        {
          "title": "btn2",
          "type": "web_url",
          "value": "http://google.com"
        }
      ]
    }
  ],
  "quickReplies": [
    {
      "payload": "module-HkI2FKv84e",
      "title": "know more about Bonnie",
      "type": "text"
    }
  ]
}
```

## 1.2 圖像訊息 Image

由單張圖像組成，支援的格式為 jpg、png 和 gif，可搭配快速回覆選單。（不支援按鈕）

Single image message. (buttons are not supported)

Image format: jpg, png, gif

QuickReplies are optional.

```javascript
{
  "type": "image",
  "imageUrl": "https://i.imgur.com/hAGm4iF.jpg",
  "quickReplies": [
    {
      "payload": "module-Sk2zR5LGg",
      "title": "quick reply btn 1",
      "type": "text"
    }
  ]
}
```

## 1.3 文字訊息 Text

由純文字組成，文字長度最多 320 字元，可搭配按鈕或快速回覆選單。

Text message. The max length is 320.

Buttons and QuickReplies are optional

```javascript
{
  "type": "text",
  "text": "文字描述",
  "buttons": [
    {
      "title": "按鈕1",
      "type": "postback",
      "value": "module-ry49xXQU2"
    },
    {
      "title": "按鈕2",
      "type": "web_url",
      "value": "http://google.com"
    }
  ],
  "quickReplies": [
    {
      "title": "快速回覆1",
      "type": "text",
      "payload": "module-SkHJnEqZl"
    },
    {
      "title": "快速回覆2",
      "type": "text",
      "payload": "module-KkHJaEqZl"
    }
  ]
}
```

## 1.4 影片訊息 Video

由影片組成，支援的格式為 mp4，可搭配快速回覆選單。

Video message.

Video format: mp4.

QuickReplies are optional.

```javascript
{
  "type": "video",
  "videoUrl": "https://d1dh985a59yv80.cloudfront.net/video/WK_30s.mp4",
  "quickReplies": [
    {
      "payload": "module-Sk2zR5LGg",
      "title": "快速回覆1",
      "type": "text"
    }
  ]
}
```

## 1.5 語音訊息 Audio

由音訊組成，支援的格式為 mp3，可搭配快速回覆選單。

Audio message.

Audio format: mp3.

QuickReplies are optional.

```javascript
{
  "type": "audio",
  "audioUrl": "https://d1dh985a59yv80.cloudfront.net/audio/sodagreen.mp3",
  "quickReplies": [
    {
      "payload": "module-Sk2zR5LGg",
      "title": "快速回覆1",
      "type": "text"
    }
  ]
}
```

## 1.6 媒體訊息 Media

目前僅支援 Facebook Messenger。 可支援圖片/影片訊息，可以選用一個按鈕與快速回覆。

The Facebook channel only message type.

### Facebook URL

| 媒體種類  | 媒體來源         | URL 格式                                                          |
| ----- | ------------ | --------------------------------------------------------------- |
| Video | Facebook 粉絲頁 | `https://business.facebook.com/<PAGE_NAME>/videos/<NUMERIC_ID>` |
| Video | Facebook 帳號  | `https://www.facebook.com/<USERNAME>/videos/<NUMERIC_ID>/`      |
| Image | Facebook 粉絲頁 | `https://business.facebook.com/<PAGE_NAME>/photos/<NUMERIC_ID>` |
| Image | Facebook 帳號  | `https://www.facebook.com/photo.php?fbid=<NUMERIC_ID>`          |

```javascript
{
  "type": "media",
  "mediaType": "<image|video>",
  "url": "<FACEBOOK_URL>",
  "buttons": [
    {
      "title": "唯一的按鈕",
      "type": "postback",
      "value": "module-ry49xXQU2"
    }
  ]
}
```


# 如何取得 API Token？

當需要從您的伺服器呼叫 BotBonnie 的 API 時，必須帶著 BotBonnie 提供的 `API Token` 做來源安全性驗證，此 API 才會生效。

## 如何取得 API Token？

BotBonnie 提供每個 bot 專屬的 `API Token`。可進入 bot 主控台，點選「機器人設定 > 進階設定」，即可取得此 bot 的 `API Token`。

![](https://3594967572-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-L9ym4NSFsLE0fxemOot%2F-M2Bz7GWf38dnhCXKBEp%2F-M2BzN5WrRmeFirg8c9_%2F%E8%9E%A2%E5%B9%95%E5%BF%AB%E7%85%A7%202020-03-12%20%E4%B8%8B%E5%8D%8812.25.16.png?alt=media\&token=b8bd12d3-2a15-4ac4-a711-8c86756556d3)


# Changelog

API 文件相關編修紀錄

## v2.26.4

### 新增：

1. 查詢 / 新增 / 刪除 用戶標籤
2. 用戶參數
3. 帳號綁定內容

### 修正：

* &#x20;更新 API Token 截圖


