Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
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",
],
},
Comment on lines +46 to +51
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe we're supposed to be adding syncDir to components that work with the /tmp directory.

Suggested change
attachments: {
propDefinition: [
frontApp,
"attachments",
],
},
attachments: {
propDefinition: [
frontApp,
"attachments",
],
},
syncDir: {
type: "dir",
accessMode: "write",
sync: true,
},

Copy link
Collaborator

Choose a reason for hiding this comment

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

The syncDir prop has to do with File Stash. https://pipedream.com/docs/connect/components/files

},
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);

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;
},
};
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
@@ -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",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note: the docs do not mention a page or per_page parameter for this endpoint at all

Copy link
Collaborator

Choose a reason for hiding this comment

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

The docs show it uses a page_token instead. This action should have a maxResults prop and return a paginated list as the result. Note: You can look at how the messageTemplateId prop uses pagination.

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,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
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-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,
Expand Down
77 changes: 77 additions & 0 deletions components/frontapp/actions/update-teammate/update-teammate.mjs
Original file line number Diff line number Diff line change
@@ -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: "ID of the teammate to update",
},
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;
},
};
Loading
Loading