Coder Social home page Coder Social logo

zdeskr's Introduction

zdeskR

Connect to your Zendesk data with R!

Purpose

zdeskR facilitates making a connection to the Zendesk API and executing various queries. You can use it to get tickets and ticket metrics in the form of data frames.

Installation

The development version can be installed from GitHub: devtools::install_github("chrisumphlett/zdeskR").

Usage

The API uses Zendesk email id and the token associated with it to make queries. Once you have this parameters then we create a username and password:

username <- paste0(email_id, "/token")

password <- token

This username and password will be used in every API call along with a function specific URL to fetch the data.

The current version has several functions to make requests to the API

  • get_tickets(). Returns all the tickets of your Zendesk organization after a given start time.
  • get_all_tickets_metrics(). Returns all the ticket metrics in your Zendesk organization. Zendesk does not have an incremental version of this API endpoint; you cannot get the data starting after a certain date as of August 2020.
  • get_users(). Returns all the users registered in your Zendesk organization.
  • get_custom_fields(). Returns all the system and custom fields available for the tickets in your Zendesk organization.

Using get_custom_fields() along with get_tickets()

get_tickets() returns a data frame that contains the names of system fields and ids of custom fields which adds up an additional task to map those ids with their respective names. One way to do that is to manually create a dictionary having 'id' as keys and 'names' as values, but this approach becomes cumbersome when the size of dictionary increases. An alternative to this approach is to use get_tickets() which returns a data frame containing system and all the custom field names. Here is a code snippet that you can use for reference

# Fetch respective data frames
tickets <- get_tickets(email_id = email_id, token = token, subdomain = subdomain, start_time = start_time)
fields <- get_custom_fields(email_id = email_id,token = token,subdomain = subdomain)
# Create a data frame that contains only 'id' and 'title' columns
fields_reduced <- fields%>%
                    select(2,4)
# Remove the system fields from the data frame
sys_list <- c('a','b','c') # Assuming that these are the only system fields in fields_reduced
cust_fields <- fields_reduced[!fields_reduced$title %in% sys_list,]
# Pivoting the custom field dataframe
cust_fields_piv <- cust_fields%>%
           pivot_wider(names_from = .data$id, values_from = .data$title)
# Keep common column names , this will keep only the custom field ids
common_col <- intersect(names(tickets),names(cust_fields_piv))
# Change names in tickets data frame using the list of column names in common_col
names(tickets)[names(tickets) %in% common_col] = cust_fields_piv[common_col]

zdeskr's People

Contributors

avirichie avatar chrisumphlett avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.