Skip to content

Commit 99f6ccf

Browse files
committed
Adding new actions and adjusting minor things
1 parent 61b8e0d commit 99f6ccf

File tree

12 files changed

+412
-12
lines changed

12 files changed

+412
-12
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import frontApp from "../../frontapp.app.mjs";
2+
3+
export default {
4+
key: "frontapp-create-inbox",
5+
name: "Create Inbox",
6+
description: "Create an inbox in the default team (workspace). [See the documentation](https://dev.frontapp.com/reference/create-inbox).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
frontApp,
11+
name: {
12+
type: "string",
13+
label: "Name",
14+
description: "The name of the inbox",
15+
},
16+
teammateIds: {
17+
type: "string[]",
18+
label: "Teammate IDs",
19+
description: "An array of teammate IDs that should have access to the inbox. Alternatively, you can supply teammate emails as a resource alias.",
20+
propDefinition: [
21+
frontApp,
22+
"teammateId",
23+
],
24+
optional: true,
25+
},
26+
},
27+
async run({ $ }) {
28+
const {
29+
frontApp,
30+
name,
31+
teammateIds,
32+
} = this;
33+
34+
const data = {
35+
name,
36+
teammate_ids: teammateIds,
37+
};
38+
39+
const response = await frontApp.createInbox({
40+
data,
41+
$,
42+
});
43+
44+
$.export("$summary", `Successfully created inbox "${name}"`);
45+
return response;
46+
},
47+
};
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
import FormData from "form-data";
2+
import { getFileStreamAndMetadata } from "@pipedream/platform";
3+
import frontApp from "../../frontapp.app.mjs";
4+
5+
export default {
6+
key: "frontapp-create-message-template",
7+
name: "Create Message Template",
8+
description: "Create a new message template. [See the documentation](https://dev.frontapp.com/reference/create-message-template).",
9+
version: "0.0.1",
10+
type: "action",
11+
props: {
12+
frontApp,
13+
name: {
14+
type: "string",
15+
label: "Name",
16+
description: "Name of the message template",
17+
},
18+
subject: {
19+
type: "string",
20+
label: "Subject",
21+
description: "Subject of the message template",
22+
optional: true,
23+
},
24+
body: {
25+
type: "string",
26+
label: "Body",
27+
description: "Body of the message template. You can supply HTML with inline CSS to structure and style your template.",
28+
},
29+
folderId: {
30+
propDefinition: [
31+
frontApp,
32+
"folderId",
33+
],
34+
description: "ID of the message template folder to place this message template in",
35+
},
36+
inboxIds: {
37+
type: "string[]",
38+
label: "Inbox IDs",
39+
description: "The specific inboxes this template is available in. If not specified, it will be available in all inboxes.",
40+
propDefinition: [
41+
frontApp,
42+
"inboxId",
43+
],
44+
optional: true,
45+
},
46+
attachments: {
47+
propDefinition: [
48+
frontApp,
49+
"attachments",
50+
],
51+
},
52+
},
53+
async run({ $ }) {
54+
const {
55+
frontApp,
56+
name,
57+
subject,
58+
body,
59+
folderId,
60+
inboxIds,
61+
attachments,
62+
} = this;
63+
64+
let data, headers = {};
65+
66+
// Handle attachments if provided
67+
if (attachments && attachments.length > 0) {
68+
const formData = new FormData();
69+
70+
formData.append("name", name);
71+
formData.append("body", body);
72+
formData.append("subject", subject);
73+
formData.append("folder_id", folderId);
74+
formData.append("inbox_ids", inboxIds);
75+
76+
for (const attachment of attachments) {
77+
const {
78+
stream, metadata,
79+
} = await getFileStreamAndMetadata(attachment);
80+
formData.append("attachments", stream, {
81+
contentType: metadata.contentType,
82+
knownLength: metadata.size,
83+
filename: metadata.name,
84+
});
85+
}
86+
87+
data = formData;
88+
headers = formData.getHeaders();
89+
} else {
90+
// Simple JSON request without attachments
91+
data = {
92+
name,
93+
subject,
94+
body,
95+
folder_id: folderId,
96+
inbox_ids: inboxIds,
97+
};
98+
}
99+
100+
const response = await frontApp.createMessageTemplate({
101+
data,
102+
headers,
103+
$,
104+
});
105+
106+
$.export("$summary", `Successfully created message template "${name}"`);
107+
return response;
108+
},
109+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import frontApp from "../../frontapp.app.mjs";
2+
3+
export default {
4+
key: "frontapp-delete-message-template",
5+
name: "Delete Message Template",
6+
description: "Delete a message template. [See the documentation](https://dev.frontapp.com/reference/delete-message-template).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
frontApp,
11+
messageTemplateId: {
12+
propDefinition: [
13+
frontApp,
14+
"messageTemplateId",
15+
],
16+
description: "The message template ID",
17+
},
18+
},
19+
async run({ $ }) {
20+
const {
21+
frontApp,
22+
messageTemplateId,
23+
} = this;
24+
25+
const response = await frontApp.deleteMessageTemplate({
26+
messageTemplateId,
27+
$,
28+
});
29+
30+
$.export("$summary", `Successfully deleted message template ${messageTemplateId}`);
31+
return response;
32+
},
33+
};

components/frontapp/actions/import-message/import-message.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import frontApp from "../../frontapp.app.mjs";
44
export default {
55
key: "frontapp-import-message",
66
name: "Import Message",
7-
description: "Appends a new message into an inbox. [See the docs here](https://dev.frontapp.com/reference/import-inbox-message).",
7+
description: "Appends a new message into an inbox. [See the documentation](https://dev.frontapp.com/reference/import-inbox-message).",
88
version: "0.1.7",
99
type: "action",
1010
props: {
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import frontApp from "../../frontapp.app.mjs";
2+
3+
export default {
4+
key: "frontapp-list-message-templates",
5+
name: "List Message Templates",
6+
description: "List the message templates. [See the documentation](https://dev.frontapp.com/reference/list-message-templates).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
frontApp,
11+
sortBy: {
12+
type: "string",
13+
label: "Sort By",
14+
description: "Field used to sort the message templates.",
15+
options: [
16+
"created_at",
17+
"updated_at",
18+
"sort_order",
19+
],
20+
optional: true,
21+
},
22+
sortOrder: {
23+
type: "string",
24+
label: "Sort Order",
25+
description: "Order by which results should be sorted",
26+
options: [
27+
"asc",
28+
"desc",
29+
],
30+
optional: true,
31+
},
32+
},
33+
async run({ $ }) {
34+
const {
35+
frontApp,
36+
sortBy,
37+
sortOrder,
38+
} = this;
39+
40+
const params = {};
41+
42+
if (sortBy) params.sort_by = sortBy;
43+
if (sortOrder) params.sort_order = sortOrder;
44+
45+
const response = await frontApp.listMessageTemplates({
46+
params,
47+
$,
48+
});
49+
50+
const templates = response._results || [];
51+
$.export("$summary", `Successfully retrieved ${templates.length} message template(s)`);
52+
53+
return response;
54+
},
55+
};

components/frontapp/actions/receive-custom-messages/receive-custom-messages.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import frontApp from "../../frontapp.app.mjs";
44
export default {
55
key: "frontapp-receive-custom-messages",
66
name: "Receive Custom Messages",
7-
description: "Receive a custom message in Front. [See the docs here](https://dev.frontapp.com/reference/post_channels-channel-id-incoming-messages).",
8-
version: "0.0.4",
7+
description: "Receive a custom message in Front. [See the documentation](https://dev.frontapp.com/reference/post_channels-channel-id-incoming-messages).",
8+
version: "0.0.5",
99
type: "action",
1010
props: {
1111
frontApp,

components/frontapp/actions/reply-to-conversation/reply-to-conversation.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import frontApp from "../../frontapp.app.mjs";
44
export default {
55
key: "frontapp-reply-to-conversation",
66
name: "Reply To Conversation",
7-
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).",
8-
version: "0.0.3",
7+
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).",
8+
version: "0.0.4",
99
type: "action",
1010
props: {
1111
frontApp,

components/frontapp/actions/send-new-message/send-new-message.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import frontApp from "../../frontapp.app.mjs";
44
export default {
55
key: "frontapp-send-new-message",
66
name: "Send New Message",
7-
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).",
8-
version: "0.2.6",
7+
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).",
8+
version: "0.2.7",
99
type: "action",
1010
props: {
1111
frontApp,

components/frontapp/actions/update-conversation/update-conversation.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import frontApp from "../../frontapp.app.mjs";
44
export default {
55
key: "frontapp-update-conversation",
66
name: "Update Conversation",
7-
description: "Updates a conversation. [See the docs here](https://dev.frontapp.com/reference/patch_conversations-conversation-id).",
8-
version: "0.1.6",
7+
description: "Updates a conversation. [See the documentation](https://dev.frontapp.com/reference/patch_conversations-conversation-id).",
8+
version: "0.1.7",
99
type: "action",
1010
props: {
1111
frontApp,
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import frontApp from "../../frontapp.app.mjs";
2+
3+
export default {
4+
key: "frontapp-update-teammate",
5+
name: "Update Teammate",
6+
description: "Update a teammate. [See the documentation](https://dev.frontapp.com/reference/update-teammate).",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
frontApp,
11+
teammateId: {
12+
propDefinition: [
13+
frontApp,
14+
"teammateId",
15+
],
16+
description: "The teammate ID. Alternatively, you can supply an email as a resource alias",
17+
},
18+
username: {
19+
type: "string",
20+
label: "Username",
21+
description: "New username. It must be unique and can only contains lowercase letters, numbers and underscores",
22+
optional: true,
23+
},
24+
firstName: {
25+
type: "string",
26+
label: "First Name",
27+
description: "New first name",
28+
optional: true,
29+
},
30+
lastName: {
31+
type: "string",
32+
label: "Last Name",
33+
description: "New last name",
34+
optional: true,
35+
},
36+
isAvailable: {
37+
type: "boolean",
38+
label: "Is Available",
39+
description: "New availability status",
40+
optional: true,
41+
},
42+
customFields: {
43+
type: "object",
44+
label: "Custom Fields",
45+
description: "Custom fields for this teammate. If included, all current custom fields will be replaced with the object supplied here",
46+
optional: true,
47+
},
48+
},
49+
async run({ $ }) {
50+
const {
51+
frontApp,
52+
teammateId,
53+
username,
54+
firstName,
55+
lastName,
56+
isAvailable,
57+
customFields,
58+
} = this;
59+
60+
const data = {
61+
username,
62+
first_name: firstName,
63+
last_name: lastName,
64+
is_available: isAvailable,
65+
custom_fields: customFields,
66+
};
67+
68+
const response = await frontApp.updateTeammate({
69+
teammateId,
70+
data,
71+
$,
72+
});
73+
74+
$.export("$summary", `Successfully updated teammate ${teammateId}`);
75+
return response;
76+
},
77+
};

0 commit comments

Comments
 (0)