Skip to content

Frontapp new components #17689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/frontapp/actions/add-comment/add-comment.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion components/frontapp/actions/create-draft/create-draft.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
47 changes: 47 additions & 0 deletions components/frontapp/actions/create-inbox/create-inbox.mjs
Original file line number Diff line number Diff line change
@@ -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: {
propDefinition: [
frontApp,
"teammateId",
],
type: "string[]",
label: "Teammate IDs",
description: "One or more IDs of teammates that should have access to the inbox",
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;
},
};
Original file line number Diff line number Diff line change
@@ -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?.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);
Comment on lines +72 to +74
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify handling of optional fields in FormData.

The code appends subject and inboxIds to FormData without checking if they're defined. This could potentially append undefined values.


🏁 Script executed:

#!/bin/bash
# Description: Check if FormData.append handles undefined values gracefully
# This will help verify if we need null checks before appending optional fields

# Search for similar FormData usage patterns in the codebase
rg -A 5 -B 5 "formData\.append.*subject|formData\.append.*optional"

Length of output: 2638



---

🏁 Script executed:

```shell
#!/bin/bash
# Inspect the class and constructor definitions in create-message-template.mjs

# Find the class declaration
rg -n "class .*MessageTemplate" components/frontapp/actions/create-message-template/create-message-template.mjs

# Find the constructor signature
rg -n "constructor" -A 5 components/frontapp/actions/create-message-template/create-message-template.mjs

# Locate where subject and inboxIds are defined or documented
rg -n "subject" -n -A 3 components/frontapp/actions/create-message-template/create-message-template.mjs
rg -n "inboxIds" -n -A 3 components/frontapp/actions/create-message-template/create-message-template.mjs

Length of output: 1339


Add guards before appending optional FormData fields

To keep the FormData payload consistent (and avoid sending "undefined"), wrap the optional subject and inbox_ids appends in presence checks:

• File:
components/frontapp/actions/create-message-template/create-message-template.mjs

• Change the block around lines 72–74 to:

-      formData.append("subject", subject);
+      if (subject !== undefined && subject !== null) {
+        formData.append("subject", subject);
+      }

-      formData.append("inbox_ids", inboxIds);
+      if (Array.isArray(inboxIds) && inboxIds.length > 0) {
+        formData.append("inbox_ids", inboxIds);
+      }

This ensures neither key is sent when its value is unset.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
formData.append("subject", subject);
formData.append("folder_id", folderId);
formData.append("inbox_ids", inboxIds);
if (subject !== undefined && subject !== null) {
formData.append("subject", subject);
}
formData.append("folder_id", folderId);
if (Array.isArray(inboxIds) && inboxIds.length > 0) {
formData.append("inbox_ids", inboxIds);
}
🤖 Prompt for AI Agents
In
components/frontapp/actions/create-message-template/create-message-template.mjs
around lines 72 to 74, the optional fields 'subject' and 'inbox_ids' are
appended to FormData without checking if they are defined, which can result in
sending "undefined" as a value. Add conditional checks to verify that 'subject'
and 'inbox_ids' are set before appending them to the FormData object, ensuring
these keys are only included when their values are present.


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;
},
};
Original file line number Diff line number Diff line change
@@ -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: "ID of the message template to delete",
},
},
async run({ $ }) {
const {
frontApp,
messageTemplateId,
} = this;

const response = await frontApp.deleteMessageTemplate({
messageTemplateId,
$,
});

$.export("$summary", `Successfully deleted message template ${messageTemplateId}`);
return response;
},
};
2 changes: 1 addition & 1 deletion components/frontapp/actions/get-comment/get-comment.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion components/frontapp/actions/get-teammate/get-teammate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions components/frontapp/actions/import-message/import-message.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ 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).",
version: "0.1.7",
description: "Appends a new message into an inbox. [See the documentation](https://dev.frontapp.com/reference/import-inbox-message).",
version: "0.1.8",
type: "action",
props: {
frontApp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
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",
],
optional: true,
},
sortOrder: {
type: "string",
label: "Sort Order",
description: "Order by which results should be sorted",
options: [
{
label: "Ascending",
value: "asc",
},
{
label: "Descending",
value: "desc",
},
],
optional: true,
},
},
async run({ $ }) {
const {
frontApp,
sortBy,
sortOrder,
} = this;

const response = await frontApp.listMessageTemplates({
$,
params: {
sort_by: sortBy,
sort_order: sortOrder,
},
});

const templates = response._results || [];
const length = templates.length;
$.export("$summary", `Successfully retrieved ${length} message template${length === 1
? ""
: "s"}`);

return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading
Loading