Skip to content

Commit f78b76a

Browse files
authored
FrontApp - new actions (#16247)
1 parent 7352e38 commit f78b76a

File tree

22 files changed

+848
-15
lines changed

22 files changed

+848
-15
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import frontApp from "../../frontapp.app.mjs";
2+
import utils from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "frontapp-add-comment",
6+
name: "Add Comment",
7+
description: "Add a comment to a conversation. [See the documentation](https://dev.frontapp.com/reference/add-comment)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
frontApp,
12+
conversationId: {
13+
propDefinition: [
14+
frontApp,
15+
"conversationId",
16+
],
17+
},
18+
body: {
19+
type: "string",
20+
label: "Body",
21+
description: "Content of the comment. Can include markdown formatting.",
22+
},
23+
authorId: {
24+
propDefinition: [
25+
frontApp,
26+
"teammateId",
27+
],
28+
label: "Author ID",
29+
optional: true,
30+
},
31+
isPinned: {
32+
type: "boolean",
33+
label: "Is Pinned?",
34+
description: "Whether or not the comment is pinned in its conversation",
35+
optional: true,
36+
},
37+
attachments: {
38+
propDefinition: [
39+
frontApp,
40+
"attachments",
41+
],
42+
},
43+
},
44+
async run({ $ }) {
45+
const response = await this.frontApp.addComment({
46+
$,
47+
conversationId: this.conversationId,
48+
data: {
49+
body: this.body,
50+
author_id: this.authorId,
51+
is_pinned: this.isPinned,
52+
attachments: this.attachments,
53+
},
54+
headers: utils.hasArrayItems(this.attachments) && {
55+
"Content-Type": "multipart/form-data",
56+
},
57+
});
58+
$.export("$summary", `Successfully created comment with ID: ${response.id}`);
59+
return response;
60+
},
61+
};
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: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
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+
teamId: {
13+
propDefinition: [
14+
frontApp,
15+
"teamId",
16+
],
17+
},
18+
conversationId: {
19+
propDefinition: [
20+
frontApp,
21+
"conversationId",
22+
],
23+
},
24+
channelId: {
25+
propDefinition: [
26+
frontApp,
27+
"channelId",
28+
],
29+
},
30+
body: {
31+
type: "string",
32+
label: "Body",
33+
description: "Body of the draft reply. Accepts HTML",
34+
},
35+
subject: {
36+
type: "string",
37+
label: "Subject",
38+
description: "Subject of the draft reply",
39+
optional: true,
40+
},
41+
authorId: {
42+
propDefinition: [
43+
frontApp,
44+
"teammateId",
45+
],
46+
label: "Author ID",
47+
},
48+
to: {
49+
propDefinition: [
50+
frontApp,
51+
"to",
52+
],
53+
optional: true,
54+
},
55+
cc: {
56+
propDefinition: [
57+
frontApp,
58+
"cc",
59+
],
60+
},
61+
bcc: {
62+
propDefinition: [
63+
frontApp,
64+
"bcc",
65+
],
66+
},
67+
attachments: {
68+
propDefinition: [
69+
frontApp,
70+
"attachments",
71+
],
72+
},
73+
mode: {
74+
propDefinition: [
75+
frontApp,
76+
"mode",
77+
],
78+
},
79+
signatureId: {
80+
propDefinition: [
81+
frontApp,
82+
"signatureId",
83+
(c) => ({
84+
teamId: c.teamId,
85+
}),
86+
],
87+
},
88+
shouldAddDefaultSignature: {
89+
propDefinition: [
90+
frontApp,
91+
"shouldAddDefaultSignature",
92+
],
93+
},
94+
quoteBody: {
95+
propDefinition: [
96+
frontApp,
97+
"quoteBody",
98+
],
99+
},
100+
},
101+
async run({ $ }) {
102+
const response = await this.frontApp.createDraftReply({
103+
$,
104+
conversationId: this.conversationId,
105+
data: {
106+
channel_id: this.channelId,
107+
body: this.body,
108+
subject: this.subject,
109+
author_id: this.authorId,
110+
to: this.to,
111+
cc: this.cc,
112+
bcc: this.bcc,
113+
attachments: this.attachments,
114+
mode: this.mode,
115+
signature_id: this.signatureId,
116+
should_add_default_signature: this.shouldAddDefaultSignature,
117+
quote_body: this.quoteBody,
118+
},
119+
headers: utils.hasArrayItems(this.attachments) && {
120+
"Content-Type": "multipart/form-data",
121+
},
122+
});
123+
$.export("$summary", `Successfully created draft reply with ID: ${response.id}`);
124+
return response;
125+
},
126+
};
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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+
teamId: {
13+
propDefinition: [
14+
frontApp,
15+
"teamId",
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 message. Accepts HTML",
28+
},
29+
subject: {
30+
type: "string",
31+
label: "Subject",
32+
description: "Subject of the draft",
33+
optional: true,
34+
},
35+
authorId: {
36+
propDefinition: [
37+
frontApp,
38+
"teammateId",
39+
],
40+
label: "Author ID",
41+
},
42+
to: {
43+
propDefinition: [
44+
frontApp,
45+
"to",
46+
],
47+
optional: true,
48+
},
49+
cc: {
50+
propDefinition: [
51+
frontApp,
52+
"cc",
53+
],
54+
},
55+
bcc: {
56+
propDefinition: [
57+
frontApp,
58+
"bcc",
59+
],
60+
},
61+
attachments: {
62+
propDefinition: [
63+
frontApp,
64+
"attachments",
65+
],
66+
},
67+
mode: {
68+
propDefinition: [
69+
frontApp,
70+
"mode",
71+
],
72+
},
73+
signatureId: {
74+
propDefinition: [
75+
frontApp,
76+
"signatureId",
77+
(c) => ({
78+
teamId: c.teamId,
79+
}),
80+
],
81+
},
82+
shouldAddDefaultSignature: {
83+
propDefinition: [
84+
frontApp,
85+
"shouldAddDefaultSignature",
86+
],
87+
},
88+
quoteBody: {
89+
propDefinition: [
90+
frontApp,
91+
"quoteBody",
92+
],
93+
},
94+
},
95+
async run({ $ }) {
96+
const response = await this.frontApp.createDraft({
97+
$,
98+
channelId: this.channelId,
99+
data: {
100+
body: this.body,
101+
subject: this.subject,
102+
author_id: this.authorId,
103+
to: this.to,
104+
cc: this.cc,
105+
bcc: this.bcc,
106+
attachments: this.attachments,
107+
mode: this.mode,
108+
signature_id: this.signatureId,
109+
should_add_default_signature: this.shouldAddDefaultSignature,
110+
quote_body: this.quoteBody,
111+
},
112+
headers: utils.hasArrayItems(this.attachments) && {
113+
"Content-Type": "multipart/form-data",
114+
},
115+
});
116+
$.export("$summary", `Successfully created draft with ID: ${response.id}`);
117+
return response;
118+
},
119+
};

0 commit comments

Comments
 (0)