Building an application for custom mapping of tickets in Zoho Desk

Building an application for custom mapping of tickets in Zoho Desk

The use case requires building a custom application that can assign tickets to respective departments in Zoho Desk based on the subject line or the content of the body of the email. This can be extended to similar scenarios like:
  • Assigning tickets to agents based on custom criteria
  • Updating status of tickets based on criteria
  • Assigning a case record in CRM to a case owner Solution Diagram
Solution Diagram:

Level 1 : Uploading mappings one-by-one
Level 2 : Upload mappings using a csv
Level 3: Sync department details to Catalyst Data Store

Step 1: Database Schema
The Catalyst Data Store is a relational database that can store the mappings. The first step would be the setting up of the respective tables in the Catalyst Data Store. We'd definitely need a table to set up the OrderID, and department details mapping. Next, we set up the columns for the MappingTable. We've created two columns, OrderID and Team. We'd recommend setting up constraints like unique and mandatory if possible. Every table in the Catalyst Data Store will contain the ROWID, CREEATORID, CREATEDTIME, and MODIFIEDTIME columns by default.
Next, we create a Department table where we store the mapping between the DepartmentID and the DepartmentName. We do this because Desk APIs accept DepartmentID as input whereas the end-user will be typing in Department names.

For more information, please check the attachments.

Step 2: Setting up the functions
Functions perform the compute operation in our project. We will use only the Advanced I/O function to do this. Advanced I/O Functions support Java and Nodejs. We'd need an API to insert into the Mapping table. We assume 'team' would be an ID for simplicity sake.
  1. //Used to insert rows into MappingTable
  2. //Takes a json object body with the keys OrderID, Team
  3. app.post("/row", (req, res) => {

  4.  //initialise catalystApp
  5.     const catalystApp = catalyst.initialize(req);

  6.  //varaibles from json requestBody
  7.  const requestBody = req.body;
  8.  let order_id = requestBody.OrderID;
  9.  let team = requestBody.Team;

  10.  //initialise row data
  11.  let rowData = 
  12.     { 
  13.         OrderID: order_id,
  14.         Team: team
  15.     };
  16.  let datastore = catalystApp.datastore();
  17.     let table = datastore.table('MappingTable');
  18.     let insertPromise = table.insertRow(rowData);
  19.     insertPromise.then((row) => {
  20.             console.log(row);
  21.    res.send({"Message":"Row inserted successfully"})
  22.         }).catch((err) => {
  23.    console.log(err);
  24.    res.status(500).send(err);
  25.   });;
  26. });
Now that we've inserted a mapping, we can use the GET API to get the respective mappings
  1. //Get team name when orderID is provided as input
  2. app.get("/row", async(req, res) => {

  3.     let catalystApp = catalyst.initialize(req, {type: catalyst.type.applogic});

  4.  const requestQuery = req.query;
  5.  let order_id = requestQuery.order_id;

  6.  let select_promise = await select_query(order_id,'SELECT Team FROM MappingTable where OrderID='+order_id+";",catalystApp,res);
  7.  res.send({
  8.   "Message":select_promise
  9.  })

  10. }

Similarly, we'd need a function for assigning the ticket to the Department using the following API.
 
A neat trick is to try this in Postman and switch it to Nodejs code using the code option. Nodejs Connector can be used to generate the access token using the refresh token.

Step 3: Set up the Web Client
 
The Web Client can be built using Angular, React or Simple HTML, CSS and Javascript. We've set up a very simple web client. It's possible to set up better web clients that invoke the REST APIs according to your use case.
Please find attachment

Step 4: Set up the webhook
 
Configure a webhook from Zoho Desk to invoke the API URL according to requirements.
 
This entire solution can be thought of on three levels :
  • First level: adding mappings one at a time
  • Bulk addition of OrderID, Department Mappings
  • CRON function to sync DepartmentID, Departmentname mapping
Feel free to write to us at support@zohocatalyst.com if you have any questions.​






    • Announcements

    • Important Announcements in Support for Catalyst Features

      Hello Catalyst Users, This announcement is to bring to your notice some of the recent updates in our support for various Catalyst components, to ensure that your existing Catalyst applications function properly. You can continue to build robust applications
    • Introducing Catalyst 2.0, the simplest cloud-based pro-code development platform.

      Dear Catalyst Community, We are beyond thrilled to present you Catalyst 2.0—the new-age, pro-code development platform that redefines the way you build, deploy, and scale apps. Catalyst 2.0 is not a mere upgrade, but a significant leap into the future
    • Set budgets to optionally disable your Catalyst production environment

      Hello all,    We are pleased to inform you that you can now configure the automatic disabling of a project's production environment upon reaching a specified budget's threshold. Budget alerts in Catalyst facilitate setting usage limits in amounts or Catalyst
    • #CatalystServerless Hackathon 2022

      We are pleased to announce #CatalystServerless Hackathon with prizes worth $5000 up for grabs. Create a working prototype aimed to solve a critical business issue using Catalyst and stand a chance to win exciting prizes. The Hackathon will happen in 3
    • Share your interest to participate in the #CatalystServerless Blogathon

      Hi, we are working on announcing the next edition of the #CatalystServerless Blogathon. Please fill up this form to stay posted on all updates related to the Blogathon. https://zfrmz.com/JN9ChxPU9JQpPgB1vRp8

      Catalyst Community