Skip to content

Commit 1fdb386

Browse files
authored
Helpscout - new components (#19227)
* new actions * versions
1 parent 1f43a7d commit 1fdb386

File tree

18 files changed

+227
-17
lines changed

18 files changed

+227
-17
lines changed

components/help_scout/actions/add-note/add-note.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "help_scout-add-note",
55
name: "Add Note to Conversation",
66
description: "Adds a note to an existing conversation in Help Scout. [See the documentation](https://developer.helpscout.com/mailbox-api/endpoints/conversations/threads/note/)",
7-
version: "0.0.3",
7+
version: "0.0.4",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,

components/help_scout/actions/create-customer/create-customer.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default {
1313
key: "help_scout-create-customer",
1414
name: "Create Customer",
1515
description: "Creates a new customer record in Help Scout. [See the documentation](https://developer.helpscout.com/mailbox-api/endpoints/customers/create/)",
16-
version: "0.0.3",
16+
version: "0.0.4",
1717
annotations: {
1818
destructiveHint: false,
1919
openWorldHint: true,

components/help_scout/actions/get-conversation-details/get-conversation-details.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "help_scout-get-conversation-details",
55
name: "Get Conversation Details",
66
description: "Retrieves the details of a specific conversation. [See the documentation](https://developer.helpscout.com/mailbox-api/endpoints/conversations/get/)",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,

components/help_scout/actions/get-conversation-threads/get-conversation-threads.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "help_scout-get-conversation-threads",
55
name: "Get Conversation Threads",
66
description: "Retrieves the threads of a specific conversation. [See the documentation](https://developer.helpscout.com/mailbox-api/endpoints/conversations/threads/list/)",
7-
version: "0.0.2",
7+
version: "0.0.3",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import helpScout from "../../help_scout.app.mjs";
2+
3+
export default {
4+
key: "help_scout-get-tag-by-id",
5+
name: "Get Tag by ID",
6+
description: "Gets a tag by its ID. [See the documentation](https://developer.helpscout.com/mailbox-api/endpoints/tags/get/)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
helpScout,
16+
tagId: {
17+
propDefinition: [
18+
helpScout,
19+
"tagId",
20+
],
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.helpScout.getTag({
25+
$,
26+
tagId: this.tagId,
27+
});
28+
$.export("$summary", `Successfully retrieved tag with ID ${this.tagId}`);
29+
return response;
30+
},
31+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import helpScout from "../../help_scout.app.mjs";
2+
3+
export default {
4+
key: "help_scout-list-tags",
5+
name: "List Tags",
6+
description: "Lists all tags in Help Scout. [See the documentation](https://developer.helpscout.com/mailbox-api/endpoints/tags/list/)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
helpScout,
16+
page: {
17+
type: "integer",
18+
label: "Page",
19+
description: "The page number to return. Defaults to 1.",
20+
default: 1,
21+
optional: true,
22+
},
23+
},
24+
async run({ $ }) {
25+
const response = await this.helpScout.listTags({
26+
$,
27+
params: {
28+
page: this.page,
29+
},
30+
});
31+
const length = response?._embedded?.tags?.length ?? 0;
32+
$.export("$summary", `Successfully retrieved ${length} tag${length === 1
33+
? ""
34+
: "s"}`);
35+
return response;
36+
},
37+
};

components/help_scout/actions/send-reply/send-reply.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "help_scout-send-reply",
55
name: "Send Reply",
66
description: "Sends a reply to a conversation. Be careful as this sends an actual email to the customer. [See the documentation](https://developer.helpscout.com/mailbox-api/endpoints/conversations/threads/reply/)",
7-
version: "0.0.3",
7+
version: "0.0.4",
88
annotations: {
99
destructiveHint: false,
1010
openWorldHint: true,
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import helpScout from "../../help_scout.app.mjs";
2+
import { CONVERSATION_OPERATIONS } from "../../common/constants.mjs";
3+
4+
export default {
5+
key: "help_scout-update-conversation",
6+
name: "Update Conversation",
7+
description: "Updates a conversation. [See the documentation](https://developer.helpscout.com/mailbox-api/endpoints/conversations/update/)",
8+
version: "0.0.1",
9+
type: "action",
10+
annotations: {
11+
destructiveHint: true,
12+
openWorldHint: true,
13+
readOnlyHint: false,
14+
},
15+
props: {
16+
helpScout,
17+
conversationId: {
18+
propDefinition: [
19+
helpScout,
20+
"conversationId",
21+
],
22+
},
23+
operation: {
24+
type: "string",
25+
label: "Operation",
26+
description: "The operation to perform on the conversation",
27+
options: CONVERSATION_OPERATIONS.map(({ label }) => label),
28+
},
29+
value: {
30+
type: "string",
31+
label: "Value",
32+
description: "The value to use for the operation",
33+
},
34+
},
35+
async run({ $ }) {
36+
const operation = CONVERSATION_OPERATIONS.find(({ label }) => label === this.operation);
37+
const value = operation.type === "boolean"
38+
? this.value === "true"
39+
: operation.type === "number"
40+
? +this.value
41+
: this.value;
42+
43+
const response = await this.helpScout.updateConversation({
44+
conversationId: this.conversationId,
45+
data: {
46+
op: operation.operation,
47+
path: operation.path,
48+
value,
49+
},
50+
});
51+
52+
$.export("$summary", `Successfully updated conversation with ID ${this.conversationId}`);
53+
54+
return response;
55+
},
56+
};

components/help_scout/common/constants.mjs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,48 @@ export const GENDER_OPTIONS = [
1414
"female",
1515
"unknown",
1616
];
17+
18+
export const CONVERSATION_OPERATIONS = [
19+
{
20+
label: "Change subject",
21+
path: "/subject",
22+
operation: "replace",
23+
type: "string",
24+
},
25+
{
26+
label: "Change customer",
27+
path: "/primaryCustomer.id",
28+
operation: "replace",
29+
type: "number",
30+
},
31+
{
32+
label: "Publish draft",
33+
path: "/draft",
34+
operation: "replace",
35+
type: "boolean",
36+
},
37+
{
38+
label: "Move conversation to another inbox",
39+
path: "/mailboxId",
40+
operation: "move",
41+
type: "number",
42+
},
43+
{
44+
label: "Change conversation status",
45+
path: "/status",
46+
operation: "replace",
47+
type: "string",
48+
},
49+
{
50+
label: "Change conversation owner",
51+
path: "/assignTo",
52+
operation: "replace",
53+
type: "number",
54+
},
55+
{
56+
label: "Un-assign conversation",
57+
path: "/assignTo",
58+
operation: "remove",
59+
type: "number",
60+
},
61+
];

components/help_scout/help_scout.app.mjs

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
agentId: {
88
type: "string",
99
label: "Agent ID",
10-
description: "ID of the agent to whom the conversation is assigned.",
10+
description: "ID of the agent to whom the conversation is assigned",
1111
},
1212
conversationId: {
1313
type: "string",
@@ -31,7 +31,7 @@ export default {
3131
customerId: {
3232
type: "string",
3333
label: "Customer ID",
34-
description: "The unique identifier of the customer.",
34+
description: "The unique identifier of the customer",
3535
async options({ page }) {
3636
const { _embedded: { customers } } = await this.listCustomers({
3737
params: {
@@ -50,7 +50,7 @@ export default {
5050
userId: {
5151
type: "string",
5252
label: "User ID",
53-
description: "The unique identifier of the user.",
53+
description: "The unique identifier of the user",
5454
async options({ page }) {
5555
const { _embedded: { users } } = await this.listUsers({
5656
params: {
@@ -66,10 +66,28 @@ export default {
6666
}));
6767
},
6868
},
69+
tagId: {
70+
type: "string",
71+
label: "Tag ID",
72+
description: "The unique identifier of the tag",
73+
async options({ page }) {
74+
const { _embedded: { tags } } = await this.listTags({
75+
params: {
76+
page: page + 1,
77+
},
78+
});
79+
return tags.map(({
80+
id: value, name: label,
81+
}) => ({
82+
label,
83+
value,
84+
}));
85+
},
86+
},
6987
text: {
7088
type: "string",
7189
label: "Text",
72-
description: "The content of the note.",
90+
description: "The content of the note",
7391
},
7492
},
7593
methods: {
@@ -90,6 +108,14 @@ export default {
90108
...opts,
91109
});
92110
},
111+
getTag({
112+
tagId, ...opts
113+
}) {
114+
return this._makeRequest({
115+
path: `/tags/${tagId}`,
116+
...opts,
117+
});
118+
},
93119
listConversations(opts = {}) {
94120
return this._makeRequest({
95121
path: "/conversations",
@@ -108,6 +134,12 @@ export default {
108134
...opts,
109135
});
110136
},
137+
listTags(opts = {}) {
138+
return this._makeRequest({
139+
path: "/tags",
140+
...opts,
141+
});
142+
},
111143
createWebhook(opts = {}) {
112144
return this._makeRequest({
113145
method: "POST",
@@ -162,5 +194,14 @@ export default {
162194
...opts,
163195
});
164196
},
197+
updateConversation({
198+
conversationId, ...opts
199+
}) {
200+
return this._makeRequest({
201+
method: "PATCH",
202+
path: `/conversations/${conversationId}`,
203+
...opts,
204+
});
205+
},
165206
},
166207
};

0 commit comments

Comments
 (0)