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
  • Create a Direct Link to Zendesk
  • Change the priority of a ticket

Was this helpful?

  1. How to's
  2. Zendesk Integration

Bonus: Direct link to Zendesk + change priority of a ticket

PreviousView tickets related to a userNextDwolla integration

Last updated 4 years ago

Was this helpful?

Create a Direct Link to Zendesk

The next step is to build a direct link to the Zendesk Ticket using a URL. We are going to implement a smart field for this. To build the URL, we simply use Zendesk's convention: ZENDESK_URL_PREFIX/agent/tickets/ticketId

forest/zendesk_tickets.js
const ZENDESK_URL_PREFIX = `https://${process.env.ZENDESK_SUBDOMAIN}.zendesk.com`;

collection('zendesk_tickets', {
  actions: [],
  fields: [{
    field: 'direct_url',
    type: 'String',
    get: (ticket) => {
      return `${ZENDESK_URL_PREFIX}/agent/tickets/${ticket.id}`;
    },    
  },
  ...
  ],
  segments: [],
});

Once the smart field is added, just set up the Display Widget in Forest UI to allow the display of the URL as a Link:

Change the priority of a ticket

Let's say your operations team wants to change the priority of Zendesk tickets directly from Forest Admin.

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

const ZENDESK_URL_PREFIX = `https://${process.env.ZENDESK_SUBDOMAIN}.zendesk.com`;

// Search on tickets => https://support.zendesk.com/hc/en-us/articles/203663206-Searching-tickets
collection('zendesk_tickets', {
  actions: [{
    name: 'Change Priority',
    type: 'single',
    endpoint: '/forest/actions/zendesk-ticket-change-priority',
    fields: [
      {
        field: 'New Ticket Priority',
        description: 'What is the new priority?',
        type: 'Enum',
        enums: ['urgent', 'high', 'normal', 'low'],
        isRequired: true
      },
    ],
  }],
  fields: [
    ...
  ],
  segments:[]
}  
services/zendesk-tickets-service.js
async function udpateTicket(ticketId, newValues) {
  const body = {
    ticket: newValues
  };
  return axios.put(`${ZENDESK_URL_PREFIX}/api/v2/tickets/${ticketId}`, 
    body,
    {
      headers: {
        'Authorization': `Basic ${getToken()}` 
      },
    }
  )
  .then( async (resp) => {
    let record = resp.data.ticket;
    return record;
  })
}

And now, we need to implement the route to handle this Smart Action:

routes/zendesk_tickets.js
const {getTickets, getTicket, udpateTicket} = require('../services/zendesk-tickets-service');

router.post('/actions/zendesk-ticket-change-priority', permissionMiddlewareCreator.smartAction(), (request, response, next) => {
  const ticketId = request.body.data.attributes.ids[0];
  const newValues = {
    priority: request.body.data.attributes.values['New Ticket Priority'],
  };

  udpateTicket(ticketId, newValues)
  // eslint-disable-next-line no-unused-vars
  .then(async function (recordUpdated) {
    response.send({
      success: 'Ticket Priority changed!',
    });
  })
  .catch(next);
});
  • Get the Assignee, Submitter & Requester users for a Zendek Ticket

  • Get the Zendesk User for a User

  • Get the requested tickets for a Zendesk User

  • and more...

For doing so, let's create a simple like this:

Implement the updateTicket service according to the :

You now have full integration with Zendesk! To go further, please :

Smart Action
Zendesk API
check our Github repository and explore how to