# 用戶推播

## 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.md)。
* 模組訊息：請在 `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.md) ？

**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.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.botbonnie.com/jiao-xue-fan-li/yong-hu-tui-bo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
