Wednesday 8 September 2021

Utilities untuk Zendesk

 Export Tickets

Jika berlangganan paket Suite Team, maka kita tidak akan mendapat akses ke fungsionalitas Report untuk mengexport data ticket-ticket yang masuk. Jika menggunakan custom view, yg bisa diexport hanya 2000 tiket. 

Ada beberapa solusi menggunakan API yg telah dibuat oleh komunitas. Dintaranya timpalac/zendeskexport [1], kelemahannya, hanya bisa meng-export maksimal 1000 tiket dalam satu requeat. 

Zenpy pun menawarkan solusi, salah satu nya adalah yg telah ditulis oleh Paul [2][3], tapi sepertinya API nya sudah kadaluarsa (?). Setelah mencoba memodifikasi script diatas, Alhamdulillah, akhirnya bisa menarik data tiket Zendesk : 

credentials = {
'email' : 'email',
'token' : 'token',
'subdomain': 'subdomain'
}

# Import the Zenpy Class
from zenpy import Zenpy
from django.utils import timezone
import requests
import pandas as pd
import datetime as dt
import json
import time

zenpy_client = Zenpy(**credentials)

def export_data(start_date = dt.datetime(2020, 1, 1, tzinfo=timezone.utc)):

tickets_json = '['
tickets_df = pd.DataFrame()
org_df = pd.DataFrame()
users_df = pd.DataFrame()
df_tickets = pd.DataFrame(columns=['id', 'requester_id', 'submitter_id',
'created_at', 'subject', 'description',
'tags', 'channel', 'status'])

result_generator = zenpy_client.tickets.incremental(start_time=start_date, include=['users','organizations','groups'])
for ticket in result_generator:
ticket = ticket.to_dict()
row = {
'id': ticket['id'],
'requester_id': ticket['requester_id'],
'submitter_id': ticket['submitter_id'],
'created_at': ticket['created_at'],
'subject': ticket['subject'],
'description': ticket['description'],
'tags': ticket['tags'],
'channel': ticket['via']['channel'],
'status': ticket['status'],
}

df_tickets = df_tickets.append(row, ignore_index=True)

print(str(len(df_tickets)) +" Tickets Imported")



df_tickets.to_csv('tickets_export_20200101_20210908.csv')


export_data()



Dari ekosistem Pentaho, ada yang menawarkan plugin untuk Zendesk [4], tapi ketika mencoba untuk dibuild, masih error : 

[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< org.pentaho.pdi:pdi-zendesk-plugin >-----------------
[INFO] Building PDI Zendesk Plugin 1.3.2-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.149 s
[INFO] Finished at: 2021-09-08T20:07:24+07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.pentaho.maven.plugins:license-helper-maven-plugin:1.26 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.pentaho.maven.plugins:license-helper-maven-plugin:jar:1.26: Could not transfer artifact org.pentaho.maven.plugins:license-helper-maven-plugin:pom:1.26 from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [pentaho-public (http://nexus.pentaho.org/content/groups/omni/, default, releases+snapshots)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

Referensi

  1. ZenDesk Export, https://github.com/timpalac/zendeskexport
  2. Zenpy, https://github.com/facetoe/zenpy
  3. How to Export all Tickets from Zendesk using the API and Python, https://www.pauldesalvo.com/how-to-export-all-tickets-from-zendesk-using-the-api-and-python/
  4. Zendesk Plugin for PDI, https://github.com/matthewtckr/pdi-zendesk-plugin

No comments:

Post a Comment