From 61b8e0d1607723c011b616ba9cd7ff71a7f60f51 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 16 Jul 2025 14:54:18 -0300 Subject: [PATCH 1/6] package version bump --- components/frontapp/package.json | 4 ++-- pnpm-lock.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/frontapp/package.json b/components/frontapp/package.json index f46650a4cda8d..d5e3ca9658284 100644 --- a/components/frontapp/package.json +++ b/components/frontapp/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/frontapp", - "version": "0.6.0", + "version": "0.7.0", "description": "Pipedream Frontapp Components", "main": "frontapp.app.mjs", "keywords": [ @@ -10,7 +10,7 @@ "homepage": "https://pipedream.com/apps/frontapp", "author": "Pipedream (https://pipedream.com/)", "dependencies": { - "@pipedream/platform": "^3.0.3", + "@pipedream/platform": "^3.1.0", "form-data": "^4.0.0" }, "gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a51461c5c41ce..360fbea544711 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5068,8 +5068,8 @@ importers: components/frontapp: dependencies: '@pipedream/platform': - specifier: ^3.0.3 - version: 3.0.3 + specifier: ^3.1.0 + version: 3.1.0 form-data: specifier: ^4.0.0 version: 4.0.1 From 99f6ccf8be6c392531de486cd0aec2454c45ed73 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 16 Jul 2025 19:57:15 -0300 Subject: [PATCH 2/6] Adding new actions and adjusting minor things --- .../actions/create-inbox/create-inbox.mjs | 47 ++++++++ .../create-message-template.mjs | 109 ++++++++++++++++++ .../delete-message-template.mjs | 33 ++++++ .../actions/import-message/import-message.mjs | 2 +- .../list-message-templates.mjs | 55 +++++++++ .../receive-custom-messages.mjs | 4 +- .../reply-to-conversation.mjs | 4 +- .../send-new-message/send-new-message.mjs | 4 +- .../update-conversation.mjs | 4 +- .../update-teammate/update-teammate.mjs | 77 +++++++++++++ components/frontapp/frontapp.app.mjs | 79 +++++++++++++ .../new-conversation-state-change.mjs | 6 +- 12 files changed, 412 insertions(+), 12 deletions(-) create mode 100644 components/frontapp/actions/create-inbox/create-inbox.mjs create mode 100644 components/frontapp/actions/create-message-template/create-message-template.mjs create mode 100644 components/frontapp/actions/delete-message-template/delete-message-template.mjs create mode 100644 components/frontapp/actions/list-message-templates/list-message-templates.mjs create mode 100644 components/frontapp/actions/update-teammate/update-teammate.mjs diff --git a/components/frontapp/actions/create-inbox/create-inbox.mjs b/components/frontapp/actions/create-inbox/create-inbox.mjs new file mode 100644 index 0000000000000..719e2705bbf36 --- /dev/null +++ b/components/frontapp/actions/create-inbox/create-inbox.mjs @@ -0,0 +1,47 @@ +import frontApp from "../../frontapp.app.mjs"; + +export default { + key: "frontapp-create-inbox", + name: "Create Inbox", + description: "Create an inbox in the default team (workspace). [See the documentation](https://dev.frontapp.com/reference/create-inbox).", + version: "0.0.1", + type: "action", + props: { + frontApp, + name: { + type: "string", + label: "Name", + description: "The name of the inbox", + }, + teammateIds: { + type: "string[]", + label: "Teammate IDs", + description: "An array of teammate IDs that should have access to the inbox. Alternatively, you can supply teammate emails as a resource alias.", + propDefinition: [ + frontApp, + "teammateId", + ], + optional: true, + }, + }, + async run({ $ }) { + const { + frontApp, + name, + teammateIds, + } = this; + + const data = { + name, + teammate_ids: teammateIds, + }; + + const response = await frontApp.createInbox({ + data, + $, + }); + + $.export("$summary", `Successfully created inbox "${name}"`); + return response; + }, +}; diff --git a/components/frontapp/actions/create-message-template/create-message-template.mjs b/components/frontapp/actions/create-message-template/create-message-template.mjs new file mode 100644 index 0000000000000..846a369542e1a --- /dev/null +++ b/components/frontapp/actions/create-message-template/create-message-template.mjs @@ -0,0 +1,109 @@ +import FormData from "form-data"; +import { getFileStreamAndMetadata } from "@pipedream/platform"; +import frontApp from "../../frontapp.app.mjs"; + +export default { + key: "frontapp-create-message-template", + name: "Create Message Template", + description: "Create a new message template. [See the documentation](https://dev.frontapp.com/reference/create-message-template).", + version: "0.0.1", + type: "action", + props: { + frontApp, + name: { + type: "string", + label: "Name", + description: "Name of the message template", + }, + subject: { + type: "string", + label: "Subject", + description: "Subject of the message template", + optional: true, + }, + body: { + type: "string", + label: "Body", + description: "Body of the message template. You can supply HTML with inline CSS to structure and style your template.", + }, + folderId: { + propDefinition: [ + frontApp, + "folderId", + ], + description: "ID of the message template folder to place this message template in", + }, + inboxIds: { + type: "string[]", + label: "Inbox IDs", + description: "The specific inboxes this template is available in. If not specified, it will be available in all inboxes.", + propDefinition: [ + frontApp, + "inboxId", + ], + optional: true, + }, + attachments: { + propDefinition: [ + frontApp, + "attachments", + ], + }, + }, + async run({ $ }) { + const { + frontApp, + name, + subject, + body, + folderId, + inboxIds, + attachments, + } = this; + + let data, headers = {}; + + // Handle attachments if provided + if (attachments && attachments.length > 0) { + const formData = new FormData(); + + formData.append("name", name); + formData.append("body", body); + formData.append("subject", subject); + formData.append("folder_id", folderId); + formData.append("inbox_ids", inboxIds); + + for (const attachment of attachments) { + const { + stream, metadata, + } = await getFileStreamAndMetadata(attachment); + formData.append("attachments", stream, { + contentType: metadata.contentType, + knownLength: metadata.size, + filename: metadata.name, + }); + } + + data = formData; + headers = formData.getHeaders(); + } else { + // Simple JSON request without attachments + data = { + name, + subject, + body, + folder_id: folderId, + inbox_ids: inboxIds, + }; + } + + const response = await frontApp.createMessageTemplate({ + data, + headers, + $, + }); + + $.export("$summary", `Successfully created message template "${name}"`); + return response; + }, +}; diff --git a/components/frontapp/actions/delete-message-template/delete-message-template.mjs b/components/frontapp/actions/delete-message-template/delete-message-template.mjs new file mode 100644 index 0000000000000..2a9c28d53a5a6 --- /dev/null +++ b/components/frontapp/actions/delete-message-template/delete-message-template.mjs @@ -0,0 +1,33 @@ +import frontApp from "../../frontapp.app.mjs"; + +export default { + key: "frontapp-delete-message-template", + name: "Delete Message Template", + description: "Delete a message template. [See the documentation](https://dev.frontapp.com/reference/delete-message-template).", + version: "0.0.1", + type: "action", + props: { + frontApp, + messageTemplateId: { + propDefinition: [ + frontApp, + "messageTemplateId", + ], + description: "The message template ID", + }, + }, + async run({ $ }) { + const { + frontApp, + messageTemplateId, + } = this; + + const response = await frontApp.deleteMessageTemplate({ + messageTemplateId, + $, + }); + + $.export("$summary", `Successfully deleted message template ${messageTemplateId}`); + return response; + }, +}; diff --git a/components/frontapp/actions/import-message/import-message.mjs b/components/frontapp/actions/import-message/import-message.mjs index 7d21b63cac714..1fbe1be872a1e 100644 --- a/components/frontapp/actions/import-message/import-message.mjs +++ b/components/frontapp/actions/import-message/import-message.mjs @@ -4,7 +4,7 @@ import frontApp from "../../frontapp.app.mjs"; export default { key: "frontapp-import-message", name: "Import Message", - description: "Appends a new message into an inbox. [See the docs here](https://dev.frontapp.com/reference/import-inbox-message).", + description: "Appends a new message into an inbox. [See the documentation](https://dev.frontapp.com/reference/import-inbox-message).", version: "0.1.7", type: "action", props: { diff --git a/components/frontapp/actions/list-message-templates/list-message-templates.mjs b/components/frontapp/actions/list-message-templates/list-message-templates.mjs new file mode 100644 index 0000000000000..451340b548a54 --- /dev/null +++ b/components/frontapp/actions/list-message-templates/list-message-templates.mjs @@ -0,0 +1,55 @@ +import frontApp from "../../frontapp.app.mjs"; + +export default { + key: "frontapp-list-message-templates", + name: "List Message Templates", + description: "List the message templates. [See the documentation](https://dev.frontapp.com/reference/list-message-templates).", + version: "0.0.1", + type: "action", + props: { + frontApp, + sortBy: { + type: "string", + label: "Sort By", + description: "Field used to sort the message templates.", + options: [ + "created_at", + "updated_at", + "sort_order", + ], + optional: true, + }, + sortOrder: { + type: "string", + label: "Sort Order", + description: "Order by which results should be sorted", + options: [ + "asc", + "desc", + ], + optional: true, + }, + }, + async run({ $ }) { + const { + frontApp, + sortBy, + sortOrder, + } = this; + + const params = {}; + + if (sortBy) params.sort_by = sortBy; + if (sortOrder) params.sort_order = sortOrder; + + const response = await frontApp.listMessageTemplates({ + params, + $, + }); + + const templates = response._results || []; + $.export("$summary", `Successfully retrieved ${templates.length} message template(s)`); + + return response; + }, +}; diff --git a/components/frontapp/actions/receive-custom-messages/receive-custom-messages.mjs b/components/frontapp/actions/receive-custom-messages/receive-custom-messages.mjs index 294c0d1df55d6..bf25964f07d41 100644 --- a/components/frontapp/actions/receive-custom-messages/receive-custom-messages.mjs +++ b/components/frontapp/actions/receive-custom-messages/receive-custom-messages.mjs @@ -4,8 +4,8 @@ import frontApp from "../../frontapp.app.mjs"; export default { key: "frontapp-receive-custom-messages", name: "Receive Custom Messages", - description: "Receive a custom message in Front. [See the docs here](https://dev.frontapp.com/reference/post_channels-channel-id-incoming-messages).", - version: "0.0.4", + description: "Receive a custom message in Front. [See the documentation](https://dev.frontapp.com/reference/post_channels-channel-id-incoming-messages).", + version: "0.0.5", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/reply-to-conversation/reply-to-conversation.mjs b/components/frontapp/actions/reply-to-conversation/reply-to-conversation.mjs index 4f227cc4cc884..2f74ec08aea07 100644 --- a/components/frontapp/actions/reply-to-conversation/reply-to-conversation.mjs +++ b/components/frontapp/actions/reply-to-conversation/reply-to-conversation.mjs @@ -4,8 +4,8 @@ import frontApp from "../../frontapp.app.mjs"; export default { key: "frontapp-reply-to-conversation", name: "Reply To Conversation", - description: "Reply to a conversation by sending a message and appending it to the conversation. [See the docs here](https://dev.frontapp.com/reference/post_conversations-conversation-id-messages).", - version: "0.0.3", + description: "Reply to a conversation by sending a message and appending it to the conversation. [See the documentation](https://dev.frontapp.com/reference/post_conversations-conversation-id-messages).", + version: "0.0.4", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/send-new-message/send-new-message.mjs b/components/frontapp/actions/send-new-message/send-new-message.mjs index 748f86e65af4e..3cd9234f34c60 100644 --- a/components/frontapp/actions/send-new-message/send-new-message.mjs +++ b/components/frontapp/actions/send-new-message/send-new-message.mjs @@ -4,8 +4,8 @@ import frontApp from "../../frontapp.app.mjs"; export default { key: "frontapp-send-new-message", name: "Send New Message", - description: "Sends a new message from a channel. It will create a new conversation. [See the docs here](https://dev.frontapp.com/reference/post_channels-channel-id-messages).", - version: "0.2.6", + description: "Sends a new message from a channel. It will create a new conversation. [See the documentation](https://dev.frontapp.com/reference/post_channels-channel-id-messages).", + version: "0.2.7", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/update-conversation/update-conversation.mjs b/components/frontapp/actions/update-conversation/update-conversation.mjs index 4d69740438a6a..99206fca0bbf9 100644 --- a/components/frontapp/actions/update-conversation/update-conversation.mjs +++ b/components/frontapp/actions/update-conversation/update-conversation.mjs @@ -4,8 +4,8 @@ import frontApp from "../../frontapp.app.mjs"; export default { key: "frontapp-update-conversation", name: "Update Conversation", - description: "Updates a conversation. [See the docs here](https://dev.frontapp.com/reference/patch_conversations-conversation-id).", - version: "0.1.6", + description: "Updates a conversation. [See the documentation](https://dev.frontapp.com/reference/patch_conversations-conversation-id).", + version: "0.1.7", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/update-teammate/update-teammate.mjs b/components/frontapp/actions/update-teammate/update-teammate.mjs new file mode 100644 index 0000000000000..10983f0890f59 --- /dev/null +++ b/components/frontapp/actions/update-teammate/update-teammate.mjs @@ -0,0 +1,77 @@ +import frontApp from "../../frontapp.app.mjs"; + +export default { + key: "frontapp-update-teammate", + name: "Update Teammate", + description: "Update a teammate. [See the documentation](https://dev.frontapp.com/reference/update-teammate).", + version: "0.0.1", + type: "action", + props: { + frontApp, + teammateId: { + propDefinition: [ + frontApp, + "teammateId", + ], + description: "The teammate ID. Alternatively, you can supply an email as a resource alias", + }, + username: { + type: "string", + label: "Username", + description: "New username. It must be unique and can only contains lowercase letters, numbers and underscores", + optional: true, + }, + firstName: { + type: "string", + label: "First Name", + description: "New first name", + optional: true, + }, + lastName: { + type: "string", + label: "Last Name", + description: "New last name", + optional: true, + }, + isAvailable: { + type: "boolean", + label: "Is Available", + description: "New availability status", + optional: true, + }, + customFields: { + type: "object", + label: "Custom Fields", + description: "Custom fields for this teammate. If included, all current custom fields will be replaced with the object supplied here", + optional: true, + }, + }, + async run({ $ }) { + const { + frontApp, + teammateId, + username, + firstName, + lastName, + isAvailable, + customFields, + } = this; + + const data = { + username, + first_name: firstName, + last_name: lastName, + is_available: isAvailable, + custom_fields: customFields, + }; + + const response = await frontApp.updateTeammate({ + teammateId, + data, + $, + }); + + $.export("$summary", `Successfully updated teammate ${teammateId}`); + return response; + }, +}; diff --git a/components/frontapp/frontapp.app.mjs b/components/frontapp/frontapp.app.mjs index 8d3f031c4db91..d9fecde8b629b 100644 --- a/components/frontapp/frontapp.app.mjs +++ b/components/frontapp/frontapp.app.mjs @@ -273,6 +273,41 @@ export default { default: 100, optional: true, }, + messageTemplateId: { + type: "string", + label: "Message Template ID", + description: "The message template ID", + async options({ prevContext }) { + return this.paginateOptions({ + prevContext, + listResourcesFn: this.listMessageTemplates, + mapper: ({ + id, name, + }) => ({ + label: name, + value: id, + }), + }); + }, + }, + folderId: { + type: "string", + label: "Folder ID", + description: "ID of the message template folder", + async options({ prevContext }) { + return this.paginateOptions({ + prevContext, + listResourcesFn: this.listMessageTemplateFolders, + mapper: ({ + id, name, + }) => ({ + label: name, + value: id, + }), + }); + }, + optional: true, + }, }, methods: { getUrl(path, url) { @@ -510,6 +545,50 @@ export default { ...args, }); }, + async listMessageTemplates(args = {}) { + return this.makeRequest({ + path: "/message_templates", + ...args, + }); + }, + async listMessageTemplateFolders(args = {}) { + return this.makeRequest({ + path: "/message_template_folders", + ...args, + }); + }, + async updateTeammate({ + teammateId, ...args + } = {}) { + return this.makeRequest({ + method: "patch", + path: `/teammates/${teammateId}`, + ...args, + }); + }, + async createInbox(args = {}) { + return this.makeRequest({ + method: "post", + path: "/inboxes", + ...args, + }); + }, + async createMessageTemplate(args = {}) { + return this.makeRequest({ + method: "post", + path: "/message_templates", + ...args, + }); + }, + async deleteMessageTemplate({ + messageTemplateId, ...args + } = {}) { + return this.makeRequest({ + method: "delete", + path: `/message_templates/${messageTemplateId}`, + ...args, + }); + }, async paginateOptions({ prevContext, listResourcesFn, diff --git a/components/frontapp/sources/new-conversation-state-change/new-conversation-state-change.mjs b/components/frontapp/sources/new-conversation-state-change/new-conversation-state-change.mjs index edc90a1610223..549e0814361e2 100644 --- a/components/frontapp/sources/new-conversation-state-change/new-conversation-state-change.mjs +++ b/components/frontapp/sources/new-conversation-state-change/new-conversation-state-change.mjs @@ -6,8 +6,8 @@ export default { ...common, key: "frontapp-new-conversation-state-change", name: "New Conversation State Change", - description: "Emit new event when a conversation reaches a specific state. [See the docs](https://dev.frontapp.com/reference/list-conversations)", - version: "0.0.2", + description: "Emit new event when a conversation reaches a specific state. [See the documentation](https://dev.frontapp.com/reference/list-conversations)", + version: "0.0.3", type: "source", dedupe: "unique", props: { @@ -15,7 +15,7 @@ export default { types: { type: "string[]", label: "States to Listen For", - description: "Trigger a workflow when a conversation reaches any of these states. [See the docs](https://dev.frontapp.com/reference/list-conversations) for more detail.", + description: "Trigger a workflow when a conversation reaches any of these states. [See the documentation](https://dev.frontapp.com/reference/list-conversations) for more detail.", options: utils.TYPES_OPTIONS, }, }, From 97c7644db62232e46aea76a5f60287010640dc0f Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 17 Jul 2025 17:02:30 -0300 Subject: [PATCH 3/6] Description improvements --- .../actions/create-inbox/create-inbox.mjs | 6 ++-- .../create-message-template.mjs | 6 ++-- .../delete-message-template.mjs | 2 +- .../actions/import-message/import-message.mjs | 2 +- .../list-message-templates.mjs | 28 +++++++++++-------- .../update-teammate/update-teammate.mjs | 2 +- 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/components/frontapp/actions/create-inbox/create-inbox.mjs b/components/frontapp/actions/create-inbox/create-inbox.mjs index 719e2705bbf36..356f99096c389 100644 --- a/components/frontapp/actions/create-inbox/create-inbox.mjs +++ b/components/frontapp/actions/create-inbox/create-inbox.mjs @@ -14,13 +14,13 @@ export default { description: "The name of the inbox", }, teammateIds: { - type: "string[]", - label: "Teammate IDs", - description: "An array of teammate IDs that should have access to the inbox. Alternatively, you can supply teammate emails as a resource alias.", propDefinition: [ frontApp, "teammateId", ], + type: "string[]", + label: "Teammate IDs", + description: "One or more IDs of teammates that should have access to the inbox", optional: true, }, }, diff --git a/components/frontapp/actions/create-message-template/create-message-template.mjs b/components/frontapp/actions/create-message-template/create-message-template.mjs index 846a369542e1a..914b8297e4547 100644 --- a/components/frontapp/actions/create-message-template/create-message-template.mjs +++ b/components/frontapp/actions/create-message-template/create-message-template.mjs @@ -24,7 +24,7 @@ export default { body: { type: "string", label: "Body", - description: "Body of the message template. You can supply HTML with inline CSS to structure and style your template.", + description: "Body of the message template. You can supply HTML with inline CSS to structure and style your template", }, folderId: { propDefinition: [ @@ -36,7 +36,7 @@ export default { inboxIds: { type: "string[]", label: "Inbox IDs", - description: "The specific inboxes this template is available in. If not specified, it will be available in all inboxes.", + description: "The specific inboxes this template is available in. If not specified, it will be available in all inboxes", propDefinition: [ frontApp, "inboxId", @@ -64,7 +64,7 @@ export default { let data, headers = {}; // Handle attachments if provided - if (attachments && attachments.length > 0) { + if (attachments?.length > 0) { const formData = new FormData(); formData.append("name", name); diff --git a/components/frontapp/actions/delete-message-template/delete-message-template.mjs b/components/frontapp/actions/delete-message-template/delete-message-template.mjs index 2a9c28d53a5a6..2c0b20477e032 100644 --- a/components/frontapp/actions/delete-message-template/delete-message-template.mjs +++ b/components/frontapp/actions/delete-message-template/delete-message-template.mjs @@ -13,7 +13,7 @@ export default { frontApp, "messageTemplateId", ], - description: "The message template ID", + description: "ID of the message template to delete", }, }, async run({ $ }) { diff --git a/components/frontapp/actions/import-message/import-message.mjs b/components/frontapp/actions/import-message/import-message.mjs index 1fbe1be872a1e..042ff683a122c 100644 --- a/components/frontapp/actions/import-message/import-message.mjs +++ b/components/frontapp/actions/import-message/import-message.mjs @@ -5,7 +5,7 @@ export default { key: "frontapp-import-message", name: "Import Message", description: "Appends a new message into an inbox. [See the documentation](https://dev.frontapp.com/reference/import-inbox-message).", - version: "0.1.7", + version: "0.1.8", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/list-message-templates/list-message-templates.mjs b/components/frontapp/actions/list-message-templates/list-message-templates.mjs index 451340b548a54..e7bdd8db7904c 100644 --- a/components/frontapp/actions/list-message-templates/list-message-templates.mjs +++ b/components/frontapp/actions/list-message-templates/list-message-templates.mjs @@ -11,11 +11,10 @@ export default { sortBy: { type: "string", label: "Sort By", - description: "Field used to sort the message templates.", + description: "Field used to sort the message templates", options: [ "created_at", "updated_at", - "sort_order", ], optional: true, }, @@ -24,8 +23,14 @@ export default { label: "Sort Order", description: "Order by which results should be sorted", options: [ - "asc", - "desc", + { + label: "Ascending", + value: "asc", + }, + { + label: "Descending", + value: "desc", + }, ], optional: true, }, @@ -37,18 +42,19 @@ export default { sortOrder, } = this; - const params = {}; - - if (sortBy) params.sort_by = sortBy; - if (sortOrder) params.sort_order = sortOrder; - const response = await frontApp.listMessageTemplates({ - params, $, + params: { + sort_by: sortBy, + sort_order: sortOrder, + }, }); const templates = response._results || []; - $.export("$summary", `Successfully retrieved ${templates.length} message template(s)`); + const length = templates.length; + $.export("$summary", `Successfully retrieved ${length} message template${length === 1 + ? "" + : "s"}`); return response; }, diff --git a/components/frontapp/actions/update-teammate/update-teammate.mjs b/components/frontapp/actions/update-teammate/update-teammate.mjs index 10983f0890f59..c2c7ea33bf167 100644 --- a/components/frontapp/actions/update-teammate/update-teammate.mjs +++ b/components/frontapp/actions/update-teammate/update-teammate.mjs @@ -13,7 +13,7 @@ export default { frontApp, "teammateId", ], - description: "The teammate ID. Alternatively, you can supply an email as a resource alias", + description: "ID of the teammate to update", }, username: { type: "string", From 25bc805fc750dd0cc23e7d874bd49ff91d0d6d52 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 17 Jul 2025 19:45:48 -0300 Subject: [PATCH 4/6] Adding sources --- .../frontapp/sources/common/polling-ids.mjs | 55 +++++++++++ .../new-conversation-created.mjs | 36 +++++++ .../new-conversation-created/test-event.mjs | 96 +++++++++++++++++++ .../new-message-template-created.mjs | 36 +++++++ .../test-event.mjs | 56 +++++++++++ 5 files changed, 279 insertions(+) create mode 100644 components/frontapp/sources/common/polling-ids.mjs create mode 100644 components/frontapp/sources/new-conversation-created/new-conversation-created.mjs create mode 100644 components/frontapp/sources/new-conversation-created/test-event.mjs create mode 100644 components/frontapp/sources/new-message-template-created/new-message-template-created.mjs create mode 100644 components/frontapp/sources/new-message-template-created/test-event.mjs diff --git a/components/frontapp/sources/common/polling-ids.mjs b/components/frontapp/sources/common/polling-ids.mjs new file mode 100644 index 0000000000000..bbfd443fd25dd --- /dev/null +++ b/components/frontapp/sources/common/polling-ids.mjs @@ -0,0 +1,55 @@ +import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; +import frontapp from "../../frontapp.app.mjs"; + +export default { + props: { + frontapp, + db: "$.service.db", + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, + }, + }, + }, + methods: { + _getSavedIds() { + return this.db.get("savedIds") || []; + }, + _setSavedIds(ids) { + this.db.set("savedIds", ids); + }, + async startEvent(maxItems) { + const savedIds = this._getSavedIds(); + const items = await this.getItems(savedIds); + + const newIds = []; + for (const item of items) { + const id = this.getItemId(item); + if (!savedIds.includes(id)) { + const meta = this.generateMeta(item); + if (maxItems === undefined || (typeof maxItems === "number" && --maxItems >= 0)) { + this.$emit(item, meta); + } + newIds.push(id); + } + } + + if (newIds.length > 0) { + const ids = [ + ...savedIds, + ...newIds, + ].slice(-100); + this._setSavedIds(ids); + } + }, + }, + async run() { + await this.startEvent(); + }, + hooks: { + async deploy() { + await this.startEvent(5); + }, + }, +}; diff --git a/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs b/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs new file mode 100644 index 0000000000000..18cfe1327f2c3 --- /dev/null +++ b/components/frontapp/sources/new-conversation-created/new-conversation-created.mjs @@ -0,0 +1,36 @@ +import common from "../common/polling-ids.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "frontapp-new-conversation-created", + name: "New Conversation Created", + description: "Emit new event when a conversation is created. [See the documentation](https://dev.frontapp.com/reference/list-conversations)", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + generateMeta(conversation) { + return { + id: conversation.id, + summary: `New conversation created: ${conversation.subject}`, + ts: conversation.created_at * 1000, + }; + }, + getItemId(conversation) { + return conversation.id; + }, + async getItems() { + const response = await this.frontapp.listConversations({ + params: { + sort_by: "date", + sort_order: "desc", + }, + }); + + return response._results || []; + }, + }, + sampleEmit, +}; diff --git a/components/frontapp/sources/new-conversation-created/test-event.mjs b/components/frontapp/sources/new-conversation-created/test-event.mjs new file mode 100644 index 0000000000000..0da0e3a74c5db --- /dev/null +++ b/components/frontapp/sources/new-conversation-created/test-event.mjs @@ -0,0 +1,96 @@ +export default { + "_links": { + "self": "string", + "related": { + "events": "string", + "followers": "string", + "messages": "string", + "comments": "string", + "inboxes": "string", + "last_message": "string" + } + }, + "id": "cnv_123abc", + "subject": "New conversation subject", + "status": "open", + "assignee": { + "_links": { + "self": "string", + "related": { + "inboxes": "string", + "conversations": "string" + } + }, + "id": "tea_123abc", + "email": "teammate@example.com", + "username": "teammate", + "first_name": "John", + "last_name": "Doe", + "is_admin": false, + "is_available": true, + "is_blocked": false, + "custom_fields": {} + }, + "recipient": { + "_links": { + "related": { + "contact": "string" + } + }, + "name": "Customer Name", + "handle": "customer@example.com", + "role": "from" + }, + "tags": [ + { + "_links": { + "self": "string", + "related": { + "conversations": "string", + "owner": "string", + "children": "string" + } + }, + "id": "tag_123abc", + "name": "urgent", + "description": "Urgent conversations", + "highlight": "red", + "is_private": false, + "is_visible_in_conversation_lists": true, + "created_at": 1640995200, + "updated_at": 1640995200 + } + ], + "links": [ + { + "_links": { + "self": "string" + }, + "id": "link_123abc", + "name": "Related Ticket", + "type": "string", + "external_url": "https://example.com/ticket/123", + "custom_fields": {} + } + ], + "custom_fields": {}, + "created_at": 1640995200, + "is_private": false, + "scheduled_reminders": [ + { + "_links": { + "related": { + "owner": "string" + } + }, + "created_at": 1640995200, + "scheduled_at": 1641081600, + "updated_at": 1640995200 + } + ], + "metadata": { + "external_conversation_ids": [ + "external_123" + ] + } +}; \ No newline at end of file diff --git a/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs b/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs new file mode 100644 index 0000000000000..6d8a28ed94f47 --- /dev/null +++ b/components/frontapp/sources/new-message-template-created/new-message-template-created.mjs @@ -0,0 +1,36 @@ +import common from "../common/polling-ids.mjs"; +import sampleEmit from "./test-event.mjs"; + +export default { + ...common, + key: "frontapp-new-message-template-created", + name: "New Message Template Created", + description: "Emit new event when a message template is created. [See the documentation](https://dev.frontapp.com/reference/list-message-templates)", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + generateMeta(template) { + return { + id: template.id, + summary: `New message template created: ${template.name}`, + ts: template.created_at * 1000, + }; + }, + getItemId(template) { + return template.id; + }, + async getItems() { + const response = await this.frontapp.listMessageTemplates({ + params: { + sort_by: "created_at", + sort_order: "desc", + }, + }); + + return response._results || []; + }, + }, + sampleEmit, +}; diff --git a/components/frontapp/sources/new-message-template-created/test-event.mjs b/components/frontapp/sources/new-message-template-created/test-event.mjs new file mode 100644 index 0000000000000..8ee6c9cac0632 --- /dev/null +++ b/components/frontapp/sources/new-message-template-created/test-event.mjs @@ -0,0 +1,56 @@ +export default { + "_links": { + "self": "string", + "related": { + "folder": "string", + "inboxes": "string" + } + }, + "id": "tpl_123abc", + "name": "Welcome Email Template", + "subject": "Welcome to our service!", + "body": "

Welcome to our service! We're excited to have you on board.

Best regards,
The Team

", + "folder_id": "fol_123abc", + "inbox_ids": [ + "inb_123abc", + "inb_456def" + ], + "attachments": [ + { + "filename": "welcome-guide.pdf", + "url": "string", + "content_type": "application/pdf", + "size": 1024000 + } + ], + "created_at": 1640995200, + "updated_at": 1640995200, + "is_available_for_all_inboxes": false, + "folder": { + "_links": { + "self": "string", + "related": { + "owner": "string" + } + }, + "id": "fol_123abc", + "name": "Customer Onboarding", + "description": "Templates for customer onboarding process" + }, + "inboxes": [ + { + "_links": { + "self": "string", + "related": { + "conversations": "string", + "teammates": "string", + "channels": "string", + "owner": "string" + } + }, + "id": "inb_123abc", + "name": "Support Inbox", + "is_private": false + } + ] +}; \ No newline at end of file From 10ae11be54241087ff8444b48625e39210bed2ce Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 17 Jul 2025 20:02:26 -0300 Subject: [PATCH 5/6] Version bumps --- components/frontapp/actions/add-comment/add-comment.mjs | 2 +- .../actions/archive-conversation/archive-conversation.mjs | 2 +- .../actions/assign-conversation/assign-conversation.mjs | 2 +- .../frontapp/actions/create-draft-reply/create-draft-reply.mjs | 2 +- components/frontapp/actions/create-draft/create-draft.mjs | 2 +- components/frontapp/actions/get-comment/get-comment.mjs | 2 +- components/frontapp/actions/get-teammate/get-teammate.mjs | 2 +- .../actions/list-comment-mentions/list-comment-mentions.mjs | 2 +- components/frontapp/actions/list-comments/list-comments.mjs | 2 +- .../frontapp/actions/list-conversations/list-conversations.mjs | 2 +- components/frontapp/actions/list-teammates/list-teammates.mjs | 2 +- .../frontapp/actions/tag-conversation/tag-conversation.mjs | 2 +- .../sources/new-conversation-tag/new-conversation-tag.mjs | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/components/frontapp/actions/add-comment/add-comment.mjs b/components/frontapp/actions/add-comment/add-comment.mjs index 399742563e934..72e214fe8840f 100644 --- a/components/frontapp/actions/add-comment/add-comment.mjs +++ b/components/frontapp/actions/add-comment/add-comment.mjs @@ -5,7 +5,7 @@ export default { key: "frontapp-add-comment", name: "Add Comment", description: "Add a comment to a conversation. [See the documentation](https://dev.frontapp.com/reference/add-comment)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/archive-conversation/archive-conversation.mjs b/components/frontapp/actions/archive-conversation/archive-conversation.mjs index ea17d398d66b3..e5d3f85ac5c61 100644 --- a/components/frontapp/actions/archive-conversation/archive-conversation.mjs +++ b/components/frontapp/actions/archive-conversation/archive-conversation.mjs @@ -4,7 +4,7 @@ export default { key: "frontapp-archive-conversation", name: "Archive Conversation", description: "Archives a conversation. [See the documentation](https://dev.frontapp.com/reference/patch_conversations-conversation-id)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/assign-conversation/assign-conversation.mjs b/components/frontapp/actions/assign-conversation/assign-conversation.mjs index 2332fa1c45639..e2229f8c4d79f 100644 --- a/components/frontapp/actions/assign-conversation/assign-conversation.mjs +++ b/components/frontapp/actions/assign-conversation/assign-conversation.mjs @@ -4,7 +4,7 @@ export default { key: "frontapp-assign-conversation", name: "Assign Conversation", description: "Assign or unassign a conversation. [See the documentation](https://dev.frontapp.com/reference/update-conversation-assignee)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/create-draft-reply/create-draft-reply.mjs b/components/frontapp/actions/create-draft-reply/create-draft-reply.mjs index 56fa9c241505a..5a1da95bcb01e 100644 --- a/components/frontapp/actions/create-draft-reply/create-draft-reply.mjs +++ b/components/frontapp/actions/create-draft-reply/create-draft-reply.mjs @@ -5,7 +5,7 @@ export default { key: "frontapp-create-draft-reply", name: "Create Draft Reply", description: "Create a new draft as a reply to the last message in the conversation. [See the documentation](https://dev.frontapp.com/reference/create-draft-reply)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/create-draft/create-draft.mjs b/components/frontapp/actions/create-draft/create-draft.mjs index c324eac39cd55..38b22e07992eb 100644 --- a/components/frontapp/actions/create-draft/create-draft.mjs +++ b/components/frontapp/actions/create-draft/create-draft.mjs @@ -5,7 +5,7 @@ export default { key: "frontapp-create-draft", name: "Create Draft", description: "Create a draft message which is the first message of a new conversation. [See the documentation](https://dev.frontapp.com/reference/create-draft)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/get-comment/get-comment.mjs b/components/frontapp/actions/get-comment/get-comment.mjs index c51214587acdf..6d0f12a67c0a0 100644 --- a/components/frontapp/actions/get-comment/get-comment.mjs +++ b/components/frontapp/actions/get-comment/get-comment.mjs @@ -4,7 +4,7 @@ export default { key: "frontapp-get-comment", name: "Get Comment", description: "Retrieve a comment from a conversation. [See the documentation](https://dev.frontapp.com/reference/get-comment)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/get-teammate/get-teammate.mjs b/components/frontapp/actions/get-teammate/get-teammate.mjs index c0cac11fc155c..89c0f41598908 100644 --- a/components/frontapp/actions/get-teammate/get-teammate.mjs +++ b/components/frontapp/actions/get-teammate/get-teammate.mjs @@ -4,7 +4,7 @@ export default { key: "frontapp-get-teammate", name: "Get Teammate", description: "Retrieve a teammate by ID. [See the documentation](https://dev.frontapp.com/reference/get-teammate)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/list-comment-mentions/list-comment-mentions.mjs b/components/frontapp/actions/list-comment-mentions/list-comment-mentions.mjs index f371f9009d5c4..da31a3f5e230b 100644 --- a/components/frontapp/actions/list-comment-mentions/list-comment-mentions.mjs +++ b/components/frontapp/actions/list-comment-mentions/list-comment-mentions.mjs @@ -4,7 +4,7 @@ export default { key: "frontapp-list-comment-mentions", name: "List Comment Mentions", description: "List the teammates mentioned in a comment. [See the documentation](https://dev.frontapp.com/reference/list-comment-mentions)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/list-comments/list-comments.mjs b/components/frontapp/actions/list-comments/list-comments.mjs index 72331db31cea7..c659f7816b392 100644 --- a/components/frontapp/actions/list-comments/list-comments.mjs +++ b/components/frontapp/actions/list-comments/list-comments.mjs @@ -4,7 +4,7 @@ export default { key: "frontapp-list-comments", name: "List Conversation Comments", description: "List the comments in a conversation. [See the documentation](https://dev.frontapp.com/reference/list-conversation-comments)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/list-conversations/list-conversations.mjs b/components/frontapp/actions/list-conversations/list-conversations.mjs index ee19fe0e67ad9..b458621046c19 100644 --- a/components/frontapp/actions/list-conversations/list-conversations.mjs +++ b/components/frontapp/actions/list-conversations/list-conversations.mjs @@ -4,7 +4,7 @@ export default { key: "frontapp-list-conversations", name: "List Conversations", description: "List conversations in the company. [See the documentation](https://dev.frontapp.com/reference/list-conversations)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/list-teammates/list-teammates.mjs b/components/frontapp/actions/list-teammates/list-teammates.mjs index 5c1076b955cda..b8867a1aa5c0e 100644 --- a/components/frontapp/actions/list-teammates/list-teammates.mjs +++ b/components/frontapp/actions/list-teammates/list-teammates.mjs @@ -4,7 +4,7 @@ export default { key: "frontapp-list-teammates", name: "List Teammate", description: "List teammates in the company. [See the documentation](https://dev.frontapp.com/reference/list-teammates)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/actions/tag-conversation/tag-conversation.mjs b/components/frontapp/actions/tag-conversation/tag-conversation.mjs index cda17006754ff..8ef633625ddff 100644 --- a/components/frontapp/actions/tag-conversation/tag-conversation.mjs +++ b/components/frontapp/actions/tag-conversation/tag-conversation.mjs @@ -4,7 +4,7 @@ export default { key: "frontapp-tag-conversation", name: "Tag Conversation", description: "Add tags to a conversation. [See the documentation](https://dev.frontapp.com/reference/patch_conversations-conversation-id)", - version: "0.0.1", + version: "0.0.2", type: "action", props: { frontApp, diff --git a/components/frontapp/sources/new-conversation-tag/new-conversation-tag.mjs b/components/frontapp/sources/new-conversation-tag/new-conversation-tag.mjs index f3a71bffa3ee9..6b25ebb92789f 100644 --- a/components/frontapp/sources/new-conversation-tag/new-conversation-tag.mjs +++ b/components/frontapp/sources/new-conversation-tag/new-conversation-tag.mjs @@ -6,7 +6,7 @@ export default { key: "frontapp-new-conversation-tag", name: "New Conversation Tag", description: "Emit new event when a conversation is tagged with a specific tag or any tag. [See the documentation](https://dev.frontapp.com/reference/events)", - version: "0.0.2", + version: "0.0.3", type: "source", dedupe: "unique", props: { From 4b38191a2d112bb0261c6466961097b90eb9a4c2 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Fri, 18 Jul 2025 17:16:42 -0300 Subject: [PATCH 6/6] Checking for undefined values on formData --- .../create-message-template.mjs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/frontapp/actions/create-message-template/create-message-template.mjs b/components/frontapp/actions/create-message-template/create-message-template.mjs index 914b8297e4547..062c58fdada86 100644 --- a/components/frontapp/actions/create-message-template/create-message-template.mjs +++ b/components/frontapp/actions/create-message-template/create-message-template.mjs @@ -69,9 +69,15 @@ export default { formData.append("name", name); formData.append("body", body); - formData.append("subject", subject); - formData.append("folder_id", folderId); - formData.append("inbox_ids", inboxIds); + if (subject !== undefined) { + formData.append("subject", subject); + } + if (folderId !== undefined) { + formData.append("folder_id", folderId); + } + if (inboxIds !== undefined) { + formData.append("inbox_ids", inboxIds); + } for (const attachment of attachments) { const {