Skip to content

Commit 79fe510

Browse files
committed
new actions
1 parent f532bd3 commit 79fe510

File tree

10 files changed

+455
-3
lines changed

10 files changed

+455
-3
lines changed

components/frontapp/actions/add-comment/add-comment.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import frontApp from "../../frontapp.app.mjs";
2+
import utils from "../../common/utils.mjs";
23

34
export default {
45
key: "frontapp-add-comment",
@@ -33,6 +34,12 @@ export default {
3334
description: "Whether or not the comment is pinned in its conversation",
3435
optional: true,
3536
},
37+
attachments: {
38+
propDefinition: [
39+
frontApp,
40+
"attachments",
41+
],
42+
},
3643
},
3744
async run({ $ }) {
3845
const response = await this.frontApp.addComment({
@@ -42,6 +49,10 @@ export default {
4249
body: this.body,
4350
author_id: this.authorId,
4451
is_pinned: this.isPinned,
52+
attachments: this.attachments,
53+
},
54+
headers: utils.hasArrayItems(this.attachments) && {
55+
"Content-Type": "multipart/form-data",
4556
},
4657
});
4758
$.export("$summary", `Successfully created comment with ID: ${response.id}`);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import frontApp from "../../frontapp.app.mjs";
2+
3+
export default {
4+
key: "frontapp-archive-conversation",
5+
name: "Archive Conversation",
6+
description: "Archives a conversation. [See the documentation](https://dev.frontapp.com/reference/patch_conversations-conversation-id)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
frontApp,
11+
conversationId: {
12+
propDefinition: [
13+
frontApp,
14+
"conversationId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.frontApp.updateConversation({
20+
$,
21+
conversationId: this.conversationId,
22+
data: {
23+
status: "archived",
24+
},
25+
});
26+
$.export("$summary", `Successfully archived conversation with ID: ${this.conversationId}`);
27+
return response;
28+
},
29+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import frontApp from "../../frontapp.app.mjs";
2+
3+
export default {
4+
key: "frontapp-assign-conversation",
5+
name: "Assign Conversation",
6+
description: "Assign or unassign a conversation. [See the documentation](https://dev.frontapp.com/reference/update-conversation-assignee)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
frontApp,
11+
conversationId: {
12+
propDefinition: [
13+
frontApp,
14+
"conversationId",
15+
],
16+
},
17+
assigneeId: {
18+
propDefinition: [
19+
frontApp,
20+
"teammateId",
21+
],
22+
label: "Assignee ID",
23+
description: "ID of the contact to assign",
24+
},
25+
},
26+
async run({ $ }) {
27+
const response = await this.frontApp.updateConversationAssignee({
28+
$,
29+
conversationId: this.conversationId,
30+
data: {
31+
assignee_id: this.assigneeId,
32+
},
33+
});
34+
$.export("$summary", `Successfully assigned contact to conversation with ID: ${this.conversationId}`);
35+
return response;
36+
},
37+
};
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import frontApp from "../../frontapp.app.mjs";
2+
import utils from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "frontapp-create-draft-reply",
6+
name: "Create Draft Reply",
7+
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)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
frontApp,
12+
conversationId: {
13+
propDefinition: [
14+
frontApp,
15+
"conversationId",
16+
],
17+
},
18+
channelId: {
19+
propDefinition: [
20+
frontApp,
21+
"channelId",
22+
],
23+
},
24+
body: {
25+
type: "string",
26+
label: "Body",
27+
description: "Body of the draft reply. Accepts HTML",
28+
},
29+
subject: {
30+
type: "string",
31+
label: "Subject",
32+
description: "Subject of the draft reply",
33+
optional: true,
34+
},
35+
authorId: {
36+
propDefinition: [
37+
frontApp,
38+
"teammateId",
39+
],
40+
label: "Author ID",
41+
optional: true,
42+
},
43+
to: {
44+
propDefinition: [
45+
frontApp,
46+
"to",
47+
],
48+
optional: true,
49+
},
50+
cc: {
51+
propDefinition: [
52+
frontApp,
53+
"cc",
54+
],
55+
},
56+
bcc: {
57+
propDefinition: [
58+
frontApp,
59+
"bcc",
60+
],
61+
},
62+
attachments: {
63+
propDefinition: [
64+
frontApp,
65+
"attachments",
66+
],
67+
},
68+
},
69+
async run({ $ }) {
70+
const response = await this.frontApp.createDraftReply({
71+
$,
72+
conversationId: this.conversationId,
73+
data: {
74+
channel_id: this.channelId,
75+
body: this.body,
76+
author_id: this.authorId,
77+
to: this.to,
78+
cc: this.cc,
79+
bcc: this.bcc,
80+
attachments: this.attachments,
81+
},
82+
headers: utils.hasArrayItems(this.attachments) && {
83+
"Content-Type": "multipart/form-data",
84+
},
85+
});
86+
$.export("$summary", `Successfully created draft reply with ID: ${response.id}`);
87+
return response;
88+
},
89+
};
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import frontApp from "../../frontapp.app.mjs";
2+
import utils from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "frontapp-create-draft",
6+
name: "Create Draft",
7+
description: "Create a draft message which is the first message of a new conversation. [See the documentation](https://dev.frontapp.com/reference/create-draft)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
frontApp,
12+
channelId: {
13+
propDefinition: [
14+
frontApp,
15+
"channelId",
16+
],
17+
},
18+
body: {
19+
type: "string",
20+
label: "Body",
21+
description: "Body of the draft message. Accepts HTML",
22+
},
23+
subject: {
24+
type: "string",
25+
label: "Subject",
26+
description: "Subject of the draft",
27+
optional: true,
28+
},
29+
authorId: {
30+
propDefinition: [
31+
frontApp,
32+
"teammateId",
33+
],
34+
label: "Author ID",
35+
optional: true,
36+
},
37+
to: {
38+
propDefinition: [
39+
frontApp,
40+
"to",
41+
],
42+
optional: true,
43+
},
44+
cc: {
45+
propDefinition: [
46+
frontApp,
47+
"cc",
48+
],
49+
},
50+
bcc: {
51+
propDefinition: [
52+
frontApp,
53+
"bcc",
54+
],
55+
},
56+
attachments: {
57+
propDefinition: [
58+
frontApp,
59+
"attachments",
60+
],
61+
},
62+
},
63+
async run({ $ }) {
64+
const response = await this.frontApp.createDraft({
65+
$,
66+
channelId: this.channelId,
67+
data: {
68+
body: this.body,
69+
author_id: this.authorId,
70+
to: this.to,
71+
cc: this.cc,
72+
bcc: this.bcc,
73+
attachments: this.attachments,
74+
},
75+
headers: utils.hasArrayItems(this.attachments) && {
76+
"Content-Type": "multipart/form-data",
77+
},
78+
});
79+
$.export("$summary", `Successfully created draft with ID: ${response.id}`);
80+
return response;
81+
},
82+
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import frontApp from "../../frontapp.app.mjs";
2+
3+
export default {
4+
key: "frontapp-get-teammate",
5+
name: "Get Teammate",
6+
description: "Retrieve a teammate by ID. [See the documentation](https://dev.frontapp.com/reference/get-teammate)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
frontApp,
11+
teammateId: {
12+
propDefinition: [
13+
frontApp,
14+
"teammateId",
15+
],
16+
description: "ID of the teammate to get details of",
17+
},
18+
},
19+
async run({ $ }) {
20+
const response = await this.frontApp.getTeammate({
21+
$,
22+
teammateId: this.teammateId,
23+
});
24+
$.export("$summary", `Successfully retrieved teammate with ID: ${response.id}`);
25+
return response;
26+
},
27+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import frontApp from "../../frontapp.app.mjs";
2+
3+
export default {
4+
key: "frontapp-list-conversations",
5+
name: "List Conversations",
6+
description: "List conversations in the company. [See the documentation](https://dev.frontapp.com/reference/list-conversations)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
frontApp,
11+
maxResults: {
12+
propDefinition: [
13+
frontApp,
14+
"maxResults",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const items = this.frontApp.paginate({
20+
fn: this.frontApp.listConversations,
21+
maxResults: this.maxResults,
22+
args: {
23+
$,
24+
},
25+
});
26+
27+
const results = [];
28+
for await (const item of items) {
29+
results.push(item);
30+
}
31+
32+
$.export("$summary", `Successfully retrieved ${results.length} conversation${results.length === 1
33+
? ""
34+
: "s"}`);
35+
return results;
36+
},
37+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import frontApp from "../../frontapp.app.mjs";
2+
3+
export default {
4+
key: "frontapp-list-teammates",
5+
name: "List Teammate",
6+
description: "List teammates in the company. [See the documentation](https://dev.frontapp.com/reference/list-teammates)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
frontApp,
11+
maxResults: {
12+
propDefinition: [
13+
frontApp,
14+
"maxResults",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const items = this.frontApp.paginate({
20+
fn: this.frontApp.listTeammates,
21+
maxResults: this.maxResults,
22+
args: {
23+
$,
24+
},
25+
});
26+
27+
const results = [];
28+
for await (const item of items) {
29+
results.push(item);
30+
}
31+
32+
$.export("$summary", `Successfully retrieved ${results.length} teammate${results.length === 1
33+
? ""
34+
: "s"}`);
35+
return results;
36+
},
37+
};

0 commit comments

Comments
 (0)