# Webhook 集成示例

使用 Webhook，您可以与几乎任何其他服务共享客户旅程 (Customer Journey) 数据：分析工具、CRM 系统、营销自动化服务等等。例如，当客户在旅程中采取特定操作时自动通知外部服务，将客户数据发送到您的分析工具，以及在特定的旅程内事件上触发第三方电子邮件、SMS 或 WhatsApp 消息——有无数的用例，选择适合您的那一个。[了解有关 Customer Journey 中 Webhook 元素的更多信息](/zh/product/customer-journey/journey-elements#webhook)

本文展示了如何为不同的用例和服务实现 Webhook。

## Mixpanel

### 用例

将旅程中的事件数据发送到 Mixpanel。

### 前提条件

*   Mixpanel 帐户和 Project ID
*   [服务帐户](https://developer.mixpanel.com/reference/authentication#service-accounts)

用于数据采集 API 的 Webhook ([https://developer.mixpanel.com/reference/events](https://developer.mixpanel.com/reference/events))：

### URL 示例

`https://api.mixpanel.com/import?strict=1&project_id=XXXXXXX`

```
Authorization: Basic UHVzaHdvb3NVTTWlrcjROZUE=
Content-Type: application/json
```

### 数据示例

```
[
  {
    "event": "PW_ApplicationOpen",
    "properties": {
        "time": "{{point:48ae746b-0f54-47db-b96c-1f082e110ff4;event:PW_ApplicationOpen;attribute:datetime}}",
        "distinct_id": "{{device:hwid}}",
        "$insert_id": "48ae746b-0f54-47db-b96c-1f082e110ff4",
        "device_type": "{{point:48ae746b-0f54-47db-b96c-1f082e110ff4;event:PW_ApplicationOpen;attribute:device_type}}",
        "application_version": "{{point:48ae746b-0f54-47db-b96c-1f082e110ff4;event:PW_ApplicationOpen;attribute:application_version}}",
        "timezone": "{{tag:Timezone}}",
        "name": "{{tag:Name}}"
    }
  }
]
```

## Amplitude

### 用例

将旅程中的事件数据发送到 Amplitude。

### 前提条件

*   Amplitude 帐户

用于数据采集 API 的 Webhook ([https://developers.amplitude.com/docs/http-api-v2#request-format](https://developers.amplitude.com/docs/http-api-v2#request-format))：

### URL

`https://api.amplitude.com/2/httpapi`

```
Accept: */*Content-Type: application/json
```

### 数据示例

```
{
  "api_key": "c506ffde6db9xxxxxxa50120e22ec5",
  "events": [
    {
      "user_id": "{{device:user_id}}",
      "device_id": "{{device:hwid}}",
      "event_type": "PW_ApplicationOpen",
      "user_properties": {"timezone": "{{tag:Timezone}}", "sdk_version": "{{tag:SDK Version}}"},
      "country": "{{tag:Country}}"
    }
  ]
}
```

## Slack

### 用例

从旅程中触发 Slack 消息。

### 前提条件

*   Slack 帐户

### URL 示例

`https://pushwoosh.slack.com/apps/XXXXXXXX-incoming-webhooks`

```
Content-Type: application/json
```

### 数据示例

```json
{
"text": "Hi there :smile:",
"username": "John Doe"
}
```

## Zapier

### 用例

将数据发送到 Zapier，这些数据可以在 Zapier 自动化中用于 4000 多个应用程序。

### 前提条件

*   Zapier 帐户

### URL 示例

`https://hooks.zapier.com/hooks/catch/XXXXXXX/xxxxxxx`

```
Content-Type: application/json
```

### 数据示例

```json
{
  "hwid": "{{device:hwid}}",
  "sdk": "{{tag:SDK Version}}"
}
```

## Twilio (SMS)

### 用例

从旅程中发送 SMS

### 前提条件

*   Twilio 帐户（可访问 TWILIO\_ACCOUNT\_SID 和 TWILIO\_AUTH\_TOKEN）
*   已购买电话号码

### URL 示例

`https://api.twilio.com/2010-04-01/Accounts/\$TWILIO_ACCOUNT_SID/Messages.json`

```text
Content-Type: application/x-www-form-urlencoded
Authorization: Basic.... // 使用 https://www.blitter.se/utils/basic-authentication-header-generator/ 对 TWILIO_ACCOUNT_SID 和 TWILIO_AUTH_TOKEN 进行编码以获取 Authenticate 值
```

### 数据示例

```text
From=%2B18646511557&To=%2B15852826356&Body=...
```