diff --git a/components/freshdesk/actions/update-ticket/update-ticket.mjs b/components/freshdesk/actions/update-ticket/update-ticket.mjs index f1dd5c8c1e7df..641b0e3d8d047 100644 --- a/components/freshdesk/actions/update-ticket/update-ticket.mjs +++ b/components/freshdesk/actions/update-ticket/update-ticket.mjs @@ -5,7 +5,7 @@ export default { key: "freshdesk-update-ticket", name: "Update a Ticket", description: "Update status, priority, subject, description, agent, group, etc. [See the documentation](https://developers.freshdesk.com/api/#update_ticket).", - version: "0.0.1", + version: "0.0.2", type: "action", props: { freshdesk, @@ -71,6 +71,19 @@ export default { description: "Used when creating a contact with phone but no email.", optional: true, }, + internalNote: { + type: "boolean", + label: "Internal note (private)", + description: "If enabled, the comment will be added as an internal note (not visible to requester).", + optional: true, + default: false, + }, + noteBody: { + type: "string", + label: "Note Body", + description: "The content of the internal note to add.", + optional: true, + }, type: { type: "string", label: "Type", @@ -95,6 +108,8 @@ export default { const { freshdesk, ticketId, + internalNote, + noteBody, ...fields } = this; @@ -102,21 +117,35 @@ export default { const ticketName = await freshdesk.getTicketName(ticketId); + if (internalNote && noteBody) { + const response = await freshdesk._makeRequest({ + $, + method: "POST", + url: `/tickets/${ticketId}/notes`, + data: { + body: noteBody, + private: true, + }, + }); + + $.export("$summary", `Internal note added to ticket "${ticketName}" (ID: ${ticketId})`); + return response; + } + if (!Object.keys(data).length) { throw new Error("Please provide at least one field to update."); } - + if (data.custom_fields) freshdesk.parseIfJSONString(data.custom_fields); - + const response = await freshdesk._makeRequest({ $, method: "PUT", url: `/tickets/${ticketId}`, data, }); - + $.export("$summary", `Ticket "${ticketName}" (ID: ${this.ticketId}) updated successfully`); return response; }, -}; - +} \ No newline at end of file diff --git a/components/zendesk/actions/add-ticket-tags/add-ticket-tags.mjs b/components/zendesk/actions/add-ticket-tags/add-ticket-tags.mjs new file mode 100644 index 0000000000000..e905467e471dc --- /dev/null +++ b/components/zendesk/actions/add-ticket-tags/add-ticket-tags.mjs @@ -0,0 +1,48 @@ +import app from "../../zendesk.app.mjs"; + +export default { + key: "zendesk-add-ticket-tags", + name: "Add Ticket Tags", + description: "Add tags to a ticket (appends to existing tags). [See the documentation](https://developer.zendesk.com/api-reference/ticketing/ticket-management/tags/#add-tags).", + type: "action", + version: "0.0.1", + props: { + app, + ticketId: { + propDefinition: [ + app, + "ticketId", + ], + }, + ticketTags: { + propDefinition: [ + app, + "ticketTags", + ], + description: "Array of tags to add to the ticket. These will be appended to any existing tags.", + }, + customSubdomain: { + propDefinition: [ + app, + "customSubdomain", + ], + }, + }, + async run({ $: step }) { + const { + ticketId, + ticketTags, + customSubdomain, + } = this; + + const response = await this.app.addTicketTags({ + step, + ticketId, + tags: ticketTags, + customSubdomain, + }); + + step.export("$summary", `Successfully added ${ticketTags.length} tag(s) to ticket ${ticketId}`); + return response; + }, +}; \ No newline at end of file diff --git a/components/zendesk/actions/remove-ticket-tags/remove-ticket-tags.mjs b/components/zendesk/actions/remove-ticket-tags/remove-ticket-tags.mjs new file mode 100644 index 0000000000000..4ebc41d4169e5 --- /dev/null +++ b/components/zendesk/actions/remove-ticket-tags/remove-ticket-tags.mjs @@ -0,0 +1,48 @@ +import app from "../../zendesk.app.mjs"; + +export default { + key: "zendesk-remove-ticket-tags", + name: "Remove Ticket Tags", + description: "Remove specific tags from a ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/ticket-management/tags/#remove-tags).", + type: "action", + version: "0.0.1", + props: { + app, + ticketId: { + propDefinition: [ + app, + "ticketId", + ], + }, + ticketTags: { + propDefinition: [ + app, + "ticketTags", + ], + description: "Array of tags to remove from the ticket.", + }, + customSubdomain: { + propDefinition: [ + app, + "customSubdomain", + ], + }, + }, + async run({ $: step }) { + const { + ticketId, + ticketTags, + customSubdomain, + } = this; + + const response = await this.app.removeTicketTags({ + step, + ticketId, + tags: ticketTags, + customSubdomain, + }); + + step.export("$summary", `Successfully removed ${ticketTags.length} tag(s) from ticket ${ticketId}`); + return response; + }, +}; \ No newline at end of file diff --git a/components/zendesk/actions/set-ticket-tags/set-ticket-tags.mjs b/components/zendesk/actions/set-ticket-tags/set-ticket-tags.mjs new file mode 100644 index 0000000000000..93f67f9c03f37 --- /dev/null +++ b/components/zendesk/actions/set-ticket-tags/set-ticket-tags.mjs @@ -0,0 +1,47 @@ +import app from "../../zendesk.app.mjs"; + +export default { + key: "zendesk-set-ticket-tags", + name: "Set Ticket Tags", + description: "Set tags on a ticket (replaces all existing tags). [See the documentation](https://developer.zendesk.com/api-reference/ticketing/ticket-management/tags/#set-tags).", + type: "action", + version: "0.0.1", + props: { + app, + ticketId: { + propDefinition: [ + app, + "ticketId", + ], + }, + ticketTags: { + propDefinition: [ + app, + "ticketTags", + ], + }, + customSubdomain: { + propDefinition: [ + app, + "customSubdomain", + ], + }, + }, + async run({ $: step }) { + const { + ticketId, + ticketTags, + customSubdomain, + } = this; + + const response = await this.app.setTicketTags({ + step, + ticketId, + tags: ticketTags, + customSubdomain, + }); + + step.export("$summary", `Successfully set ${ticketTags.length} tag(s) on ticket ${ticketId}`); + return response; + }, +}; \ No newline at end of file diff --git a/components/zendesk/actions/update-ticket/update-ticket.mjs b/components/zendesk/actions/update-ticket/update-ticket.mjs index f3e44b6566f68..5eb9e6852fc01 100644 --- a/components/zendesk/actions/update-ticket/update-ticket.mjs +++ b/components/zendesk/actions/update-ticket/update-ticket.mjs @@ -3,9 +3,9 @@ import app from "../../zendesk.app.mjs"; export default { key: "zendesk-update-ticket", name: "Update Ticket", - description: "Updates a ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-ticket).", + description: "Updates a ticket and optionally manages tags. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-ticket).", type: "action", - version: "0.1.3", + version: "0.1.4", props: { app, ticketId: { @@ -44,6 +44,33 @@ export default { "customSubdomain", ], }, + ticketTags: { + propDefinition: [ + app, + "ticketTags", + ], + }, + tagAction: { + type: "string", + label: "Tag Action", + description: "How to handle the tags: set (replace all existing tags), add (append to existing tags), or remove (remove specified tags)", + options: [ + { + label: "Set Tags (Replace All)", + value: "set", + }, + { + label: "Add Tags (Append)", + value: "add", + }, + { + label: "Remove Tags", + value: "remove", + }, + ], + optional: true, + default: "set", + }, }, methods: { updateTicket({ @@ -63,6 +90,8 @@ export default { ticketSubject, ticketStatus, customSubdomain, + ticketTags, + tagAction, } = this; const response = await this.updateTicket({ @@ -81,8 +110,50 @@ export default { }, }); - step.export("$summary", `Successfully updated ticket with ID ${response.ticket.id}`); + // Handle tag operations if tags are provided + if (ticketTags && ticketTags.length > 0) { + let tagResponse; + + switch (tagAction) { + case "add": + tagResponse = await this.app.addTicketTags({ + step, + ticketId, + tags: ticketTags, + customSubdomain, + }); + break; + case "remove": + tagResponse = await this.app.removeTicketTags({ + step, + ticketId, + tags: ticketTags, + customSubdomain, + }); + break; + case "set": + default: + tagResponse = await this.app.setTicketTags({ + step, + ticketId, + tags: ticketTags, + customSubdomain, + }); + break; + } + + // Include tag information in summary + const tagSummary = `and ${tagAction === "set" ? "set" : tagAction === "add" ? "added" : "removed"} ${ticketTags.length} tag(s)`; + step.export("$summary", `Successfully updated ticket with ID ${response.ticket.id} ${tagSummary}`); + + // Include tag response in the return data + return { + ticket: response, + tags: tagResponse, + }; + } + step.export("$summary", `Successfully updated ticket with ID ${response.ticket.id}`); return response; }, }; diff --git a/components/zendesk/zendesk.app.mjs b/components/zendesk/zendesk.app.mjs index f2b60ed78f3ba..4d8d92d8e984b 100644 --- a/components/zendesk/zendesk.app.mjs +++ b/components/zendesk/zendesk.app.mjs @@ -174,6 +174,12 @@ export default { description: "For Enterprise Zendesk accounts: optionally specify the subdomain to use. This will override the subdomain that was provided when connecting your Zendesk account to Pipedream. For example, if you Zendesk URL is https://examplehelp.zendesk.com, your subdomain is `examplehelp`", optional: true, }, + ticketTags: { + type: "string[]", + label: "Tags", + description: "Array of tags to apply to the ticket. These will replace any existing tags on the ticket.", + optional: true, + }, }, methods: { getUrl(path, customSubdomain) { @@ -300,5 +306,68 @@ export default { args.params.page += 1; } }, + /** + * Set tags on a ticket (replaces all existing tags) + * @param {object} args - Arguments object + * @param {string} args.ticketId - The ticket ID + * @param {string[]} args.tags - Array of tags to set + * @param {string} args.customSubdomain - Optional custom subdomain + * @returns {Promise} API response + */ + setTicketTags({ + ticketId, tags, customSubdomain, ...args + }) { + return this.makeRequest({ + method: "PUT", + path: `/tickets/${ticketId}/tags.json`, + customSubdomain, + data: { + tags, + }, + ...args, + }); + }, + /** + * Add tags to a ticket (appends to existing tags) + * @param {object} args - Arguments object + * @param {string} args.ticketId - The ticket ID + * @param {string[]} args.tags - Array of tags to add + * @param {string} args.customSubdomain - Optional custom subdomain + * @returns {Promise} API response + */ + addTicketTags({ + ticketId, tags, customSubdomain, ...args + }) { + return this.makeRequest({ + method: "POST", + path: `/tickets/${ticketId}/tags.json`, + customSubdomain, + data: { + tags, + }, + ...args, + }); + }, + /** + * Remove specific tags from a ticket + * @param {object} args - Arguments object + * @param {string} args.ticketId - The ticket ID + * @param {string[]} args.tags - Array of tags to remove + * @param {string} args.customSubdomain - Optional custom subdomain + * @returns {Promise} API response + */ + removeTicketTags({ + ticketId, tags, customSubdomain, ...args + }) { + return this.makeRequest({ + method: "DELETE", + path: `/tickets/${ticketId}/tags.json`, + customSubdomain, + data: { + tags, + }, + ...args, + }); + }, }, };