From 3162811ae69b7dbf08be3c329a14580d194b7222 Mon Sep 17 00:00:00 2001 From: falc1 Date: Fri, 25 Apr 2025 15:37:02 +0400 Subject: [PATCH 1/6] Add update ticket action and set actions --- .../assign-ticket-to-agent.mjs | 35 +++++ .../assign-ticket-to-group.mjs | 35 +++++ .../actions/close-ticket/close-ticket.mjs | 33 ++++ .../set-ticket-priority.mjs | 36 +++++ .../set-ticket-status/set-ticket-status.mjs | 36 +++++ .../actions/update-ticket/update-ticket.mjs | 142 ++++++++++++++++++ 6 files changed, 317 insertions(+) create mode 100644 components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs create mode 100644 components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs create mode 100644 components/freshdesk/actions/close-ticket/close-ticket.mjs create mode 100644 components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs create mode 100644 components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs create mode 100644 components/freshdesk/actions/update-ticket/update-ticket.mjs diff --git a/components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs b/components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs new file mode 100644 index 0000000000000..5c84b128964ac --- /dev/null +++ b/components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs @@ -0,0 +1,35 @@ +import freshdesk from "../../freshdesk.app.mjs"; + +export default { + key: "freshdesk-assign-ticket-to-agent", + name: "Assign Ticket to Agent", + description: "Assign a Freshdesk ticket to a specific agent", + version: "0.0.3", + type: "action", + props: { + freshdesk, + ticketId: { + propDefinition: [ + freshdesk, + "ticketId", + ], + }, + responder_id: { + type: "integer", + label: "Agent ID", + description: "ID of the agent to assign this ticket to", + }, + }, + async run({ $ }) { + const response = await this.freshdesk._makeRequest({ + $, + method: "PUT", + url: `/tickets/${this.ticketId}`, + data: { + responder_id: this.responder_id, + }, + }); + $.export("$summary", `Ticket ${this.ticketId} assigned to agent ${this.responder_id}`); + return response; + }, +}; diff --git a/components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs b/components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs new file mode 100644 index 0000000000000..1b90e422e91f1 --- /dev/null +++ b/components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs @@ -0,0 +1,35 @@ +import freshdesk from "../../freshdesk.app.mjs"; + +export default { + key: "freshdesk-assign-ticket-to-group", + name: "Assign Ticket to Group", + description: "Assign a Freshdesk ticket to a specific group", + version: "0.0.3", + type: "action", + props: { + freshdesk, + ticketId: { + propDefinition: [ + freshdesk, + "ticketId", + ], + }, + group_id: { + type: "integer", + label: "Group ID", + description: "ID of the group to assign this ticket to", + }, + }, + async run({ $ }) { + const response = await this.freshdesk._makeRequest({ + $, + method: "PUT", + url: `/tickets/${this.ticketId}`, + data: { + group_id: this.group_id, + }, + }); + $.export("$summary", `Ticket ${this.ticketId} assigned to group ${this.group_id}`); + return response; + }, +}; diff --git a/components/freshdesk/actions/close-ticket/close-ticket.mjs b/components/freshdesk/actions/close-ticket/close-ticket.mjs new file mode 100644 index 0000000000000..6697f7e56db1a --- /dev/null +++ b/components/freshdesk/actions/close-ticket/close-ticket.mjs @@ -0,0 +1,33 @@ +import freshdesk from "../../freshdesk.app.mjs"; + +export default { + key: "freshdesk-close-ticket", + name: "Close Ticket", + description: "Set a Freshdesk ticket's status to 'Closed'. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)", + version: "0.0.3", + type: "action", + props: { + freshdesk, + ticketId: { + propDefinition: [ + freshdesk, + "ticketId", + ], + }, + }, + async run({ $ }) { + const CLOSED_STATUS = 5; // Freshdesk status code for 'Closed' + + const response = await this.freshdesk._makeRequest({ + $, + method: "PUT", + url: `/tickets/${this.ticketId}`, + data: { + status: CLOSED_STATUS, + }, + }); + + $.export("$summary", `Ticket ${this.ticketId} closed successfully`); + return response; + }, +}; diff --git a/components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs b/components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs new file mode 100644 index 0000000000000..8731e1715ddc6 --- /dev/null +++ b/components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs @@ -0,0 +1,36 @@ +import freshdesk from "../../freshdesk.app.mjs"; + +export default { + key: "freshdesk-set-ticket-priority", + name: "Set Ticket Priority", + description: "Update the priority of a ticket in Freshdesk", + version: "0.0.3", + type: "action", + props: { + freshdesk, + ticketId: { + propDefinition: [ + freshdesk, + "ticketId", + ], + }, + ticketPriority: { + propDefinition: [ + freshdesk, + "ticketPriority", + ], + }, + }, + async run({ $ }) { + const response = await this.freshdesk._makeRequest({ + $, + method: "PUT", + url: `/tickets/${this.ticketId}`, + data: { + priority: this.ticketPriority, + }, + }); + $.export("$summary", `Ticket ${this.ticketId} priority updated to ${this.ticketPriority}`); + return response; + }, +}; diff --git a/components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs b/components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs new file mode 100644 index 0000000000000..763ac7a7e3fb0 --- /dev/null +++ b/components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs @@ -0,0 +1,36 @@ +import freshdesk from "../../freshdesk.app.mjs"; + +export default { + key: "freshdesk-set-ticket-status", + name: "Set Ticket Status", + description: "Update the status of a ticket in Freshdesk", + version: "0.0.3", + type: "action", + props: { + freshdesk, + ticketId: { + propDefinition: [ + freshdesk, + "ticketId", + ], + }, + ticketStatus: { + propDefinition: [ + freshdesk, + "ticketStatus", + ], + }, + }, + async run({ $ }) { + const response = await this.freshdesk._makeRequest({ + $, + method: "PUT", + url: `/tickets/${this.ticketId}`, + data: { + status: this.ticketStatus, + }, + }); + $.export("$summary", `Ticket ${this.ticketId} status updated to ${this.ticketStatus}`); + return response; + }, +}; diff --git a/components/freshdesk/actions/update-ticket/update-ticket.mjs b/components/freshdesk/actions/update-ticket/update-ticket.mjs new file mode 100644 index 0000000000000..c952e5165c88d --- /dev/null +++ b/components/freshdesk/actions/update-ticket/update-ticket.mjs @@ -0,0 +1,142 @@ +import freshdesk from "../../freshdesk.app.mjs"; +import { removeNullEntries } from "../../common/utils.mjs"; + +export default { + key: "freshdesk-update-ticket", + name: "Update a Ticket", + description: "Update status, priority, subject, description, agent, group, tags, etc. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)", + version: "0.0.11", + type: "action", + props: { + freshdesk, + ticketId: { + propDefinition: [ + freshdesk, + "ticketId", + ], + }, + ticketStatus: { + propDefinition: [ + freshdesk, + "ticketStatus", + ], + optional: true, + }, + ticketPriority: { + propDefinition: [ + freshdesk, + "ticketPriority", + ], + optional: true, + }, + subject: { + type: "string", + label: "Subject", + description: "Ticket subject", + optional: true, + }, + description: { + type: "string", + label: "Description", + description: "Detailed ticket description (HTML allowed)", + optional: true, + }, + group_id: { + type: "integer", + label: "Group ID", + description: "ID of the group to assign this ticket to", + optional: true, + }, + responder_id: { + type: "integer", + label: "Agent ID", + description: "ID of the agent to assign this ticket to", + optional: true, + }, + email: { + type: "string", + label: "Requester Email (replaces requester)", + description: "Updates the requester. If no contact with this email exists, a new one will be created and assigned to the ticket.", + optional: true, + }, + phone: { + type: "string", + label: "Requester Phone (replaces requester)", + description: "If no contact with this phone number exists, a new one will be created. If used without email, 'name' is required.", + optional: true, + }, + name: { + type: "string", + label: "Requester Name (required with phone if no email)", + description: "Used when creating a contact with phone but no email.", + optional: true, + }, + type: { + type: "string", + label: "Type", + description: "Type of ticket (must match one of the allowed values)", + optional: true, + options: [ + "Question", + "Incident", + "Problem", + "Feature Request", + "Refund", + ], + }, + custom_fields: { + type: "object", + label: "Custom Fields", + description: "Custom fields as key-value pairs (make sure types match your config)", + optional: true, + }, + }, + async run({ $ }) { + const { + freshdesk, + ticketId, + ticketStatus, + ticketPriority, + subject, + description, + type, + group_id, + responder_id, + email, + phone, + name, + tags, + custom_fields, + } = this; + + const data = removeNullEntries({ + status: ticketStatus, + priority: ticketPriority, + subject, + description, + type, + group_id, + responder_id, + email, + phone, + name, + tags, + custom_fields, + }); + + if (!Object.keys(data).length) { + throw new Error("Please provide at least one field to update."); + } + + const response = await freshdesk._makeRequest({ + $, + method: "PUT", + url: `/tickets/${ticketId}`, + data, + }); + + $.export("$summary", `Ticket ${ticketId} updated successfully`); + return response; + }, +}; + From 57d8eb51b15b926907d09318b2d94c248ff43cf3 Mon Sep 17 00:00:00 2001 From: falc1 Date: Fri, 25 Apr 2025 16:12:04 +0400 Subject: [PATCH 2/6] Ammend --- .../freshdesk/actions/update-ticket/update-ticket.mjs | 6 ++---- components/freshdesk/package.json | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/components/freshdesk/actions/update-ticket/update-ticket.mjs b/components/freshdesk/actions/update-ticket/update-ticket.mjs index c952e5165c88d..9537799b89002 100644 --- a/components/freshdesk/actions/update-ticket/update-ticket.mjs +++ b/components/freshdesk/actions/update-ticket/update-ticket.mjs @@ -4,8 +4,8 @@ import { removeNullEntries } from "../../common/utils.mjs"; export default { key: "freshdesk-update-ticket", name: "Update a Ticket", - description: "Update status, priority, subject, description, agent, group, tags, etc. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)", - version: "0.0.11", + description: "Update status, priority, subject, description, agent, group, etc. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)", + version: "0.0.12", type: "action", props: { freshdesk, @@ -105,7 +105,6 @@ export default { email, phone, name, - tags, custom_fields, } = this; @@ -120,7 +119,6 @@ export default { email, phone, name, - tags, custom_fields, }); diff --git a/components/freshdesk/package.json b/components/freshdesk/package.json index 1128b1f775f3e..b8471eff6fd82 100644 --- a/components/freshdesk/package.json +++ b/components/freshdesk/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/freshdesk", - "version": "0.1.1", + "version": "0.1.2", "description": "Pipedream Freshdesk Components", "main": "freshdesk.app.mjs", "keywords": [ From 8022b19a287524f7d8a467e4ef47f359ce82ea2a Mon Sep 17 00:00:00 2001 From: falc1 Date: Fri, 25 Apr 2025 16:12:04 +0400 Subject: [PATCH 3/6] Ammend --- .../freshdesk/actions/update-ticket/update-ticket.mjs | 6 ++---- components/freshdesk/package.json | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/components/freshdesk/actions/update-ticket/update-ticket.mjs b/components/freshdesk/actions/update-ticket/update-ticket.mjs index c952e5165c88d..9537799b89002 100644 --- a/components/freshdesk/actions/update-ticket/update-ticket.mjs +++ b/components/freshdesk/actions/update-ticket/update-ticket.mjs @@ -4,8 +4,8 @@ import { removeNullEntries } from "../../common/utils.mjs"; export default { key: "freshdesk-update-ticket", name: "Update a Ticket", - description: "Update status, priority, subject, description, agent, group, tags, etc. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)", - version: "0.0.11", + description: "Update status, priority, subject, description, agent, group, etc. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)", + version: "0.0.12", type: "action", props: { freshdesk, @@ -105,7 +105,6 @@ export default { email, phone, name, - tags, custom_fields, } = this; @@ -120,7 +119,6 @@ export default { email, phone, name, - tags, custom_fields, }); diff --git a/components/freshdesk/package.json b/components/freshdesk/package.json index 1128b1f775f3e..4d9f224444b3b 100644 --- a/components/freshdesk/package.json +++ b/components/freshdesk/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/freshdesk", - "version": "0.1.1", + "version": "0.1.3", "description": "Pipedream Freshdesk Components", "main": "freshdesk.app.mjs", "keywords": [ From 45ee9b178a2a7e761dbeae7bfd70ae3a1064db7b Mon Sep 17 00:00:00 2001 From: falc1 Date: Tue, 29 Apr 2025 00:32:13 +0400 Subject: [PATCH 4/6] Fix after QA --- .../assign-ticket-to-agent.mjs | 18 ++++-- .../assign-ticket-to-group.mjs | 19 ++++-- .../actions/close-ticket/close-ticket.mjs | 2 +- .../actions/create-company/create-company.mjs | 2 +- .../actions/create-contact/create-contact.mjs | 2 +- .../actions/create-ticket/create-ticket.mjs | 2 +- .../actions/get-ticket/get-ticket.mjs | 2 +- .../list-all-tickets/list-all-tickets.mjs | 2 +- .../set-ticket-priority.mjs | 21 ++++++- .../set-ticket-status/set-ticket-status.mjs | 23 +++++++- .../actions/update-ticket/update-ticket.mjs | 56 ++++++------------ components/freshdesk/freshdesk.app.mjs | 59 +++++++++++++++++++ components/freshdesk/package.json | 2 +- .../sources/new-contact/new-contact.mjs | 2 +- .../sources/new-ticket/new-ticket.mjs | 2 +- 15 files changed, 150 insertions(+), 64 deletions(-) diff --git a/components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs b/components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs index 5c84b128964ac..12eb17d523041 100644 --- a/components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs +++ b/components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs @@ -3,8 +3,8 @@ import freshdesk from "../../freshdesk.app.mjs"; export default { key: "freshdesk-assign-ticket-to-agent", name: "Assign Ticket to Agent", - description: "Assign a Freshdesk ticket to a specific agent", - version: "0.0.3", + description: "Assign a Freshdesk ticket to a specific agent. [See the documentation](https://developers.freshdesk.com/api/#update_ticket).", + version: "0.0.13", type: "action", props: { freshdesk, @@ -15,12 +15,16 @@ export default { ], }, responder_id: { - type: "integer", - label: "Agent ID", - description: "ID of the agent to assign this ticket to", + propDefinition: [ + freshdesk, + "agentId", + ], }, }, async run({ $ }) { + + const ticketName = await this.freshdesk.getTicketName(this.ticketId); + const response = await this.freshdesk._makeRequest({ $, method: "PUT", @@ -29,7 +33,9 @@ export default { responder_id: this.responder_id, }, }); - $.export("$summary", `Ticket ${this.ticketId} assigned to agent ${this.responder_id}`); + $.export("$summary", + `Ticket "${ticketName}" (ID: ${this.ticketId}) assigned to agent ${this.responder_id}`); + return response; }, }; diff --git a/components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs b/components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs index 1b90e422e91f1..6d85fa05d3c6a 100644 --- a/components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs +++ b/components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs @@ -3,8 +3,8 @@ import freshdesk from "../../freshdesk.app.mjs"; export default { key: "freshdesk-assign-ticket-to-group", name: "Assign Ticket to Group", - description: "Assign a Freshdesk ticket to a specific group", - version: "0.0.3", + description: "Assign a Freshdesk ticket to a specific group [See the documentation](https://developers.freshdesk.com/api/#update_ticket).", + version: "0.0.7", type: "action", props: { freshdesk, @@ -15,12 +15,16 @@ export default { ], }, group_id: { - type: "integer", - label: "Group ID", - description: "ID of the group to assign this ticket to", + propDefinition: [ + freshdesk, + "groupId", + ], }, }, async run({ $ }) { + + const ticketName = await this.freshdesk.getTicketName(this.ticketId); + const response = await this.freshdesk._makeRequest({ $, method: "PUT", @@ -29,7 +33,10 @@ export default { group_id: this.group_id, }, }); - $.export("$summary", `Ticket ${this.ticketId} assigned to group ${this.group_id}`); + + $.export("$summary", + `Ticket "${ticketName}" (ID: ${this.ticketId}) assigned to group ${this.group_id}`); + return response; }, }; diff --git a/components/freshdesk/actions/close-ticket/close-ticket.mjs b/components/freshdesk/actions/close-ticket/close-ticket.mjs index 6697f7e56db1a..7326b78cf33ba 100644 --- a/components/freshdesk/actions/close-ticket/close-ticket.mjs +++ b/components/freshdesk/actions/close-ticket/close-ticket.mjs @@ -4,7 +4,7 @@ export default { key: "freshdesk-close-ticket", name: "Close Ticket", description: "Set a Freshdesk ticket's status to 'Closed'. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)", - version: "0.0.3", + version: "0.0.4", type: "action", props: { freshdesk, diff --git a/components/freshdesk/actions/create-company/create-company.mjs b/components/freshdesk/actions/create-company/create-company.mjs index 2960aec4dc5f1..2763436cc55bb 100644 --- a/components/freshdesk/actions/create-company/create-company.mjs +++ b/components/freshdesk/actions/create-company/create-company.mjs @@ -4,7 +4,7 @@ export default { key: "freshdesk-create-company", name: "Create a Company", description: "Create a company. [See the documentation](https://developers.freshdesk.com/api/#create_company)", - version: "0.0.3", + version: "0.0.4", type: "action", props: { freshdesk, diff --git a/components/freshdesk/actions/create-contact/create-contact.mjs b/components/freshdesk/actions/create-contact/create-contact.mjs index e7a375fc2a6ef..049d0160e740c 100644 --- a/components/freshdesk/actions/create-contact/create-contact.mjs +++ b/components/freshdesk/actions/create-contact/create-contact.mjs @@ -5,7 +5,7 @@ export default { key: "freshdesk-create-contact", name: "Create a Contact", description: "Create a contact. [See the documentation](https://developers.freshdesk.com/api/#create_contact)", - version: "0.0.3", + version: "0.0.4", type: "action", props: { freshdesk, diff --git a/components/freshdesk/actions/create-ticket/create-ticket.mjs b/components/freshdesk/actions/create-ticket/create-ticket.mjs index c505334e4e455..6b562efe43682 100644 --- a/components/freshdesk/actions/create-ticket/create-ticket.mjs +++ b/components/freshdesk/actions/create-ticket/create-ticket.mjs @@ -4,7 +4,7 @@ export default { key: "freshdesk-create-ticket", name: "Create a Ticket", description: "Create a ticket. [See the documentation](https://developers.freshdesk.com/api/#create_ticket)", - version: "0.0.4", + version: "0.0.5", type: "action", props: { freshdesk, diff --git a/components/freshdesk/actions/get-ticket/get-ticket.mjs b/components/freshdesk/actions/get-ticket/get-ticket.mjs index 18837769a396f..6769ba87c5975 100644 --- a/components/freshdesk/actions/get-ticket/get-ticket.mjs +++ b/components/freshdesk/actions/get-ticket/get-ticket.mjs @@ -4,7 +4,7 @@ export default { key: "freshdesk-get-ticket", name: "Get Ticket Details", description: "Get details of a Ticket. [See the documentation](https://developers.freshdesk.com/api/#view_a_ticket)", - version: "0.1.1", + version: "0.1.2", type: "action", props: { freshdesk, diff --git a/components/freshdesk/actions/list-all-tickets/list-all-tickets.mjs b/components/freshdesk/actions/list-all-tickets/list-all-tickets.mjs index 8c9060b92517d..13a0896a1316d 100644 --- a/components/freshdesk/actions/list-all-tickets/list-all-tickets.mjs +++ b/components/freshdesk/actions/list-all-tickets/list-all-tickets.mjs @@ -5,7 +5,7 @@ export default { name: "List Tickets", description: "Fetch up to 100 tickets according to the selected filters. [See the documentation](https://developers.freshdesk.com/api/#list_all_tickets)", - version: "0.2.1", + version: "0.2.2", type: "action", props: { freshdesk, diff --git a/components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs b/components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs index 8731e1715ddc6..1d5f2c26cf6b5 100644 --- a/components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs +++ b/components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs @@ -3,8 +3,8 @@ import freshdesk from "../../freshdesk.app.mjs"; export default { key: "freshdesk-set-ticket-priority", name: "Set Ticket Priority", - description: "Update the priority of a ticket in Freshdesk", - version: "0.0.3", + description: "Update the priority of a ticket in Freshdesk [See the documentation](https://developers.freshdesk.com/api/#update_ticket).", + version: "0.0.11", type: "action", props: { freshdesk, @@ -22,6 +22,9 @@ export default { }, }, async run({ $ }) { + + const ticketName = await this.freshdesk.getTicketName(this.ticketId); + const response = await this.freshdesk._makeRequest({ $, method: "PUT", @@ -30,7 +33,19 @@ export default { priority: this.ticketPriority, }, }); - $.export("$summary", `Ticket ${this.ticketId} priority updated to ${this.ticketPriority}`); + + const priorityLabels = { + 1: "Low", + 2: "Medium", + 3: "High", + 4: "Urgent", + }; + + const priorityLabel = priorityLabels[this.ticketPriority] || this.ticketPriority; + + $.export("$summary", + `Ticket ${ticketName} (ID: ${this.ticketId}) priority updated to "${priorityLabel}".`); + return response; }, }; diff --git a/components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs b/components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs index 763ac7a7e3fb0..56dd64fd4b55e 100644 --- a/components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs +++ b/components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs @@ -3,8 +3,8 @@ import freshdesk from "../../freshdesk.app.mjs"; export default { key: "freshdesk-set-ticket-status", name: "Set Ticket Status", - description: "Update the status of a ticket in Freshdesk", - version: "0.0.3", + description: "Update the status of a ticket in Freshdesk [See the documentation](https://developers.freshdesk.com/api/#update_ticket).", + version: "0.0.8", type: "action", props: { freshdesk, @@ -22,6 +22,9 @@ export default { }, }, async run({ $ }) { + + const ticketName = await this.freshdesk.getTicketName(this.ticketId); + const response = await this.freshdesk._makeRequest({ $, method: "PUT", @@ -30,7 +33,21 @@ export default { status: this.ticketStatus, }, }); - $.export("$summary", `Ticket ${this.ticketId} status updated to ${this.ticketStatus}`); + + const statusLabels = { + 2: "Open", + 3: "Pending", + 4: "Resolved", + 5: "Closed", + }; + + const statusLabel = statusLabels[this.ticketStatus] || this.ticketStatus; + + $.export( + "$summary", + `Ticket "${ticketName}" (ID: ${this.ticketId}) status updated to "${statusLabel}".`, + ); + return response; }, }; diff --git a/components/freshdesk/actions/update-ticket/update-ticket.mjs b/components/freshdesk/actions/update-ticket/update-ticket.mjs index 9537799b89002..f93573d59c00e 100644 --- a/components/freshdesk/actions/update-ticket/update-ticket.mjs +++ b/components/freshdesk/actions/update-ticket/update-ticket.mjs @@ -4,8 +4,8 @@ import { removeNullEntries } from "../../common/utils.mjs"; export default { key: "freshdesk-update-ticket", name: "Update a Ticket", - description: "Update status, priority, subject, description, agent, group, etc. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)", - version: "0.0.12", + description: "Update status, priority, subject, description, agent, group, etc. [See the documentation](https://developers.freshdesk.com/api/#update_ticket).", + version: "0.0.17", type: "action", props: { freshdesk, @@ -15,14 +15,14 @@ export default { "ticketId", ], }, - ticketStatus: { + status: { propDefinition: [ freshdesk, "ticketStatus", ], optional: true, }, - ticketPriority: { + priority: { propDefinition: [ freshdesk, "ticketPriority", @@ -42,16 +42,16 @@ export default { optional: true, }, group_id: { - type: "integer", - label: "Group ID", - description: "ID of the group to assign this ticket to", - optional: true, + propDefinition: [ + freshdesk, + "groupId", + ], }, responder_id: { - type: "integer", - label: "Agent ID", - description: "ID of the agent to assign this ticket to", - optional: true, + propDefinition: [ + freshdesk, + "agentId", + ], }, email: { type: "string", @@ -95,37 +95,19 @@ export default { const { freshdesk, ticketId, - ticketStatus, - ticketPriority, - subject, - description, - type, - group_id, - responder_id, - email, - phone, - name, - custom_fields, + ...fields } = this; - const data = removeNullEntries({ - status: ticketStatus, - priority: ticketPriority, - subject, - description, - type, - group_id, - responder_id, - email, - phone, - name, - custom_fields, - }); + const data = removeNullEntries(fields); + + const ticketName = await freshdesk.getTicketName(ticketId); 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", @@ -133,7 +115,7 @@ export default { data, }); - $.export("$summary", `Ticket ${ticketId} updated successfully`); + $.export("$summary", `Ticket "${ticketName}" (ID: ${this.ticketId}) updated successfully`); return response; }, }; diff --git a/components/freshdesk/freshdesk.app.mjs b/components/freshdesk/freshdesk.app.mjs index d60c43eff58af..fe405b1c37151 100644 --- a/components/freshdesk/freshdesk.app.mjs +++ b/components/freshdesk/freshdesk.app.mjs @@ -19,6 +19,7 @@ export default { })); }, }, + ticketId: { type: "integer", label: "Ticket ID", @@ -37,6 +38,48 @@ export default { })); }, }, + agentId: { + type: "integer", + label: "Agent", + description: "Select an agent to assign the ticket to", + async options({ page = 0 }) { + const response = await this._makeRequest({ + method: "GET", + url: "/agents", + params: { + page: page + 1, + }, + }); + + return response.map((agent) => ({ + label: agent.contact?.name + ? `${agent.contact.name} (${agent.contact.email || "No email"})` + : `Agent ${agent.id}`, + value: agent.id, + })); + }, + }, + groupId: { + type: "integer", + label: "Group", + description: "Select a group to assign the ticket to.", + async options({ page = 0 }) { + const groups = await this._makeRequest({ + method: "GET", + url: "/groups", + params: { + page: page + 1, + per_page: 100, + }, + }); + + return groups.map((group) => ({ + label: group.name || `Group ${group.id}`, + value: group.id, + })); + }, + }, + ticketStatus: { type: "integer", label: "Status", @@ -207,5 +250,21 @@ export default { ...args, }); }, + async getTicketName(ticketId) { + const ticket = await this.getTicket({ + ticketId, + }); + return ticket.subject; + }, + parseIfJSONString(input) { + if (typeof input === "string") { + try { + return JSON.parse(input); + } catch (error) { + return input; + } + } + return input; + }, }, }; diff --git a/components/freshdesk/package.json b/components/freshdesk/package.json index 4d9f224444b3b..ae94da8e6a169 100644 --- a/components/freshdesk/package.json +++ b/components/freshdesk/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/freshdesk", - "version": "0.1.3", + "version": "0.1.4", "description": "Pipedream Freshdesk Components", "main": "freshdesk.app.mjs", "keywords": [ diff --git a/components/freshdesk/sources/new-contact/new-contact.mjs b/components/freshdesk/sources/new-contact/new-contact.mjs index bfd2f40aab89d..aa3e485eb8baa 100644 --- a/components/freshdesk/sources/new-contact/new-contact.mjs +++ b/components/freshdesk/sources/new-contact/new-contact.mjs @@ -6,7 +6,7 @@ export default { key: "freshdesk-new-contact", name: "New Contact Created", description: "Emit new event when a contact is created. [See the documentation](https://developers.freshdesk.com/api/#filter_contacts)", - version: "0.0.4", + version: "0.0.5", type: "source", props: { freshdesk, diff --git a/components/freshdesk/sources/new-ticket/new-ticket.mjs b/components/freshdesk/sources/new-ticket/new-ticket.mjs index 1f910b1786cc4..8af71af64fff3 100644 --- a/components/freshdesk/sources/new-ticket/new-ticket.mjs +++ b/components/freshdesk/sources/new-ticket/new-ticket.mjs @@ -6,7 +6,7 @@ export default { key: "freshdesk-new-ticket", name: "New Ticket Created", description: "Emit new event when a ticket is created. [See the documentation](https://developers.freshdesk.com/api/#filter_tickets)", - version: "0.0.4", + version: "0.0.5", type: "source", props: { freshdesk, From 2ca978d4400ca45141b4d9eca3eaae1ada657ad9 Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Wed, 30 Apr 2025 10:47:28 -0400 Subject: [PATCH 5/6] versions --- .../actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs | 2 +- .../actions/assign-ticket-to-group/assign-ticket-to-group.mjs | 2 +- components/freshdesk/actions/close-ticket/close-ticket.mjs | 2 +- .../actions/set-ticket-priority/set-ticket-priority.mjs | 2 +- .../freshdesk/actions/set-ticket-status/set-ticket-status.mjs | 2 +- components/freshdesk/actions/update-ticket/update-ticket.mjs | 2 +- components/freshdesk/package.json | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs b/components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs index 12eb17d523041..68e6f0d5bacd1 100644 --- a/components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs +++ b/components/freshdesk/actions/assign-ticket-to-agent/assign-ticket-to-agent.mjs @@ -4,7 +4,7 @@ export default { key: "freshdesk-assign-ticket-to-agent", name: "Assign Ticket to Agent", description: "Assign a Freshdesk ticket to a specific agent. [See the documentation](https://developers.freshdesk.com/api/#update_ticket).", - version: "0.0.13", + version: "0.0.1", type: "action", props: { freshdesk, diff --git a/components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs b/components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs index 6d85fa05d3c6a..296a24d2f417a 100644 --- a/components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs +++ b/components/freshdesk/actions/assign-ticket-to-group/assign-ticket-to-group.mjs @@ -4,7 +4,7 @@ export default { key: "freshdesk-assign-ticket-to-group", name: "Assign Ticket to Group", description: "Assign a Freshdesk ticket to a specific group [See the documentation](https://developers.freshdesk.com/api/#update_ticket).", - version: "0.0.7", + version: "0.0.1", type: "action", props: { freshdesk, diff --git a/components/freshdesk/actions/close-ticket/close-ticket.mjs b/components/freshdesk/actions/close-ticket/close-ticket.mjs index 7326b78cf33ba..963260da7b973 100644 --- a/components/freshdesk/actions/close-ticket/close-ticket.mjs +++ b/components/freshdesk/actions/close-ticket/close-ticket.mjs @@ -4,7 +4,7 @@ export default { key: "freshdesk-close-ticket", name: "Close Ticket", description: "Set a Freshdesk ticket's status to 'Closed'. [See docs](https://developers.freshdesk.com/api/#update_a_ticket)", - version: "0.0.4", + version: "0.0.1", type: "action", props: { freshdesk, diff --git a/components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs b/components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs index 1d5f2c26cf6b5..6790ef691a8b9 100644 --- a/components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs +++ b/components/freshdesk/actions/set-ticket-priority/set-ticket-priority.mjs @@ -4,7 +4,7 @@ export default { key: "freshdesk-set-ticket-priority", name: "Set Ticket Priority", description: "Update the priority of a ticket in Freshdesk [See the documentation](https://developers.freshdesk.com/api/#update_ticket).", - version: "0.0.11", + version: "0.0.1", type: "action", props: { freshdesk, diff --git a/components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs b/components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs index 56dd64fd4b55e..0a94f28e9c0cb 100644 --- a/components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs +++ b/components/freshdesk/actions/set-ticket-status/set-ticket-status.mjs @@ -4,7 +4,7 @@ export default { key: "freshdesk-set-ticket-status", name: "Set Ticket Status", description: "Update the status of a ticket in Freshdesk [See the documentation](https://developers.freshdesk.com/api/#update_ticket).", - version: "0.0.8", + version: "0.0.1", type: "action", props: { freshdesk, diff --git a/components/freshdesk/actions/update-ticket/update-ticket.mjs b/components/freshdesk/actions/update-ticket/update-ticket.mjs index f93573d59c00e..f1dd5c8c1e7df 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.17", + version: "0.0.1", type: "action", props: { freshdesk, diff --git a/components/freshdesk/package.json b/components/freshdesk/package.json index ae94da8e6a169..5b58e05dcd799 100644 --- a/components/freshdesk/package.json +++ b/components/freshdesk/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/freshdesk", - "version": "0.1.4", + "version": "0.2.0", "description": "Pipedream Freshdesk Components", "main": "freshdesk.app.mjs", "keywords": [ From 29ec067a1f263a19cb038d2f91bd823dbcd5792b Mon Sep 17 00:00:00 2001 From: michelle0927 Date: Wed, 30 Apr 2025 10:49:28 -0400 Subject: [PATCH 6/6] pnpm-lock.yaml --- pnpm-lock.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1a8d77d88c2c2..eee1fc6916b83 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2864,8 +2864,7 @@ importers: specifier: ^4.17.21 version: 4.17.21 - components/consulta_unica: - specifiers: {} + components/consulta_unica: {} components/contact_enhance: dependencies: