# Zendesk Export Integration

Zendesk® Sunshineのモダンなクラウドベースの CRM プラットフォームは、顧客のニーズやトレンドを特定するために使用されます。Zendesk Export Integration コネクタを使用して、Events データを Zendesk Sunshine にエクスポートできます。

## 前提条件

- Treasure Data の基本知識
- Zendesk Sunshine アカウント


## 制限事項

結果の出力スキーマは、ターゲットイベントで要求される列(名前とデータ型)と一致する必要があります。

`profile_identifier` は最大20列まで設定できます(1から20まで連続した昇順で設定)。

| Action | Target | Column required | Column requires at least 1 | Column optional | Note |
|  --- | --- | --- | --- | --- | --- |
| Create | Events for profiles | profile_source(String), profile_type(String), event_source(String), event_type(String), event_properties(JSON String) | profile_identifier_1 to profile_identifier_20 (String) | profile_name, profile_created_at, profile_attributes, event_description, event_created_at, event_received_at | 形式と制限については、以下の「識別子列」を参照してください。 |
| Create | Events for a profile ID | profile_id(String), event_source(String), event_type(String), event_properties(JSON String) |  | event_description, event_created_at, event_received_at | 「Events for a profile ID」の詳細を参照してください。 |
| Create | Events for a user ID | user_id(String), profile_source(String), profile_type(String), event_source(String), event_type(String), event_properties(JSON String) | profile_identifier_1 to profile_identifier_20 (String) | profile_name, profile_created_at, profile_attributes, event_description, event_created_at, event_received_at | 形式と制限については、以下の「識別子列」を参照してください。 |


## 列の詳細

### Events for profiles

**必須列**

- `profile_source (String)`
- `profile_type (String)`
- `event_source (String)`
- `event_type (String)`
- `event_properties (JSON String)` – イベントペイロードのシリアル化されたキーと値のペアを提供します。


**識別子(少なくとも1つ)**

- `profile_identifier_1` から `profile_identifier_20` という名前の最大20列。
- 各値は `type,value` パターンに従う必要があります(例: `email,example@gmail.com`)。


**オプション列**

- `profile_name`
- `profile_created_at`
- `profile_attributes`
- `event_description`
- `event_created_at`
- `event_received_at`


### Events for a profile ID

**必須列**

- `profile_id (String)`
- `event_source (String)`
- `event_type (String)`
- `event_properties (JSON String)`


**オプション列**

- `event_description`
- `event_created_at`
- `event_received_at`


### Events for a user ID

**必須列**

- `user_id (String)`
- `profile_source (String)`
- `profile_type (String)`
- `event_source (String)`
- `event_type (String)`
- `event_properties (JSON String)`


**識別子(少なくとも1つ)**

- 上記と同じ `profile_identifier_1` から `profile_identifier_20` 列および `type,value` ルール。


**オプション列**

- `profile_name`
- `profile_created_at`
- `profile_attributes`
- `event_description`
- `event_created_at`
- `event_received_at`


## Zendesk Sunshine の制限事項

### レート制限

API は標準の作成エンドポイントにレート制限を適用します。制限には、Zendesk Apps フレームワークから行われたリクエストも含まれます。各プランタイプのレート制限は以下の通りです:

|  | Sunshine Lite | Sunshine Professional | Sunshine Enterprise |
|  --- | --- | --- | --- |
| Custom objects | 500 requests per minute | 750 requests per minute | 1,000 requests per minute |
| Profiles | Not included | 250 requests per minute | 500 requests per minute |
| Events | Not included | 250 requests per minute | 500 requests per minute |


### Profiles の制限

次の表は、プロファイルのハード制限を示しています。可用性と制限は Sunshine プランタイプによって異なる場合があります。

| Category | Limit |
|  --- | --- |
| Profiles | 30,000,000 |
| Profile sources | 50 |
| Profile types | 2500 |
| Identifiers per profile | 20 |
| Profile source character length | 40 |
| Profile type character length | 40 |
| Identifier source character length | 60 |
| Identifier type character length | 60 |


### Event の制限

次の表は、イベントのハード制限を示しています。可用性と制限は Sunshine プランタイプによって異なる場合があります。

| Category | Limit |
|  --- | --- |
| Event sources | 50 |
| Event types | 2500 |
| Event source character length | 40 |
| Event type character length | 40 |


## Treasure コンソール を使用して接続を作成する

### 新しい接続を作成する

Treasure Data では、クエリを実行する前に、エクスポート時に使用するデータ接続を作成および設定する必要があります。データ接続の一部として、インテグレーションにアクセスするための認証を提供します。

1. Treasure コンソール を開きます。
2. Integrations Hub > Catalog に移動します。
3. Zendesk を検索して選択します。


![](/assets/image2020-11-20_14-59-51.7917e6aba4f3c541257c8b108035f65cccd06616bee8cacf4f1168cca58471a1.b016e98c.png)

1. **Create** をクリックします。認証済み接続を作成しています。次のダイアログが開きます。


![](/assets/image2020-11-20_15-0-3.0aefdf7dd4c60ce220bb74a33d222c8e4b1bff7b13360de17d55352468d0cf0d.b016e98c.png)

1. イベントデータをエクスポートするには、Zendesk のログイン URL を入力します。例: [https://{your_domain}.zendesk.com](https://boxycharm1597678338.zendesk.com)。
2. **Auth method** には、basic、token、OAuth の異なるオプションがあります。
3. オプションで、基本認証の場合は、username と password の値を入力します。
4. オプションで、token の場合は、username と token の値を入力します。
5. オプションで、OAuth の場合は、OAuth Access Token の値を入力します。
6. **Continue** を選択します。
7. 新しい Zendesk 接続に名前を付けます。
8. **Done** を選択します。


![](/assets/image2020-11-20_15-0-20.6d1a59ebc5c90a71d6773a4aa932bb3d21e98e7b1581e3aa65b29d29b568df12.b016e98c.png)

### データ接続でエクスポート結果を設定する

クエリを作成または再利用します。

場合によっては、クエリで列マッピングを定義する必要があります。

1. Treasure コンソール を開きます。
2. **Data Workbench** > **Queries** に移動します。
3. データのエクスポートに使用する予定のクエリを選択します。各タイプのリソースには**特定の列**と**正確な列名(大文字小文字を区別)**および**データ型**が必要です。データのエクスポートに使用できるコード例:


Events for profiles


```sql
SELECT
 profile_source,
 profile_type,
 profile_identifier_1,
 event_source,
 event_type,
 event_properties
FROM
  your_table;
```

Events for profile ID


```sql
SELECT p
 profile_id,
 event_source,
 event_type,
 event_properties
FROM
 your_table;
```

Events for user id


```sql
SELECT
 user_id,
 profile_source,
 profile_type,
 profile_identifier_1,
 event_source,
 event_type,
 event_properties
FROM
 your_table;
```

1. クエリエディタの上部にある **Export Results** を選択します。Choose Integration ダイアログが開きます。結果をエクスポートする接続を選択する際には、既存の接続を使用するか、新しい接続を作成するかの2つのオプションがあります。これらの手順では、既存の接続を選択することを前提としています。
2. 検索ボックスに接続名を入力してフィルタリングします。
3. 接続を選択します。
4. 次のいずれかを選択します:


![](/assets/image2020-11-20_15-3-54.557766e29ba2c08f1aeef9f046973f09c0f1c596465b72cd60e1098b7822e2cb.b016e98c.png)

1. オプションで、Skip invalid records を選択します。
2. Done を選択します。


### (オプション) Query Export ジョブをスケジュールする

Scheduled Jobs と Result Export を使用して、指定したターゲット宛先に出力結果を定期的に書き込むことができます。

Treasure Data のスケジューラー機能は、高可用性を実現するために定期的なクエリ実行をサポートしています。

2 つの仕様が競合するスケジュール仕様を提供する場合、より頻繁に実行するよう要求する仕様が優先され、もう一方のスケジュール仕様は無視されます。

例えば、cron スケジュールが `'0 0 1 * 1'` の場合、「月の日」の仕様と「週の曜日」が矛盾します。前者の仕様は毎月 1 日の午前 0 時 (00:00) に実行することを要求し、後者の仕様は毎週月曜日の午前 0 時 (00:00) に実行することを要求するためです。後者の仕様が優先されます。

#### Treasure コンソール を使用してジョブをスケジュールする

1. **Data Workbench > Queries** に移動します
2. 新しいクエリを作成するか、既存のクエリを選択します。
3. **Schedule** の横にある None を選択します。
![](/assets/image2021-1-15_17-28-51.f1b242f6ecc7666a0097fdf37edd1682786ec11ef80eff68c66f091bc405c371.0f87d8d4.png)
4. ドロップダウンで、次のスケジュールオプションのいずれかを選択します:
![](/assets/image2021-1-15_17-29-47.45289a1c99256f125f4d887e501e204ed61f02223fde0927af5f425a89ace0c0.0f87d8d4.png)
| ドロップダウン値 | 説明 |
|  --- | --- |
| Custom cron... | [Custom cron... の詳細](#custom-cron-details)を参照してください。 |
| @daily (midnight) | 指定されたタイムゾーンで 1 日 1 回午前 0 時 (00:00 am) に実行します。 |
| @hourly (:00) | 毎時 00 分に実行します。 |
| None | スケジュールなし。 |


#### Custom cron... の詳細

![](/assets/image2021-1-15_17-30-23.0f94a8aa5f75ea03e3fec0c25b0640cd59ee48d1804a83701e5f2372deae466c.0f87d8d4.png)

| **Cron 値** | **説明** |
|  --- | --- |
| `0 * * * *` | 1 時間に 1 回実行します。 |
| `0 0 * * *` | 1 日 1 回午前 0 時に実行します。 |
| `0 0 1 * *` | 毎月 1 日の午前 0 時に 1 回実行します。 |
| "" | スケジュールされた実行時刻のないジョブを作成します。 |



```
 *    *    *    *    *
 -    -    -    -    -
 |    |    |    |    |
 |    |    |    |    +----- day of week (0 - 6) (Sunday=0)
 |    |    |    +---------- month (1 - 12)
 |    |    +--------------- day of month (1 - 31)
 |    +-------------------- hour (0 - 23)
 +------------------------- min (0 - 59)
```

次の名前付きエントリを使用できます:

- Day of Week: sun, mon, tue, wed, thu, fri, sat.
- Month: jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec.


各フィールド間には単一のスペースが必要です。各フィールドの値は、次のもので構成できます:

div
| フィールド値  | 例  | 例の説明  |
|  --- | --- | --- |
| 各フィールドに対して上記で表示された制限内の単一の値。 |  |  |
| フィールドに基づく制限がないことを示すワイルドカード
`'*'`。 | `'0 0 1 * *'` | 毎月 1 日の午前 0 時 (00:00) に実行するようにスケジュールを設定します。 |
| 範囲 `'2-5'`
フィールドの許可される値の範囲を示します。 | `'0 0 1-10 * *'` | 毎月 1 日から 10 日までの午前 0 時 (00:00) に実行するようにスケジュールを設定します。 |
| カンマ区切りの値のリスト `'2,3,4,5'`
フィールドの許可される値のリストを示します。 | `0 0 1,11,21 * *'` | 毎月 1 日、11 日、21 日の午前 0 時 (00:00) に実行するようにスケジュールを設定します。 |
| 周期性インジケータ `'*/5'`
フィールドの有効な値の範囲に基づいて、
スケジュールが実行を許可される頻度を表現します。 | `'30 */2 1 * *'` | 毎月 1 日、00:30 から 2 時間ごとに実行するようにスケジュールを設定します。
`'0 0 */5 * *'` は、毎月 5 日から 5 日ごとに午前 0 時 (00:00) に実行するようにスケジュールを設定します。 |
| `'*'`
ワイルドカードを除く上記の
いずれかのカンマ区切りリストもサポートされています
`'2,*/5,8-10'` | `'0 0 5,*/10,25 * *'` | 毎月 5 日、10 日、20 日、25 日の午前 0 時 (00:00) に実行するようにスケジュールを設定します。 |


1. (オプション) Delay execution を有効にすることで、クエリの開始時刻を遅延させることができます。


### クエリを実行する

クエリに名前を付けて保存して実行するか、単にクエリを実行します。クエリが正常に完了すると、クエリ結果は指定された宛先に自動的にエクスポートされます。

設定エラーにより継続的に失敗するスケジュールジョブは、複数回通知された後、システム側で無効化される場合があります。

(オプション) Delay execution を有効にすることで、クエリの開始時刻を遅延させることができます。

## Audience Studio で Segment をアクティベートする

Audience Studio で activation を作成することで、segment データをターゲットプラットフォームに送信することもできます。

1. **Audience Studio** に移動します。
2. parent segment を選択します。
3. ターゲット segment を開き、右クリックして、**Create Activation** を選択します。
4. **Details** パネルで、Activation 名を入力し、前述の Configuration Parameters のセクションに従って activation を設定します。
5. **Output Mapping** パネルで activation 出力をカスタマイズします。


![](/assets/ouput.b2c7f1d909c4f98ed10f5300df858a4b19f71a3b0834df952f5fb24018a5ea78.8ebdf569.png)

- Attribute Columns
  - **Export All Columns** を選択すると、変更を加えずにすべての列をエクスポートできます。
  - **+ Add Columns** を選択して、エクスポート用の特定の列を追加します。Output Column Name には、Source 列名と同じ名前があらかじめ入力されます。Output Column Name を更新できます。**+ Add Columns** を選択し続けて、activation 出力用の新しい列を追加します。
- String Builder
  - **+ Add string** を選択して、エクスポート用の文字列を作成します。次の値から選択します:
    - String: 任意の値を選択します。テキストを使用してカスタム値を作成します。
    - Timestamp: エクスポートの日時。
    - Segment Id: segment ID 番号。
    - Segment Name: segment 名。
    - Audience Id: parent segment 番号。


1. **Schedule** を設定します。


![](/assets/snippet-output-connector-on-audience-studio-2024-08-28.a99525173709da1eb537f839019fa7876ffae95045154c8f2941b030022f792c.8ebdf569.png)

- スケジュールを定義する値を選択し、オプションでメール通知を含めます。


1. **Create** を選択します。


batch journey の activation を作成する必要がある場合は、[Creating a Batch Journey Activation](/products/customer-data-platform/journey-orchestration/batch/creating-a-batch-journey-activation) を参照してください。

## Workflow でエクスポート結果を設定する(オプション)

ワークフローでデータコネクタを使用してデータをエクスポートする方法の詳細については、[About Using Workflows to Export Data with the TD Toolbelt](/products/customer-data-platform/data-workbench/workflows/exporting-data-with-parameters) を参照してください。

### Events for Profiles のエクスポート例

Basic Auth を使用:


```yaml
timezone: UTC

_export:
  td:
    database: sample_datasets

+td-result-into-target:
  td>: queries/sample.sql
  result_connection: your_connections_name
  result_settings:
    login_url: https://{example}.zendesk.com
    auth_method: basic
    username: {username}
    password: {password}
    target: event_profile
    skip_invalid_records: true
```

Auth Token を使用:


```yaml
timezone: UTC

_export:
  td:
    database: sample_datasets

+td-result-into-target:
  td>: queries/sample.sql
  result_connection: your_connections_name
  result_settings:
    login_url: https://{example}.zendesk.com
    auth_method: token
    username: {username}
    token: {token}
    target: event_profile
    skip_invalid_records: true
```

OAuth Token を使用


```yaml
timezone: UTC

_export:
  td:
    database: sample_datasets

+td-result-into-target:
  td>: queries/sample.sql
  result_connection: your_connections_name
  result_settings:
    login_url: https://{example}.zendesk.com
    auth_method: oauth
    access_token: {access_token}
    target: event_profile
    skip_invalid_records: true
```

### Events for Profile ID のエクスポート例

Basic Auth を使用


```yaml
timezone: UTC

_export:
  td:
    database: sample_datasets

+td-result-into-target:
  td>: queries/sample.sql
  result_connection: your_connections_name
  result_settings:
    login_url: https://{example}.zendesk.com
    auth_method: basic
    username: {username}
    password: {password}
    target: event_profile_id
    skip_invalid_records: true
```

Basic Auth を使用


```yaml
timezone: UTC

_export:
  td:
    database: sample_datasets

+td-result-into-target:
  td>: queries/sample.sql
  result_connection: your_connections_name
  result_settings:
    login_url: https://{example}.zendesk.com
    auth_method: basic
    username: {username}
    password: {password}
    target: event_user_id
    skip_invalid_records: true
```