Skip to content

Zendesk - View, List, Search Tickets actions #16640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/zendesk/actions/create-ticket/create-ticket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Create Ticket",
description: "Creates a ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#create-ticket).",
type: "action",
version: "0.1.2",
version: "0.1.3",
props: {
app,
ticketCommentBody: {
Expand Down
2 changes: 1 addition & 1 deletion components/zendesk/actions/delete-ticket/delete-ticket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Delete Ticket",
description: "Deletes a ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#delete-ticket).",
type: "action",
version: "0.1.2",
version: "0.1.3",
props: {
app,
ticketId: {
Expand Down
40 changes: 40 additions & 0 deletions components/zendesk/actions/get-ticket-info/get-ticket-info.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import app from "../../zendesk.app.mjs";

export default {
key: "zendesk-get-ticket-info",
name: "Get Ticket Info",
description: "Retrieves information about a specific ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#show-ticket).",
type: "action",
version: "0.0.1",
props: {
app,
ticketId: {
propDefinition: [
app,
"ticketId",
],
},
customSubdomain: {
propDefinition: [
app,
"customSubdomain",
],
},
},
async run({ $: step }) {
const {
ticketId,
customSubdomain,
} = this;

const response = await this.app.getTicketInfo({
step,
ticketId,
customSubdomain,
});

step.export("$summary", `Successfully retrieved ticket with ID ${response.ticket.id}`);

return response;
},
};
67 changes: 67 additions & 0 deletions components/zendesk/actions/list-tickets/list-tickets.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import app from "../../zendesk.app.mjs";

export default {
key: "zendesk-list-tickets",
name: "List Tickets",
description: "Retrieves a list of tickets. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets).",
type: "action",
version: "0.0.1",
props: {
app,
sortBy: {
propDefinition: [
app,
"sortBy",
],
},
sortOrder: {
propDefinition: [
app,
"sortOrder",
],
},
limit: {
propDefinition: [
app,
"limit",
],
},
customSubdomain: {
propDefinition: [
app,
"customSubdomain",
],
},
},
async run({ $: step }) {
const {
sortBy,
sortOrder,
limit,
customSubdomain,
} = this;

const results = this.app.paginate({
fn: this.app.listTickets,
args: {
step,
customSubdomain,
params: {
sort_by: sortBy,
sort_order: sortOrder,
},
},
resourceKey: "tickets",
max: limit,
});

const tickets = [];
for await (const ticket of results) {
tickets.push(ticket);
}

step.export("$summary", `Successfully retrieved ${tickets.length} tickets`);

return tickets;
},
};
74 changes: 74 additions & 0 deletions components/zendesk/actions/search-tickets/search-tickets.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import app from "../../zendesk.app.mjs";

export default {
key: "zendesk-search-tickets",
name: "Search Tickets",
description: "Searches for tickets using Zendesk's search API. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/ticket-management/search/#search-tickets).",
type: "action",
version: "0.0.1",
props: {
app,
query: {
type: "string",
label: "Search Query",
description: "The search query to find tickets. You can use Zendesk's search syntax. Example: `type:ticket status:open priority:high`. [See the documentation](https://developer.zendesk.com/documentation/ticketing/using-the-zendesk-api/searching-with-the-zendesk-api/)",
},
sortBy: {
propDefinition: [
app,
"sortBy",
],
},
sortOrder: {
propDefinition: [
app,
"sortOrder",
],
},
limit: {
propDefinition: [
app,
"limit",
],
},
customSubdomain: {
propDefinition: [
app,
"customSubdomain",
],
},
},
async run({ $: step }) {
const {
query,
sortBy,
sortOrder,
limit,
customSubdomain,
} = this;

const results = this.app.paginate({
fn: this.app.searchTickets,
args: {
step,
customSubdomain,
params: {
query,
sort_by: sortBy,
sort_order: sortOrder,
},
},
resourceKey: "results",
max: limit,
});

const tickets = [];
for await (const ticket of results) {
tickets.push(ticket);
}

step.export("$summary", `Successfully found ${tickets.length} tickets matching the search query`);

return tickets;
},
};
2 changes: 1 addition & 1 deletion components/zendesk/actions/update-ticket/update-ticket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Update Ticket",
description: "Updates a ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-ticket).",
type: "action",
version: "0.1.2",
version: "0.1.3",
props: {
app,
ticketId: {
Expand Down
14 changes: 14 additions & 0 deletions components/zendesk/common/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,19 @@ const TICKET_FIELD_OPTIONS = [
},
];

const SORT_BY_OPTIONS = [
"assignee",
"assignee.name",
"created_at",
"group",
"id",
"requester",
"requester.name",
"status",
"subject",
"updated_at",
];

export default {
SUBDOMAIN_PLACEHOLDER,
BASE_URL,
Expand All @@ -242,4 +255,5 @@ export default {
TICKET_PRIORITY_OPTIONS,
TICKET_STATUS_OPTIONS,
TICKET_FIELD_OPTIONS,
SORT_BY_OPTIONS,
};
4 changes: 2 additions & 2 deletions components/zendesk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/zendesk",
"version": "0.6.1",
"version": "0.7.0",
"description": "Pipedream Zendesk Components",
"main": "zendesk.app.mjs",
"keywords": [
Expand All @@ -14,7 +14,7 @@
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^0.9.0",
"@pipedream/platform": "^3.0.3",
"crypto": "^1.0.1"
}
}
2 changes: 1 addition & 1 deletion components/zendesk/sources/new-ticket/new-ticket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "zendesk-new-ticket",
type: "source",
description: "Emit new event when a ticket is created",
version: "0.2.2",
version: "0.2.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "zendesk-ticket-added-to-view",
name: "New Ticket Added to View (Instant)",
description: "Emit new event when a ticket is added to the specified view",
version: "0.0.2",
version: "0.0.3",
type: "source",
dedupe: "unique",
props: {
Expand Down
2 changes: 1 addition & 1 deletion components/zendesk/sources/ticket-closed/ticket-closed.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

export default {
...common,
name: "Ticket Closed (Instant)",

Check warning on line 5 in components/zendesk/sources/ticket-closed/ticket-closed.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
key: "zendesk-ticket-closed",
type: "source",
description: "Emit new event when a ticket has changed to closed status",
version: "0.2.2",
version: "0.2.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
2 changes: 1 addition & 1 deletion components/zendesk/sources/ticket-pended/ticket-pended.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

export default {
...common,
name: "Ticket Pending (Instant)",

Check warning on line 5 in components/zendesk/sources/ticket-pended/ticket-pended.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
key: "zendesk-ticket-pended",
type: "source",
description: "Emit new event when a ticket has changed to pending status",
version: "0.2.2",
version: "0.2.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
2 changes: 1 addition & 1 deletion components/zendesk/sources/ticket-solved/ticket-solved.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

export default {
...common,
name: "Ticket Solved (Instant)",

Check warning on line 5 in components/zendesk/sources/ticket-solved/ticket-solved.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
key: "zendesk-ticket-solved",
type: "source",
description: "Emit new event when a ticket has changed to solved status",
version: "0.2.2",
version: "0.2.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

export default {
...common,
name: "Ticket Updated (Instant)",

Check warning on line 5 in components/zendesk/sources/ticket-updated/ticket-updated.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
key: "zendesk-ticket-updated",
type: "source",
description: "Emit new event when a ticket has been updated",
version: "0.2.2",
version: "0.2.3",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
69 changes: 69 additions & 0 deletions components/zendesk/zendesk.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,30 @@ export default {
optional: true,
options: Object.values(constants.TICKET_STATUS_OPTIONS),
},
sortBy: {
type: "string",
label: "Sort By",
description: "Field to sort tickets by",
optional: true,
options: constants.SORT_BY_OPTIONS,
},
sortOrder: {
type: "string",
label: "Sort Order",
description: "Sort order (ascending or descending)",
optional: true,
options: [
"asc",
"desc",
],
},
limit: {
type: "integer",
label: "Limit",
description: "Maximum number of tickets to return",
optional: true,
default: 100,
},
customSubdomain: {
type: "string",
label: "Custom Subdomain",
Expand Down Expand Up @@ -181,6 +205,20 @@ export default {
};
return axios(step, config);
},
getTicketInfo({
ticketId, ...args
} = {}) {
return this.makeRequest({
path: `/tickets/${ticketId}`,
...args,
});
},
searchTickets(args = {}) {
return this.makeRequest({
path: "/search",
...args,
});
},
create(args = {}) {
return this.makeRequest({
method: "post",
Expand Down Expand Up @@ -231,5 +269,36 @@ export default {
...args,
});
},
async *paginate({
fn, args, resourceKey, max,
}) {
args = {
...args,
params: {
...args?.params,
per_page: constants.DEFAULT_LIMIT,
page: 1,
},
};
let hasMore = true;
let count = 0;
while (hasMore) {
const response = await fn(args);
const items = resourceKey
? response[resourceKey]
: response;
if (!items?.length) {
return;
}
for (const item of items) {
yield item;
if (max && ++count >= max) {
return;
}
}
hasMore = !!response.next_page;
args.params.page += 1;
}
},
},
};
Loading
Loading