# Zendesk Export Integration CLI

CLI（TD Toolbelt）を使用して、TDからZendesk Sunshineへデータ結果をエクスポートできます。

## 前提条件

- [TD Toolbelt](/tools/cli-and-sdks/td-toolbelt)がインストールされていること。
- Zendesk SunshineとZendeskアカウントの基本的な知識があること。


## 制限事項

クエリは、ターゲットイベントと一致する必須カラム（名前とデータ型）を含む必要があります。

## コマンドラインを使用した接続の作成

CLIを使用して接続を設定できます。

設定キーと説明は以下の通りです:

| **Config Key** | **Type** | **Required** | **Description** |
|  --- | --- | --- | --- |
| type | string | yes | zendesk |
| login_url | string | yes | ZendeskのログインURL |
| auth_method | string | yes | basic、token、またはoauth |
| username | string | yes if auth_method is basic or token | Zendeskのユーザー名 |
| password | string | yes if auth_method is basic | Zendeskのパスワード |
| token | string | yes if auth_method is token | Zendeskのtoken |
| access_token | string | yes if auth_method is oauth | ZendeskのOAuth access token |
| target | string | yes | エクスポート先のZendeskターゲット: event_profile、event_profile_id、またはevent_user_id |
| skip_invalid_records | string | no | 無効なレコードがある場合に続行する |


### 接続とクエリの例

プロファイルのイベントを作成


```bash
td query --database my_db \
         --result '{
            "type": "zendesk",
            "login_url": "https://{example}.zendesk.com",
            "auth_method": "basic",
            "password": "xxxxx",
            "username": "xxxxx",
            "target": "event_profile",
            "skip_invalid_records": false
         }'
         'SELECT profile_source, profile_type, profile_identifier_1,
          event_source, event_type, event_properties
          FROM your_table;'
```

プロファイルIDのイベントを作成


```bash
td query --database my_db \
         --result '{
            "type": "zendesk",
            "login_url": "https://{example}.zendesk.com",
            "auth_method": "basic",
            "password": "xxxxx",
            "username": "xxxxx",
            "target": "event_profile_id",
            "skip_invalid_records": false
         }'
         'SELECT profile_id, event_source, event_type, event_properties
          FROM your_table;'
```

ユーザーIDのイベントを作成


```bash
td query --database my_db \
         --result '{
            "type": "zendesk",
            "login_url": "https://{example}.zendesk.com",
            "auth_method": "basic",
            "password": "xxxxx",
            "username": "xxxxx",
            "target": "event_user_id",
            "skip_invalid_records": false
         }'
         'SELECT user_id, profile_source, profile_type, profile_identifier_1,
          event_source, event_type, event_properties
          FROM your_table;'
```