From fc704c01c8895b8f9a9e13416afe33044450959f Mon Sep 17 00:00:00 2001 From: seynadio <79858321+seynadio@users.noreply.github.com> Date: Mon, 14 Jul 2025 10:42:31 +0200 Subject: [PATCH 1/2] fix issues --- .../actions/update-ticket/update-ticket.mjs | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) 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 From 4e01d37643242d3bc9d5b2d3e643e1bb0cfd8631 Mon Sep 17 00:00:00 2001 From: seynadio <79858321+seynadio@users.noreply.github.com> Date: Mon, 14 Jul 2025 11:23:39 +0200 Subject: [PATCH 2/2] Add internal notes support to Trengo integration - Add createInternalNote method to Trengo app - Add dedicated create-internal-note action for adding notes to tickets - Enhance send-a-message action with createInternalNote option - Update package version to 0.1.1 - Leverage existing new-internal-note webhook source for notifications --- .../create-internal-note.mjs | 37 +++++++++++++ .../actions/send-a-message/send-a-message.mjs | 52 ++++++++++++++----- components/trengo/package.json | 2 +- components/trengo/trengo.app.mjs | 7 +++ 4 files changed, 84 insertions(+), 14 deletions(-) create mode 100644 components/trengo/actions/create-internal-note/create-internal-note.mjs diff --git a/components/trengo/actions/create-internal-note/create-internal-note.mjs b/components/trengo/actions/create-internal-note/create-internal-note.mjs new file mode 100644 index 0000000000000..c6783ac5b0b72 --- /dev/null +++ b/components/trengo/actions/create-internal-note/create-internal-note.mjs @@ -0,0 +1,37 @@ +import app from "../../trengo.app.mjs"; + +export default { + type: "action", + key: "trengo-create-internal-note", + version: "0.0.1", + name: "Create Internal Note", + description: "Create an internal note on a ticket that is only visible to team members. [See the docs](https://developers.trengo.com/reference/create-internal-note)", + props: { + app, + ticketId: { + propDefinition: [ + app, + "ticketId", + ], + }, + note: { + propDefinition: [ + app, + "note", + ], + optional: false, + description: "The internal note content that will be added to the ticket.", + }, + }, + async run({ $ }) { + const resp = await this.app.createInternalNote({ + $, + data: { + ticket_id: this.ticketId, + note: this.note, + }, + }); + $.export("$summary", `Successfully created internal note on ticket ${this.ticketId}`); + return resp; + }, +}; \ No newline at end of file diff --git a/components/trengo/actions/send-a-message/send-a-message.mjs b/components/trengo/actions/send-a-message/send-a-message.mjs index f91922ad67cbc..c334e60498cf3 100644 --- a/components/trengo/actions/send-a-message/send-a-message.mjs +++ b/components/trengo/actions/send-a-message/send-a-message.mjs @@ -3,7 +3,7 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-send-a-message", - version: "0.0.2", + version: "0.0.3", name: "Send A Message", description: "This action can be used to easily send a message or an email without having to think about contacts or tickets, [See the docs](https://developers.trengo.com/reference/send-a-message-1)", props: { @@ -40,19 +40,45 @@ export default { "emailSubject", ], }, + createInternalNote: { + type: "boolean", + label: "Create Internal Note", + description: "Create an internal note instead of sending a message to the contact", + optional: true, + default: false, + }, }, async run ({ $ }) { - const resp = await this.app.sendMessage({ - $, - data: { - channel_id: this.channelId, - contact_identifier: this.contactIdentifier, - contact_name: this.contactName, - message: this.message, - email_subject: this.emailSubject, - }, - }); - $.export("$summary", "The message has been sent"); - return resp; + if (this.createInternalNote) { + // Create internal note instead of sending message + const resp = await this.app.createInternalNote({ + $, + data: { + note: this.message, + // Internal notes might need additional context + metadata: { + channel_id: this.channelId, + contact_identifier: this.contactIdentifier, + contact_name: this.contactName, + }, + }, + }); + $.export("$summary", "Internal note has been created"); + return resp; + } else { + // Send regular message + const resp = await this.app.sendMessage({ + $, + data: { + channel_id: this.channelId, + contact_identifier: this.contactIdentifier, + contact_name: this.contactName, + message: this.message, + email_subject: this.emailSubject, + }, + }); + $.export("$summary", "The message has been sent"); + return resp; + } }, }; diff --git a/components/trengo/package.json b/components/trengo/package.json index f5c320c6d33ab..34720ef0aaa66 100644 --- a/components/trengo/package.json +++ b/components/trengo/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/trengo", - "version": "0.1.0", + "version": "0.1.1", "description": "Pipedream Trengo Components", "main": "trengo.app.mjs", "keywords": [ diff --git a/components/trengo/trengo.app.mjs b/components/trengo/trengo.app.mjs index d7f4019a1e73b..b2d87e2460ea0 100644 --- a/components/trengo/trengo.app.mjs +++ b/components/trengo/trengo.app.mjs @@ -241,5 +241,12 @@ export default { ...args, }); }, + async createInternalNote(args = {}) { + return this._makeRequest({ + method: "POST", + path: "/tickets/notes", + ...args, + }); + }, }, };