DoSomething Zendesk - DoSomething/legacy-website GitHub Wiki

DoSomething Zendesk

A module to interact with the Zendesk PHP API Client Library: https://github.com/zendesk/zendesk_api_client_php

Installation

The repository https://github.com/zendesk/zendesk_api_client_php should be cloned into the Drupal libraries directory with directory name "zendesk".

Within the libraries/zendesk directory, run composer install (Need Composer installed locally to do this) to install the Zendesk PHP API library. This will generate a vendor/autoload.php file, which dosomething_zendesk_libraries_info references to load the Zendesk PHP API Client Library.

Ticket creation

The dosomething_zendesk_form provides a form to create a new Zendesk ticket, setting the ticket requester as the authenticated user. If an anonymous user is viewing the form, the form will prompt for email.

A Zendesk ticket must be associated with a Zendesk user. The function dosomething_zendesk_verify_zendesk_user checks to see if a Zendesk User exists for the email (either inputted or belonging to the global $user), and creates a Zendesk User if one does not exist (see dosomething_zendesk_create_zendesk_user). The Zendesk User is then stored in the ticket object to be submitted to the API.

The dosomething_zendesk_form accepts a Node object as a parameter, which can be used to set other Ticket properties.

A Drupal variable may be stored for the Node the form is being rendered on, to specify a specific Zendesk Group ID to assign the Ticket to: dosomething_zendesk_get_group_varname.

If the variable does not exist, the dosomething_zendesk_form function will check to see if the given Node has been assigned a Primary Cause term. Each Primary Cause term has a Drupal variable for a corresponding Zendesk Group ID to create the ticket for. If one exists, the Ticket will be assigned to this Group.

If the given Node is a staff pick, the Ticket will be assigned high priority. Otherwise, it is not assigned a priority.