From 9d0204cb776a61968889f9ecf22c806528f33017 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 24 Jul 2025 14:08:19 -0300 Subject: [PATCH 1/6] Trengo package + pnpm --- components/trengo/package.json | 2 +- pnpm-lock.yaml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/components/trengo/package.json b/components/trengo/package.json index f5c320c6d33ab..b3e33e32bbe30 100644 --- a/components/trengo/package.json +++ b/components/trengo/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/trengo", - "version": "0.1.0", + "version": "0.2.0", "description": "Pipedream Trengo Components", "main": "trengo.app.mjs", "keywords": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0e8944ef32c6e..5965c64ae75fa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4073,8 +4073,7 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/dynamic_content_snippet: - specifiers: {} + components/dynamic_content_snippet: {} components/dynamics_365_business_central_api: dependencies: From e4c0d03cfcd88e29c0be02f021d37100ae4f90f7 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 24 Jul 2025 15:12:12 -0300 Subject: [PATCH 2/6] Adding 'List Articles' action --- .../actions/list-articles/list-articles.mjs | 65 +++++++++++++++++++ components/trengo/trengo.app.mjs | 30 +++++++++ 2 files changed, 95 insertions(+) create mode 100644 components/trengo/actions/list-articles/list-articles.mjs diff --git a/components/trengo/actions/list-articles/list-articles.mjs b/components/trengo/actions/list-articles/list-articles.mjs new file mode 100644 index 0000000000000..dba8124a3d228 --- /dev/null +++ b/components/trengo/actions/list-articles/list-articles.mjs @@ -0,0 +1,65 @@ +import utils from "../../common/utils.mjs"; +import app from "../../trengo.app.mjs"; + +export default { + type: "action", + key: "trengo-list-articles", + version: "0.0.1", + name: "List Articles", + description: "List articles from a help center according to the specified criteria. [See the docs](https://developers.trengo.com/reference/list-all-articles)", + props: { + app, + helpCenterId: { + propDefinition: [ + app, + "helpCenterId", + ], + }, + localeCode: { + type: "string", + label: "Locale Code", + description: "The article's locale code", + optional: true, + default: "en", + }, + filter: { + type: "string", + label: "Filter", + description: "The article's filter. You can choose one of the available options, specify `untranslated_` for other language codes, or leave empty for all articles", + optional: true, + options: [ + "draft", + "published", + "untranslated_en", + ], + }, + term: { + type: "string", + label: "Search Term", + description: "The article's search term (if not specified, all articles will be returned)", + optional: true, + }, + }, + async run({ $ }) { + const articles = []; + const resourcesStream = utils.getResourcesStream({ + resourceFn: this.app.getArticles, + resourceFnArgs: { + helpCenterId: this.helpCenterId, + params: { + localeCode: this.localeCode, + filter: this.filter, + term: this.term, + }, + }, + }); + for await (const item of resourcesStream) { + articles.push(item); + } + const length = articles.length; + $.export("$summary", `Successfully retrieved ${length} article${length === 1 + ? "" + : "s"}`); + return articles; + }, +}; diff --git a/components/trengo/trengo.app.mjs b/components/trengo/trengo.app.mjs index d7f4019a1e73b..eb67b56b850d9 100644 --- a/components/trengo/trengo.app.mjs +++ b/components/trengo/trengo.app.mjs @@ -146,6 +146,22 @@ export default { description: "Search term to find a contact. If not given, all contacts will be returned.", optional: true, }, + helpCenterId: { + type: "integer", + label: "Help Center ID", + description: "Select a help center or provide an ID", + async options({ page = 0 }) { + const response = await this.getHelpCenters({ + params: { + page: page + 1, + }, + }); + return response.data.map((helpCenter) => ({ + label: helpCenter.name || helpCenter.slug, + value: helpCenter.id, + })); + }, + }, }, methods: { _getUrl(path) { @@ -241,5 +257,19 @@ export default { ...args, }); }, + async getHelpCenters(args = {}) { + return this._makeRequest({ + path: "/help_center", + ...args, + }); + }, + async getArticles({ + helpCenterId, ...args + } = {}) { + return this._makeRequest({ + path: `/help_center/${helpCenterId}/articles`, + ...args, + }); + }, }, }; From 387864b329005928cfbd85355d272ace086dbe6f Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 24 Jul 2025 15:26:12 -0300 Subject: [PATCH 3/6] Adding Ticket Closed and Ticket Reopened sources --- .../sources/ticket-closed/ticket-closed.mjs | 29 +++++++++++++++++++ .../ticket-reopened/ticket-reopened.mjs | 29 +++++++++++++++++++ components/trengo/trengo.app.mjs | 21 ++++++++++++-- 3 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 components/trengo/sources/ticket-closed/ticket-closed.mjs create mode 100644 components/trengo/sources/ticket-reopened/ticket-reopened.mjs diff --git a/components/trengo/sources/ticket-closed/ticket-closed.mjs b/components/trengo/sources/ticket-closed/ticket-closed.mjs new file mode 100644 index 0000000000000..2f006f9d6ff09 --- /dev/null +++ b/components/trengo/sources/ticket-closed/ticket-closed.mjs @@ -0,0 +1,29 @@ +import common from "../common/common.mjs"; + +export default { + key: "trengo-ticket-closed", + name: "Ticket Closed (Instant)", + description: "Emit new event when a ticket is closed. [See the documentation](https://developers.trengo.com/docs/webhooks)", + version: "0.0.1", + type: "source", + dedupe: "unique", + ...common, + methods: { + ...common.methods, + getMeta(event) { + const ts = Date.now(); + const id = event?.body?.ticket_id ? + parseInt(event.body.ticket_id) : + ts; + const summary = `Ticket closed: #${id} (Status: ${event?.body?.status})`; + return { + id, + ts, + summary, + }; + }, + getEvent() { + return "TICKET_CLOSED"; + }, + }, +}; diff --git a/components/trengo/sources/ticket-reopened/ticket-reopened.mjs b/components/trengo/sources/ticket-reopened/ticket-reopened.mjs new file mode 100644 index 0000000000000..3a9acef8317b3 --- /dev/null +++ b/components/trengo/sources/ticket-reopened/ticket-reopened.mjs @@ -0,0 +1,29 @@ +import common from "../common/common.mjs"; + +export default { + key: "trengo-ticket-reopened", + name: "Ticket Reopened (Instant)", + description: "Emit new event when a ticket is reopened. [See the documentation](https://developers.trengo.com/docs/webhooks)", + version: "0.0.1", + type: "source", + dedupe: "unique", + ...common, + methods: { + ...common.methods, + getMeta(event) { + const ts = Date.now(); + const id = event?.body?.ticket_id ? + parseInt(event.body.ticket_id) : + ts; + const summary = `Ticket reopened: #${id} (Status: ${event?.body?.status})`; + return { + id, + ts, + summary, + }; + }, + getEvent() { + return "TICKET_REOPENED"; + }, + }, +}; diff --git a/components/trengo/trengo.app.mjs b/components/trengo/trengo.app.mjs index eb67b56b850d9..b674cc5b15743 100644 --- a/components/trengo/trengo.app.mjs +++ b/components/trengo/trengo.app.mjs @@ -68,9 +68,20 @@ export default { description: "The WhatsApp template ID.", }, ticketId: { - type: "string", + type: "integer", label: "Ticket ID", - description: "The ticket ID. Only required if `Recipient Phone Number` is not set.", + description: "Select a ticket or provide an ID", + async options({ page = 0 }) { + const response = await this.getTickets({ + params: { + page: page + 1, + }, + }); + return response.data.map((ticket) => ({ + label: `#${ticket.ticket_id} - ${ticket.subject || "No subject"}`, + value: ticket.ticket_id, + })); + }, }, whatsappTemplateParamsKeys: { type: "string[]", @@ -271,5 +282,11 @@ export default { ...args, }); }, + async getTickets(args = {}) { + return this._makeRequest({ + path: "/tickets", + ...args, + }); + }, }, }; From 444de2c11793f7afe719c4fc92eabd0ec9b21fb7 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 24 Jul 2025 15:32:45 -0300 Subject: [PATCH 4/6] Adding 'maxResults' to List Articles --- .../trengo/actions/list-articles/list-articles.mjs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/trengo/actions/list-articles/list-articles.mjs b/components/trengo/actions/list-articles/list-articles.mjs index dba8124a3d228..588acca07fe4e 100644 --- a/components/trengo/actions/list-articles/list-articles.mjs +++ b/components/trengo/actions/list-articles/list-articles.mjs @@ -39,6 +39,12 @@ export default { description: "The article's search term (if not specified, all articles will be returned)", optional: true, }, + maxResults: { + type: "integer", + label: "Max Results", + description: "Maximum number of articles to return (if not specified, all results will be returned)", + optional: true, + }, }, async run({ $ }) { const articles = []; @@ -55,6 +61,9 @@ export default { }); for await (const item of resourcesStream) { articles.push(item); + if (this.maxResults && articles.length >= this.maxResults) { + break; + } } const length = articles.length; $.export("$summary", `Successfully retrieved ${length} article${length === 1 From 65de8ba3beaaed6ba7d70f4ab3abfa63ba83a4ed Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 24 Jul 2025 18:58:12 -0300 Subject: [PATCH 5/6] Version bumps --- components/trengo/actions/create-contact/create-contact.mjs | 2 +- components/trengo/actions/find-contacts/find-contacts.mjs | 2 +- components/trengo/actions/log-a-voice-call/log-a-voice-call.mjs | 2 +- components/trengo/actions/send-a-message/send-a-message.mjs | 2 +- .../send-a-team-chat-message/send-a-team-chat-message.mjs | 2 +- .../send-a-whatsapp-message-template.mjs | 2 +- .../trengo/sources/new-inbound-message/new-inbound-message.mjs | 2 +- .../trengo/sources/new-internal-note/new-internal-note.mjs | 2 +- .../sources/new-outbound-message/new-outbound-message.mjs | 2 +- components/trengo/sources/phone-call-ended/phone-call-ended.mjs | 2 +- .../trengo/sources/phone-call-missed/phone-call-missed.mjs | 2 +- .../trengo/sources/phone-call-started/phone-call-started.mjs | 2 +- .../trengo/sources/ticket-label-added/ticket-label-added.mjs | 2 +- .../trengo/sources/voice-call-recorded/voice-call-recorded.mjs | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/components/trengo/actions/create-contact/create-contact.mjs b/components/trengo/actions/create-contact/create-contact.mjs index a4f713cd29bdf..c09e721040204 100644 --- a/components/trengo/actions/create-contact/create-contact.mjs +++ b/components/trengo/actions/create-contact/create-contact.mjs @@ -3,7 +3,7 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-create-contact", - version: "0.0.2", + version: "0.0.3", name: "Create Contact", description: "Creates a contact. If a contact with given identifier already exists, returns it. [See the docs](https://developers.trengo.com/reference/create-update-a-user)", props: { diff --git a/components/trengo/actions/find-contacts/find-contacts.mjs b/components/trengo/actions/find-contacts/find-contacts.mjs index fca3ebb6dd6ea..682b9c55b1551 100644 --- a/components/trengo/actions/find-contacts/find-contacts.mjs +++ b/components/trengo/actions/find-contacts/find-contacts.mjs @@ -4,7 +4,7 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-find-contacts", - version: "0.0.2", + version: "0.0.3", name: "Find Contacts", description: "Finds contacts with the given term. [See the docs](https://developers.trengo.com/reference/as)", props: { diff --git a/components/trengo/actions/log-a-voice-call/log-a-voice-call.mjs b/components/trengo/actions/log-a-voice-call/log-a-voice-call.mjs index d20c39aca8bdb..cf684f71d6fb9 100644 --- a/components/trengo/actions/log-a-voice-call/log-a-voice-call.mjs +++ b/components/trengo/actions/log-a-voice-call/log-a-voice-call.mjs @@ -3,7 +3,7 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-log-a-voice-call", - version: "0.0.2", + version: "0.0.3", name: "Log A Voice Call", description: "Logs a phone call from external VOIP applications, [See the docs](https://developers.trengo.com/reference/log-a-phone-call)", props: { 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..0506170781b37 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: { diff --git a/components/trengo/actions/send-a-team-chat-message/send-a-team-chat-message.mjs b/components/trengo/actions/send-a-team-chat-message/send-a-team-chat-message.mjs index d940c98c51f24..a4a00520c2c7c 100644 --- a/components/trengo/actions/send-a-team-chat-message/send-a-team-chat-message.mjs +++ b/components/trengo/actions/send-a-team-chat-message/send-a-team-chat-message.mjs @@ -4,7 +4,7 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-send-a-team-chat-message", - version: "0.0.2", + version: "0.0.3", name: "Send A Team Chat Message", description: "Send a message as a bot in the Team Chat, [See the docs](https://developers.trengo.com/reference/sending-a-bot-message)", props: { diff --git a/components/trengo/actions/send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs b/components/trengo/actions/send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs index 9d06f4b7a0bc3..7112098eac0e3 100644 --- a/components/trengo/actions/send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs +++ b/components/trengo/actions/send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs @@ -4,7 +4,7 @@ import app from "../../trengo.app.mjs"; export default { type: "action", key: "trengo-send-a-whatsapp-message-template", - version: "0.0.2", + version: "0.0.3", name: "Send A WhatsApp Message Template", description: "Sends a WhatsApp message template, [See the docs](https://developers.trengo.com/reference/start-a-conversation)", props: { diff --git a/components/trengo/sources/new-inbound-message/new-inbound-message.mjs b/components/trengo/sources/new-inbound-message/new-inbound-message.mjs index ad69b07d7a180..d62e08ad53fe2 100644 --- a/components/trengo/sources/new-inbound-message/new-inbound-message.mjs +++ b/components/trengo/sources/new-inbound-message/new-inbound-message.mjs @@ -4,7 +4,7 @@ export default { key: "trengo-new-inbound-message", name: "New Inbound Message Event (Instant)", description: "Emit new events when an inbound message received. [See the docs here](https://developers.trengo.com/docs/webhooks)", - version: "0.0.2", + version: "0.0.3", type: "source", dedupe: "unique", ...common, diff --git a/components/trengo/sources/new-internal-note/new-internal-note.mjs b/components/trengo/sources/new-internal-note/new-internal-note.mjs index 2d24d257a07cf..5bd8e296682c3 100644 --- a/components/trengo/sources/new-internal-note/new-internal-note.mjs +++ b/components/trengo/sources/new-internal-note/new-internal-note.mjs @@ -4,7 +4,7 @@ export default { key: "trengo-new-internal-note", name: "New Internal Note Event (Instant)", description: "Emit new events when a internal note added. [See the docs here](https://developers.trengo.com/docs/webhooks)", - version: "0.0.2", + version: "0.0.3", type: "source", dedupe: "unique", ...common, diff --git a/components/trengo/sources/new-outbound-message/new-outbound-message.mjs b/components/trengo/sources/new-outbound-message/new-outbound-message.mjs index ea32eed86f23c..2f858d5265b26 100644 --- a/components/trengo/sources/new-outbound-message/new-outbound-message.mjs +++ b/components/trengo/sources/new-outbound-message/new-outbound-message.mjs @@ -4,7 +4,7 @@ export default { key: "trengo-new-outbound-message", name: "New Outbound Message Event (Instant)", description: "Emit new events when an outbound message sent. [See the docs here](https://developers.trengo.com/docs/webhooks)", - version: "0.0.2", + version: "0.0.3", type: "source", dedupe: "unique", ...common, diff --git a/components/trengo/sources/phone-call-ended/phone-call-ended.mjs b/components/trengo/sources/phone-call-ended/phone-call-ended.mjs index 5237f0ff0788a..bbc3e5698595b 100644 --- a/components/trengo/sources/phone-call-ended/phone-call-ended.mjs +++ b/components/trengo/sources/phone-call-ended/phone-call-ended.mjs @@ -4,7 +4,7 @@ export default { key: "trengo-phone-call-ended", name: "New Phone Call Ended Event (Instant)", description: "Emit new events when an phone call ended. [See the docs here](https://developers.trengo.com/docs/webhooks)", - version: "0.0.2", + version: "0.0.3", type: "source", dedupe: "unique", ...common, diff --git a/components/trengo/sources/phone-call-missed/phone-call-missed.mjs b/components/trengo/sources/phone-call-missed/phone-call-missed.mjs index 963a25d01815c..f4ba6ec69ffd3 100644 --- a/components/trengo/sources/phone-call-missed/phone-call-missed.mjs +++ b/components/trengo/sources/phone-call-missed/phone-call-missed.mjs @@ -4,7 +4,7 @@ export default { key: "trengo-phone-call-missed", name: "New Phone Call Missed Event (Instant)", description: "Emit new events when an phone call missed. [See the docs here](https://developers.trengo.com/docs/webhooks)", - version: "0.0.2", + version: "0.0.3", type: "source", dedupe: "unique", ...common, diff --git a/components/trengo/sources/phone-call-started/phone-call-started.mjs b/components/trengo/sources/phone-call-started/phone-call-started.mjs index f7def7a1b42f8..98ec31e967431 100644 --- a/components/trengo/sources/phone-call-started/phone-call-started.mjs +++ b/components/trengo/sources/phone-call-started/phone-call-started.mjs @@ -4,7 +4,7 @@ export default { key: "trengo-phone-call-started", name: "New Phone Call Started Event (Instant)", description: "Emit new events when an phone call started. [See the docs here](https://developers.trengo.com/docs/webhooks)", - version: "0.0.2", + version: "0.0.3", type: "source", dedupe: "unique", ...common, diff --git a/components/trengo/sources/ticket-label-added/ticket-label-added.mjs b/components/trengo/sources/ticket-label-added/ticket-label-added.mjs index 225af3fe5ad50..20c67ee00ccbf 100644 --- a/components/trengo/sources/ticket-label-added/ticket-label-added.mjs +++ b/components/trengo/sources/ticket-label-added/ticket-label-added.mjs @@ -4,7 +4,7 @@ export default { key: "trengo-ticket-label-added", name: "New Ticket Label Added Event (Instant)", description: "Emit new events when a ticket label added. [See the docs here](https://developers.trengo.com/docs/webhooks)", - version: "0.0.2", + version: "0.0.3", type: "source", dedupe: "unique", ...common, diff --git a/components/trengo/sources/voice-call-recorded/voice-call-recorded.mjs b/components/trengo/sources/voice-call-recorded/voice-call-recorded.mjs index 8033d408bb519..d8c527551322a 100644 --- a/components/trengo/sources/voice-call-recorded/voice-call-recorded.mjs +++ b/components/trengo/sources/voice-call-recorded/voice-call-recorded.mjs @@ -4,7 +4,7 @@ export default { key: "trengo-voice-call-recorded", name: "New Voice Call Recorded Event (Instant)", description: "Emit new events when a voice call is recorded. [See the docs here](https://developers.trengo.com/docs/webhooks)", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", ...common, From a59ff37ed82994a8941b119b9705d7c43fa9ad67 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 24 Jul 2025 19:12:43 -0300 Subject: [PATCH 6/6] Minor adjustments --- .../send-a-whatsapp-message-template.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/trengo/actions/send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs b/components/trengo/actions/send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs index 7112098eac0e3..daf120398aac3 100644 --- a/components/trengo/actions/send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs +++ b/components/trengo/actions/send-a-whatsapp-message-template/send-a-whatsapp-message-template.mjs @@ -45,7 +45,7 @@ export default { }, async run ({ $ }) { if (!this.recepientPhoneNumber && !this.ticketId) { - throw new ConfigurationError("Either `Receipent Phone Number` or `Ticket ID` should be set!"); + throw new ConfigurationError("Either `Recipient Phone Number` or `Ticket ID` should be set!"); } const params = []; if (this.whatsappTemplateParamsKeys && this.whatsappTemplateParamsValues) { @@ -65,7 +65,8 @@ export default { data: { recipient_phone_number: this.recepientPhoneNumber, hsm_id: this.hsmId, - ticket_id: this.ticketId, + // the docs specify this as string for some reason + ticket_id: this.ticketId?.toString?.() || this.ticketId, params, }, });