# 网络回调 (WebHooks)

## Webhook 是什麼？

在網頁應用程式中某項作業完成或特定事件發生時，**能夠即時接收通知的功能**。在 Listly 提取資料後，連動到 Slack 等企業用訊息應用程式，就能在資料提取完成時即時接收通知。

***

## 使用方法

### Slack Webhook 連動

{% hint style="info" %}
**超簡單跟著做**

➡️ 在 Slack 新增 Incoming Message 應用程式 ➡️ 在 Listly 任務新增 Webhook ➡️ 用資料重新提取或排程器在想要的 Slack 頻道接收通知
{% endhint %}

{% stepper %}
{% step %}
**登入 Slack 後，點擊左側邊欄的工作區名稱（範例：Acme Inc.）**

出現 **`工具及設定選單`** 時，點擊 **`應用程式管理設定`** 開啟應用程式目錄。

<figure><img src="https://content.gitbook.com/content/QSPSOmaFPAz7khj6t7Ds/blobs/LPgKH608UsVkykNz8RrJ/Untitled.png" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**在 Slack 應用程式目錄頁面搜尋 'Incoming Webhooks' 或 '接收 Webhook' 並新增到 Slack。**

<figure><img src="https://content.gitbook.com/content/QSPSOmaFPAz7khj6t7Ds/blobs/lkrZfNR38sOYf1Oje1YX/Untitled%201.png" alt=""><figcaption></figcaption></figure>

新增到 Slack 後，選擇要接收通知的頻道。在此步驟可以新增想要接收通知的頻道，也可以設定傳送提取結果訊息的機器人名稱。複製 Listly 服務連動所需的 **`Webhook URL`** 後，點擊儲存設定。

<figure><img src="https://content.gitbook.com/content/QSPSOmaFPAz7khj6t7Ds/blobs/LeKnZKlrVHfYFg6KtENY/Untitled%202.png" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
在 Listly [資料面板](https://www.listly.io/databoard)找到想要接收結果通知的任務，點擊右側的 **`資料`** 按鈕。然後如下圖所示，點擊上方選單右側的 **`Hook`** 按鈕開啟 Webhook 設定視窗。

<figure><img src="https://content.gitbook.com/content/QSPSOmaFPAz7khj6t7Ds/blobs/pNKY7Ai7suAzNYAFdvIc/Untitled%203.png" alt=""><figcaption></figcaption></figure>

看到 Webhook 設定視窗後，請依下列設定填入 Request Method、JSON 值。在 URL 輸入框輸入前一步驟複製的 **`Webhook URL`**。

<figure><img src="https://content.gitbook.com/content/QSPSOmaFPAz7khj6t7Ds/blobs/V3SnpYQpay2cEIUSHIh6/Untitled%204.png" alt=""><figcaption></figcaption></figure>

| Method | POST |
| ------ | ---- |

JSON:

{% code title="payload.json" %}

```json
{ "text": "#taskkey is #status. <[https://www.listly.io/single?key=#taskkey\&tab=4\&card=30\|See](https://www.listly.io/single?key=#taskkey\&tab=4\&card=30%7CSee) result>\nFrom Listly.", "icon_emoji": ":white_check_mark:" }
```

{% endcode %}
{% endstep %}

{% step %}
用重新提取或排程器重新提取該任務的資料，就能如下在 Slack 接收資料提取通知訊息。

<figure><img src="https://content.gitbook.com/content/QSPSOmaFPAz7khj6t7Ds/blobs/GirhUR00YtgtcK7VlU5t/Untitled%205.png" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

### 其他設定

* 如果熟悉 JSON 格式，可以在上面輸入的 JSON 中新增 **`channel: #頻道名稱`** 或 **`user: @使用者名稱`** 來變更接收通知的頻道/使用者。新增 **`username: 機器人名稱`** 也可以變更傳送通知的機器人名稱。
* 如想更詳細了解 Slack Incoming Webhooks，請參考 Slack 提供的文件（<https://api.slack.com/legacy/custom-integrations/messaging/webhooks）。>
