Prerequisites
- Basic knowledge of Arm Treasure Data
- Zendesk account
Use the TD Console to create your connection
Create a new connection
Go to Integrations Hub > Catalog and search and select Zendesk.

Click Create. You are creating an authenticated connection.
The following dialog opens.

There are three options for Auth method: basic, token, oauth.
Fill in all the required fields, the click Continue.
Name your new Zendesk connection. Click Done.
Transfer your data to Treasure Data
After creating the authenticated connection, you are automatically taken to the Authentications tab. Look for the connection you created and click New Source.

Source: specify the kind of object that you want to transfer from Zendesk: tickets, ticket_fields, ticket_forms, ticket_events, ticket_metrics, users, organizations, scores, recipients, object_records, relationship_records, user_events.
- object_records and relationship_records provide information about Zendesk custom objects
- scores and recipients provide information about Zendesk NPS
Incremental: allows the connector to run in incremental mode, which enables Start time and End time can be used.
Start time: enables you to select only objects, which have been updated since the 'start_time'
- If Start time is not specified, all the objects are retrieved from the beginning.
End time: enables you to select only objects, which have been updated up to the 'end_time'.
- If End time is not specified, all the objects up to now are retrieved.
-
Start time and End time can combined to select only objects that have been updated within a specific period, from 'start_time' until 'end_time'
Preview your data. To make changes, click Advanced Settings, otherwise click Next. 
Advanced Setting:

Include Subresources: enables you to fetch sub-resource along with the main object. Click Add to add more sub resource by name and Add a correspondence column as well. The sub resource is considered as an JSON object, presented in a column, with the same name .
For example:
- In Zendesk, this endpoint is supported: GET /api/v2/users/{user_id}/organizations.json That means we can consider organizations as a sub-resource of users. We can get all the information of organizations that a users belong to.
- To configure it, you must add 'organizations' as a sub-resource and also add one more column with the same name. The data type should be JSON.
De-duplicated Records: enables you to avoid duplicated records when running in incremental mode because the Zendesk API doesn't prevent duplication.
Retry Limit: indicates how many times the job should retry when error occurs.
Initial retry interval seconds: indicates the first waiting time before a retry. Measured in seconds.
Select a database and a table where you want to transfer your data:

Specify the schedule of the data transfer using the following dialog and click Next:

Name your source and click Done:

Use Command Line
Install ‘td’ command
Install the newest Treasure Data Toolbelt.
Create Seed Config File (seed.yml)
Prepare seed.yml as shown in the following example, with your login_url, username (email), token and, target. In this example, you use “append” mode:
in: type: zendesk login_url: https://<YOUR_DOMAIN_NAME>.zendesk.com auth_method: token username: <YOUR_EMAIL_ADDRESS> token: <YOUR_API_TOKEN> target: tickets start_time: "2007-01-01 00:00:00+0000" out: mode: append
token can be created by going to Admin Home –> CHANNELS –> API –> "add new token" (https://<YOUR_DOMAIN_NAME>.zendesk.com/agent/admin/api).
target specifies the type of object that you want to dump from Zendesk. tickets, ticket_events, ticket_forms, ticket_fields, users, organizations, scores, recipients, object_records, relationship_records and user_events are supported.
For more details on available out modes, see Appendix.
Guess Fields (Generate load.yml)
Use connector:guess. This command automatically reads the target data, and intelligently guesses the data format.
$ td connector:guess seed.yml -o load.yml
If you open the load.yml file, you see guessed file format definitions including, in some cases, file formats, encodings, column names, and types.
---
in:
type: zendesk
login_url: https://<YOUR_DOMAIN_NAME>.zendesk.com
auth_method: token
username: <YOUR_EMAIL_ADDRESS>
token: <YOUR_API_TOKEN>
target: tickets
start_time: '2019-05-15T00:00:00+00:00'
columns:
- {name: url, type: string}
- {name: id, type: long}
- {name: external_id, type: string}
- {name: via, type: json}
- {name: created_at, type: timestamp, format: "%Y-%m-%dT%H:%M:%S%z"}
- {name: updated_at, type: timestamp, format: "%Y-%m-%dT%H:%M:%S%z"}
- {name: type, type: string}
- {name: subject, type: string}
- {name: raw_subject, type: string}
- {name: description, type: string}
- {name: priority, type: string}
- {name: status, type: string}
- {name: recipient, type: string}
- {name: requester_id, type: string}
- {name: submitter_id, type: string}
- {name: assignee_id, type: string}
- {name: organization_id, type: string}
- {name: group_id, type: string}
- {name: collaborator_ids, type: json}
- {name: follower_ids, type: json}
- {name: email_cc_ids, type: json}
- {name: forum_topic_id, type: string}
- {name: problem_id, type: string}
- {name: has_incidents, type: boolean}
- {name: is_public, type: boolean}
- {name: due_at, type: string}
- {name: tags, type: json}
- {name: custom_fields, type: json}
- {name: satisfaction_rating, type: json}
- {name: sharing_agreement_ids, type: json}
- {name: fields, type: json}
- {name: followup_ids, type: json}
- {name: ticket_form_id, type: string}
- {name: brand_id, type: string}
- {name: satisfaction_probability, type: string}
- {name: allow_channelback, type: boolean}
- {name: allow_attachments, type: boolean}
- {name: generated_timestamp, type: long}
out: {mode: append}
exec: {}
filters:
- from_value: {mode: upload_time}
to_column: {name: time}
type: add_time
Then you can preview how the system parses the file by using preview command.
$ td connector:preview load.yml
If the system detects your column name or type unexpectedly, modify the load.yml directly and preview again.
| The Data Connector supports parsing of "boolean", "long", "double", "string", and "timestamp" types. |
Execute Load Job
Submit the load job. It may take a couple of hours depending on the data size. Users need to specify the database and table where their data is stored.
$ td connector:issue load.yml --database td_sample_db --table td_sample_table
The preceding command assumes that you have already created database(td_sample_db) and table(td_sample_table). If the database or the table do not exist in TD this command will not succeed, so create the database and table manually or use --auto-create-table option with td connector:issue command to automatically create the database and table:
$ td connector:issue load.yml --database td_sample_db --table td_sample_table --time-column created_at --auto-create-table
| You can assign Time Format column to the "Partitioning Key" by "--time-column" option. |
Incremental Load
You can load records incrementally from Zendesk by using the incremental flag. If False, the start_time and end_time in next.yml is not updated. The connector will always fetch all the data from Zendesk with static conditions. If True, the start_time and end_time is updated in next.yml. The default is True.
in: type: zendesk login_url: https://<YOUR_DOMAIN_NAME>.zendesk.com auth_method: token username: <YOUR_EMAIL_ADDRESS> token: <YOUR_API_TOKEN> target: tickets start_time: "2007-01-01 00:00:00+0000"
end_time: "2008-01-01 00:00:00+0000" incremental: true out: mode: append
Scheduled execution
You can schedule periodic data connector execution for periodic Zendesk import. We carefully configure our scheduler to ensure high availability. By using this feature, you no longer need a cron daemon on your local data center.
Create the schedule
A new schedule can be created by using the td connector:create command. The name of the schedule, cron-style schedule, the database and table where their data is stored, and the data connector configuration file are required.
$ td connector:create \
daily_zendesk_import \
"10 0 * * *" \
td_sample_db \
td_sample_table \
load.yml
| The `cron` parameter also accepts three special options: `@hourly`, `@daily` and `@monthly`. |
| By default, schedule is setup in UTC timezone. You can set the schedule in a timezone using -t or --timezone option. Please note that `--timezone` option only supports extended timezone formats like 'Asia/Tokyo', 'America/Los_Angeles' etc. Timezone abbreviations like PST, CST are *not* supported and may lead to unexpected schedules. |
List the Schedules
You can see the list of scheduled entries by td connector:list.
$ td connector:list
+----------------------+--------------+----------+-------+--------------+-----------------+--------------------------+
| Name | Cron | Timezone | Delay | Database | Table | Config |
+----------------------+--------------+----------+-------+--------------+-----------------+--------------------------+
| daily_zendesk_import | 10 0 * * * | UTC | 0 | td_sample_db | td_sample_table | {"type"=>"zendes", ... } |
+----------------------+--------------+----------+-------+--------------+-----------------+--------------------------+
Show the Setting and History of Schedules
td connector:show shows the execution setting of a schedule entry.
% td connector:show daily_zendesk_import Name : daily_zendesk_import Cron : 10 0 * * * Timezone : UTC Delay : 0 Database : td_sample_db Table : td_sample_table Config --- // Displayed load.yml configuration.
td connector:history shows the execution history of a schedule entry. To investigate the results of each individual execution, use td job <jobid>.
% td connector:history daily_zendesk_import +--------+---------+---------+--------------+-----------------+----------+---------------------------+----------+ | JobID | Status | Records | Database | Table | Priority | Started | Duration | +--------+---------+---------+--------------+-----------------+----------+---------------------------+----------+ | 578066 | success | 10000 | td_sample_db | td_sample_table | 0 | 2015-04-18 00:10:05 +0000 | 160 | | 577968 | success | 10000 | td_sample_db | td_sample_table | 0 | 2015-04-17 00:10:07 +0000 | 161 | | 577914 | success | 10000 | td_sample_db | td_sample_table | 0 | 2015-04-16 00:10:03 +0000 | 152 | | 577872 | success | 10000 | td_sample_db | td_sample_table | 0 | 2015-04-15 00:10:04 +0000 | 163 | | 577810 | success | 10000 | td_sample_db | td_sample_table | 0 | 2015-04-14 00:10:04 +0000 | 164 | | 577766 | success | 10000 | td_sample_db | td_sample_table | 0 | 2015-04-13 00:10:04 +0000 | 155 | | 577710 | success | 10000 | td_sample_db | td_sample_table | 0 | 2015-04-12 00:10:05 +0000 | 156 | | 577610 | success | 10000 | td_sample_db | td_sample_table | 0 | 2015-04-11 00:10:04 +0000 | 157 | +--------+---------+---------+--------------+-----------------+----------+---------------------------+----------+ 8 rows in set
Delete the Schedule
td connector:delete removes the schedule.
$ td connector:delete daily_zendesk_import
Appendix
Modes for out plugin
You can specify file import mode in out section of seed.yml.
append (default)
This is the default mode and records are appended to the target table.
in: ... out: mode: append
replace (In td 0.11.10 and later)
This mode replaces data in the target table. Any manual schema changes made to the target table remain intact with this mode.
in: ... out: mode: replace
Include sub resources
You can specify includes option to get related objects.
For example, if you want to get tickets data with comments, use a configuration as follows:.
in: type: zendesk target: tickets includes: - comments ... out: mode: replace
Further Information
Comments
0 comments
Please sign in to leave a comment.