Skip to content

Commit c52e201

Browse files
sicarius97claude
andcommitted
Fix Zoho Desk search-ticket and add list-tickets with comprehensive props
This commit addresses issue #18798 by adding comprehensive prop definitions to the Zoho Desk integration, enabling AI to properly configure ticket search and listing with all available API parameters. Changes: - Added new propDefinitions to zoho_desk.app.mjs: * ticketPriority: Dynamic options from organization fields * assigneeId: Dynamic options from agents list * channel: Dynamic options from organization fields * ticketSortBy: Static sort options (createdTime, modifiedTime, dueDate, relevance) * from: Pagination offset parameter * limit: Results limit parameter (max 50) - Added streaming methods for better pagination: * getTicketsStream(): Stream paginated ticket lists * searchTicketsStream(): Stream paginated search results - Enhanced search-ticket action (v0.0.7): * Added departmentId filter * Added status filter * Added priority filter * Added assigneeId filter * Added channel filter * Added sortBy parameter * Added from/limit pagination * Added maxResults parameter * Implemented streaming for large result sets - Created new list-tickets action (v0.0.1): * Full filtering by department, status, priority, assignee, channel, contact * Sorting options * Pagination support * Include parameter for related resources * Streaming support for large datasets All changes verified against Zoho Desk API documentation: - Search Tickets: https://desk.zoho.com/DeskAPIDocument#Search_SearchTickets - List Tickets: https://desk.zoho.com/DeskAPIDocument#Tickets_Listalltickets Fixes #18798 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 2c5f4f2 commit c52e201

File tree

3 files changed

+428
-11
lines changed

3 files changed

+428
-11
lines changed
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
import zohoDesk from "../../zoho_desk.app.mjs";
2+
3+
export default {
4+
key: "zoho_desk-list-tickets",
5+
name: "List Tickets",
6+
description: "Lists all tickets in your help desk with optional filtering. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Tickets#Tickets_Listalltickets)",
7+
type: "action",
8+
version: "0.0.1",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
zohoDesk,
16+
orgId: {
17+
propDefinition: [
18+
zohoDesk,
19+
"orgId",
20+
],
21+
},
22+
departmentId: {
23+
propDefinition: [
24+
zohoDesk,
25+
"departmentId",
26+
({ orgId }) => ({
27+
orgId,
28+
}),
29+
],
30+
},
31+
status: {
32+
propDefinition: [
33+
zohoDesk,
34+
"ticketStatus",
35+
],
36+
},
37+
priority: {
38+
propDefinition: [
39+
zohoDesk,
40+
"ticketPriority",
41+
],
42+
},
43+
assigneeId: {
44+
propDefinition: [
45+
zohoDesk,
46+
"assigneeId",
47+
({ orgId }) => ({
48+
orgId,
49+
}),
50+
],
51+
},
52+
channel: {
53+
propDefinition: [
54+
zohoDesk,
55+
"channel",
56+
],
57+
},
58+
contactId: {
59+
propDefinition: [
60+
zohoDesk,
61+
"contactId",
62+
({ orgId }) => ({
63+
orgId,
64+
}),
65+
],
66+
},
67+
sortBy: {
68+
propDefinition: [
69+
zohoDesk,
70+
"ticketSortBy",
71+
],
72+
},
73+
from: {
74+
propDefinition: [
75+
zohoDesk,
76+
"from",
77+
],
78+
},
79+
limit: {
80+
propDefinition: [
81+
zohoDesk,
82+
"limit",
83+
],
84+
},
85+
maxResults: {
86+
propDefinition: [
87+
zohoDesk,
88+
"maxResults",
89+
],
90+
},
91+
include: {
92+
type: "string",
93+
label: "Include",
94+
description: "Additional resources to include in the response (comma-separated). For example: `contacts,products,assignee`",
95+
optional: true,
96+
},
97+
},
98+
async run({ $ }) {
99+
const {
100+
orgId,
101+
departmentId,
102+
status,
103+
priority,
104+
assigneeId,
105+
channel,
106+
contactId,
107+
sortBy,
108+
from,
109+
limit,
110+
maxResults,
111+
include,
112+
} = this;
113+
114+
const params = {};
115+
116+
// Add optional filter parameters
117+
if (departmentId) params.departmentId = departmentId;
118+
if (status) params.status = status;
119+
if (priority) params.priority = priority;
120+
if (assigneeId) params.assignee = assigneeId;
121+
if (channel) params.channel = channel;
122+
if (contactId) params.contactId = contactId;
123+
if (sortBy) params.sortBy = sortBy;
124+
if (from) params.from = from;
125+
if (limit) params.limit = limit;
126+
if (include) params.include = include;
127+
128+
const tickets = [];
129+
const stream = this.zohoDesk.getTicketsStream({
130+
headers: {
131+
orgId,
132+
},
133+
params,
134+
max: maxResults,
135+
});
136+
137+
for await (const ticket of stream) {
138+
tickets.push(ticket);
139+
}
140+
141+
$.export("$summary", `Successfully retrieved ${tickets.length} ticket(s)`);
142+
143+
return tickets;
144+
},
145+
};

components/zoho_desk/actions/search-ticket/search-ticket.mjs

Lines changed: 96 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
name: "Search Ticket",
66
description: "Searches for tickets in your help desk. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Search_TicketsSearchAPI)",
77
type: "action",
8-
version: "0.0.6",
8+
version: "0.0.7",
99
annotations: {
1010
destructiveHint: false,
1111
openWorldHint: true,
@@ -24,23 +24,108 @@ export default {
2424
label: "Search",
2525
description: "Search throughout the ticket with `wildcard search` strategy",
2626
},
27+
departmentId: {
28+
propDefinition: [
29+
zohoDesk,
30+
"departmentId",
31+
({ orgId }) => ({
32+
orgId,
33+
}),
34+
],
35+
},
36+
status: {
37+
propDefinition: [
38+
zohoDesk,
39+
"ticketStatus",
40+
],
41+
},
42+
priority: {
43+
propDefinition: [
44+
zohoDesk,
45+
"ticketPriority",
46+
],
47+
},
48+
assigneeId: {
49+
propDefinition: [
50+
zohoDesk,
51+
"assigneeId",
52+
({ orgId }) => ({
53+
orgId,
54+
}),
55+
],
56+
},
57+
channel: {
58+
propDefinition: [
59+
zohoDesk,
60+
"channel",
61+
],
62+
},
63+
sortBy: {
64+
propDefinition: [
65+
zohoDesk,
66+
"ticketSortBy",
67+
],
68+
},
69+
from: {
70+
propDefinition: [
71+
zohoDesk,
72+
"from",
73+
],
74+
},
75+
limit: {
76+
propDefinition: [
77+
zohoDesk,
78+
"limit",
79+
],
80+
},
81+
maxResults: {
82+
propDefinition: [
83+
zohoDesk,
84+
"maxResults",
85+
],
86+
},
2787
},
2888
async run({ $ }) {
2989
const {
3090
orgId,
3191
search,
92+
departmentId,
93+
status,
94+
priority,
95+
assigneeId,
96+
channel,
97+
sortBy,
98+
from,
99+
limit,
100+
maxResults,
32101
} = this;
33102

34-
const { data: tickets = [] } =
35-
await this.zohoDesk.searchTickets({
36-
headers: {
37-
orgId,
38-
},
39-
params: {
40-
_all: search,
41-
sortBy: "relevance",
42-
},
43-
});
103+
const params = {
104+
_all: search,
105+
sortBy: sortBy || "relevance",
106+
};
107+
108+
// Add optional filter parameters
109+
if (departmentId) params.departmentId = departmentId;
110+
if (status) params.status = status;
111+
if (priority) params.priority = priority;
112+
if (assigneeId) params.assignee = assigneeId;
113+
if (channel) params.channel = channel;
114+
if (from) params.from = from;
115+
if (limit) params.limit = limit;
116+
117+
const tickets = [];
118+
const stream = this.zohoDesk.searchTicketsStream({
119+
headers: {
120+
orgId,
121+
},
122+
params,
123+
max: maxResults,
124+
});
125+
126+
for await (const ticket of stream) {
127+
tickets.push(ticket);
128+
}
44129

45130
$.export("$summary", `Successfully found ${tickets.length} ticket(s)`);
46131

0 commit comments

Comments
 (0)