Woodshop for old agent generation
Try the new agent generation
  • What is woodshop
  • How to's
    • Smart Relationship
      • GetIdsFromRequest
    • Smart views
      • Display a calendar view
      • Create a custom tinder-like validation view
      • Create a custom moderation view
      • Create a dynamic calendar view for an event-booking use case
    • Configure environment variables
      • NodeJS/Express projects
    • Elasticsearch Integration
      • Interact with your Elasticsearch data
      • Elasticsearch service/utils
      • Another example
    • Zendesk Integration
      • Authentication, Filtering & Sorting
      • Display Zendesk tickets
      • Display Zendesk users
      • View tickets related to a user
      • Bonus: Direct link to Zendesk + change priority of a ticket
    • Dwolla integration
      • Display Dwolla customers
      • Display Dwolla funding sources
      • Display Dwolla transfers
      • Link users and Dwolla customers
      • Dwolla service
    • Make filters case insensitive
    • Use Azure Table Storage
    • Create multiple line charts
    • Create Charts with AWS Redshift
    • View soft-deleted records
    • Send Smart Action notifications to Slack
    • Authenticate a Forest Admin API against an OAuth protected API Backend
    • Translate your project into TypeScript
      • V8
        • Migrate Mongoose files
        • Migrate Sequelize files
      • v7
        • Migrate Mongoose files
        • Migrate Sequelize files
      • v6
    • Geocode an address with Algolia
    • Display/edit a nested document
    • Send an SMS with Zapier
    • Hash a password with bcrypt
    • Display a customized response
    • Search on a smart field with two joints
    • Override the count route
    • Make a field readOnly with Sequelize
    • Hubspot integration
      • Create a Hubspot company
      • Display Hubspot companies
    • Impersonate a user
    • Import data from a CSV file
    • Import data from a JSON file
    • Load smart fields using hook
    • Pre-fill a form with data from a relationship
    • Re-use a smart field logic
    • Link to record info in a smart view
    • Display data in html format
    • Upload files to AWS S3
    • Display AWS S3 files from signed URLs
    • Prevent record update
    • Display, search and update attributes from a JSON field
    • Add many existing records at the same time (hasMany-belongsTo relationship)
    • Track users’ logs with morgan
    • Search on relationship fields by default
    • Export related data as CSV
    • Run automated tests
  • Forest Admin Documentation
Powered by GitBook
On this page
  • Declare the Smart Collection Zendesk Users
  • Implement the Smart Collection route
  • Implement the get Route

Was this helpful?

  1. How to's
  2. Zendesk Integration

Display Zendesk users

PreviousDisplay Zendesk ticketsNextView tickets related to a user

Last updated 4 years ago

Was this helpful?

This section shows you how to create a smart collection to list the users of your Zendesk account.

Declare the Smart Collection Zendesk Users

Zendesk API allows to access different data:

  • and

First, we need to declare the smart collection in your project based on the API documentation. As an example, here the smart collection definition for Users:

forest/zendesk-users.js
const { collection } = require('forest-express-sequelize');

// Search on users => https://support.zendesk.com/hc/en-us/articles/203663216-Searching-users-groups-and-organizations#topic_duj_sbb_vc
collection('zendesk_users', {
  isSearchable: true,
  actions: [],
  fields: [{
    field: 'id',
    type: 'String',
    isFilterable: false, // Zendesk API does not provide such capacity with the API
  }, {
    field: 'name',
    type: 'String',
    isFilterable: true,
  }, {
    field: 'alias',
    type: 'String',
  }, {
    field: 'email',
    type: 'String',
    isFilterable: true,
  }, {
    field: 'role',
    type: 'Enum',
    enums: ['end-user', 'agent', 'admin'],
    isFilterable: true,
  }, {
    field: 'role_type',
    type: 'Number',
  }, {
    field: 'phone',
    type: 'String',
    isFilterable: true,
  }, {
    field: 'whatsapp',
    type: 'String',
    isFilterable: true,
  }, {
    field: 'last_login_at',
    type: 'Date',
  }, {
    field: 'verified',
    type: 'Boolean',
  }, {
    field: 'active',
    type: 'Boolean',
  }, {
    field: 'suspended',
    type: 'Boolean',
    isFilterable: true,
  }, {
    field: 'created_at',
    type: 'Date',
    isSortable: true,
  }, {
    field: 'updated_at',
    type: 'Date',
    isSortable: true,
  }, {
    field: 'last_login_at',
    type: 'Date',
  }, {
    field: 'notes',
    type: 'String',
    isFilterable: true,
  }, {
    field: 'details',
    type: 'String',
    isFilterable: true,
  }, {
    field: 'tags',
    type: ['String'],
    isFilterable: true,// is it possible? => no arrays are not yet filterable
  }, {
    field: 'time_zone',
    type: 'String',
  }, {
    field: 'moderator',
    type: 'Boolean',
  }, {
    field: 'external_id',
    type: 'String',
    isFilterable: true,
  }, {
    field: 'only_private_comments',
    type: 'Boolean',
  }, {
    field: 'photo_url',
    type: 'File',
    get: (user) => {
      return user.photo ? user.photo.content_url : null;
    }
  }, ],
  segments: [],
});

Some fields are available for filtering or sorting using the Zendesk API. To allow this on the Forest UI, simply add the keywords isFilterable and isSortable in your field definition.

Implement the Smart Collection route

In the file routes/zendesk-users.js, we’ve created a new route to implement the API behind the Smart Collection.

The logic here is to list all the users of your Zendesk account.

routes/zendesk-users.js
const express = require('express');
const { PermissionMiddlewareCreator } = require('forest-express-sequelize');

const router = express.Router();
const permissionMiddlewareCreator = new PermissionMiddlewareCreator('zendesk_tickets');

const {getUsers} = require('../services/zendesk-users-service');

// Get a list of Zendesk Users
router.get('/zendesk_users', permissionMiddlewareCreator.list(), (request, response, next) => {
  getUsers(request, response, next);
});

Implement the get Route

The section above help you display the list of all Zendesk users. But you'll need to implement also the logic to display the information of a specific user.

We just need to implement a new endpoint to get an individual user from the Zendesk API.

services/zendesk-users-services.js
async function getUser(request, response, next) {
  return axios.get(`${ZENDESK_URL_PREFIX}/api/v2/users/${request.params.userId}?include=comment_count`, {
    headers: {
      'Authorization': `Basic ${getToken()}` 
    },
  })
  .then( async (resp) => {
    let record = resp.data.user;
    // Serialize the result using the Forest Admin format
    const recordSerializer = new RecordSerializer({ name: 'zendesk_users' });
    const recordSerialized = await recordSerializer.serialize(record);
    response.send(recordSerialized);      
  })
  .catch(next);  
  
}
routes/zendesk-users.js

const {getUsers, getUser} = require('../services/zendesk-tickets-service');

// Get a Zendesk Ticket
router.get('/zendesk_users/:userId', permissionMiddlewareCreator.details(), (request, response, next) => {
  getUser(request, response, next);
});

Learn more about how to .

Find more information about getUsers variable definition in .

Users
Tickets & Comments
Organizations
Groups
authenticate, filter and sort with the Zendesk API
the Github repository