Avatar

julbrs

1 public val
Joined January 12, 2023

Zoho Desk API

A set of method to easily grab information on Zoho Desk! Official API Documentation is here.

Notes

It's needed to create a Self Client Application as described here to use this val. You also need to find your org id (under Setup > API > Zoho Service Communication (ZSC) Key > OrgId).

Methods

As of today here is the methods in this val:

  • refreshAccessToken to generate a valid Access Token based on client id, client secret and a refresh token. Follow the step here to register a client and generate a refresh token.
  • notAssignedTickets to extract the currently not assigned tickets in a specified department
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import axios from "npm:axios";
export const refreshAccessToken = async (
clientId: string,
clientSecret: string,
refreshToken: string,
): Promise<string> => {
const responseDesk = await axios.post(
`https://accounts.zoho.com/oauth/v2/token`,
{}, // data is empty
{
params: {
client_id: clientId,
client_secret: clientSecret,
refresh_token: refreshToken,
grant_type: "refresh_token",
},
},
);
return responseDesk.data.access_token;
};
type Ticket = any;
export const notAssignedTickets = async (
accessToken: string,
orgId: string,
departmentId: string,
): Promise<{ data: Ticket[] }> => {
const responseDesk = await axios.get(
`https://desk.zoho.com/api/v1/tickets`,
{
params: {
limit: "100",
departmentIds: departmentId,
assignee: "Unassigned",
status: "${ONHOLD},${OPEN}",
},
headers: {
"Authorization": `Zoho-oauthtoken ${accessToken}`,
"orgId": orgId,
},
},
);
if (responseDesk.status === 422) {
// no data, return empty array
return {
data: [],
};
}
return responseDesk.data;
};
Next