Skip to content

Commit 9addf95

Browse files
authored
Slack - usability updates (#12265)
* updates * versions * updates
1 parent e63dee1 commit 9addf95

File tree

46 files changed

+196
-108
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+196
-108
lines changed

components/slack/actions/add-emoji-reaction/add-emoji-reaction.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "slack-add-emoji-reaction",
55
name: "Add Emoji Reaction",
66
description: "Add an emoji reaction to a message. [See the documentation](https://api.slack.com/methods/reactions.add)",
7-
version: "0.0.9",
7+
version: "0.0.10",
88
type: "action",
99
props: {
1010
slack,

components/slack/actions/archive-channel/archive-channel.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
key: "slack-archive-channel",
66
name: "Archive Channel",
77
description: "Archive a channel. [See the documentation](https://api.slack.com/methods/conversations.archive)",
8-
version: "0.0.17",
8+
version: "0.0.18",
99
type: "action",
1010
props: {
1111
slack,

components/slack/actions/common/build-blocks.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ export default {
8181
}
8282
},
8383
},
84-
async additionalProps() {
84+
async additionalProps(existingProps) {
85+
await common.additionalProps.call(this, existingProps);
8586
const props = {};
8687
const sectionDescription = "Add a **section** block to your message and configure with plain text or mrkdwn. See [Slack's docs](https://api.slack.com/reference/block-kit/blocks?ref=bk#section) for more info.";
8788
const contextDescription = "Add a **context** block to your message and configure with plain text or mrkdwn. Define multiple items if you'd like multiple elements in the context block. See [Slack's docs](https://api.slack.com/reference/block-kit/blocks?ref=bk#context) for more info.";

components/slack/actions/common/send-message.mjs

Lines changed: 93 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,62 +9,136 @@ export default {
99
"as_user",
1010
],
1111
},
12+
post_at: {
13+
propDefinition: [
14+
slack,
15+
"post_at",
16+
],
17+
},
18+
include_sent_via_pipedream_flag: {
19+
type: "boolean",
20+
optional: true,
21+
default: true,
22+
label: "Include link to workflow",
23+
description: "Defaults to `true`, includes a link to the workflow at the end of your Slack message.",
24+
},
25+
customizeBotSettings: {
26+
type: "boolean",
27+
label: "Customize Bot Settings",
28+
description: "Customize the username and/or icon of the Bot",
29+
optional: true,
30+
reloadProps: true,
31+
},
1232
username: {
1333
propDefinition: [
1434
slack,
1535
"username",
1636
],
37+
hidden: true,
1738
},
1839
icon_emoji: {
1940
propDefinition: [
2041
slack,
2142
"icon_emoji",
2243
],
44+
hidden: true,
2345
},
2446
icon_url: {
2547
propDefinition: [
2648
slack,
2749
"icon_url",
2850
],
51+
hidden: true,
2952
},
30-
post_at: {
53+
replyToThread: {
54+
type: "boolean",
55+
label: "Reply to Thread",
56+
description: "Reply to an existing thread",
57+
optional: true,
58+
reloadProps: true,
59+
},
60+
thread_ts: {
3161
propDefinition: [
3262
slack,
33-
"post_at",
63+
"messageTs",
64+
(c) => ({
65+
channel: c.conversation,
66+
}),
3467
],
68+
description: "Provide another message's `ts` value to make this message a reply (e.g., if triggering on new Slack messages, enter `{{event.ts}}`). Avoid using a reply's `ts` value; use its parent instead.",
69+
optional: true,
70+
hidden: true,
3571
},
36-
include_sent_via_pipedream_flag: {
72+
thread_broadcast: {
73+
propDefinition: [
74+
slack,
75+
"thread_broadcast",
76+
],
77+
hidden: true,
78+
},
79+
addMessageMetadata: {
3780
type: "boolean",
81+
label: "Add Message Metadata",
82+
description: "Set the metadata event type and payload",
3883
optional: true,
39-
default: true,
40-
label: "Include link to workflow",
41-
description: "Defaults to `true`, includes a link to the workflow at the end of your Slack message.",
84+
reloadProps: true,
4285
},
4386
metadata_event_type: {
4487
propDefinition: [
4588
slack,
4689
"metadata_event_type",
4790
],
91+
hidden: true,
4892
},
4993
metadata_event_payload: {
5094
propDefinition: [
5195
slack,
5296
"metadata_event_payload",
5397
],
98+
hidden: true,
99+
},
100+
configureUnfurlSettings: {
101+
type: "boolean",
102+
label: "Configure Unfurl Settings",
103+
description: "Configure settings for unfurling links and media",
104+
optional: true,
105+
reloadProps: true,
54106
},
55107
unfurl_links: {
56108
propDefinition: [
57109
slack,
58110
"unfurl_links",
59111
],
112+
hidden: true,
60113
},
61114
unfurl_media: {
62115
propDefinition: [
63116
slack,
64117
"unfurl_media",
65118
],
119+
hidden: true,
66120
},
67121
},
122+
async additionalProps(props) {
123+
if (this.conversation && this.replyToThread) {
124+
props.thread_ts.hidden = false;
125+
props.thread_broadcast.hidden = false;
126+
}
127+
if (this.customizeBotSettings) {
128+
props.username.hidden = false;
129+
props.icon_emoji.hidden = false;
130+
props.icon_url.hidden = false;
131+
}
132+
if (this.addMessageMetadata) {
133+
props.metadata_event_type.hidden = false;
134+
props.metadata_event_payload.hidden = false;
135+
}
136+
if (this.configureUnfurlSettings) {
137+
props.unfurl_links.hidden = false;
138+
props.unfurl_media.hidden = false;
139+
}
140+
return {};
141+
},
68142
methods: {
69143
_makeSentViaPipedreamBlock() {
70144
const workflowId = process.env.PIPEDREAM_WORKFLOW_ID;
@@ -120,7 +194,7 @@ export default {
120194

121195
if (this.metadata_event_type) {
122196

123-
if (typeof metadataEventPayload === "string") {
197+
if (typeof this.metadata_event_payload === "string") {
124198
try {
125199
metadataEventPayload = JSON.parse(this.metadata_event_payload);
126200
} catch (error) {
@@ -148,7 +222,7 @@ export default {
148222
mrkdwn: this.mrkdwn,
149223
blocks,
150224
link_names: this.link_names,
151-
reply_broadcast: this.reply_broadcast,
225+
reply_broadcast: this.thread_broadcast,
152226
thread_ts: this.thread_ts,
153227
metadata: this.metadata || null,
154228
};
@@ -158,7 +232,17 @@ export default {
158232
return await this.slack.sdk().chat.scheduleMessage(obj);
159233
}
160234
const resp = await this.slack.sdk().chat.postMessage(obj);
161-
$.export("$summary", "Successfully sent a message to channel ID " + resp.channel);
235+
const { channel } = await this.slack.conversationsInfo({
236+
channel: resp.channel,
237+
});
238+
let channelName = `#${channel?.name}`;
239+
if (channel.is_im) {
240+
const usernames = await this.slack.userNames();
241+
channelName = `@${usernames[channel.user]}`;
242+
} else if (channel.is_mpim) {
243+
channelName = `@${channel.purpose.value}`;
244+
}
245+
$.export("$summary", `Successfully sent a message to ${channelName}`);
162246
return resp;
163247
},
164248
};

components/slack/actions/create-channel/create-channel.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "slack-create-channel",
55
name: "Create a Channel",
66
description: "Create a new channel. [See the documentation](https://api.slack.com/methods/conversations.create)",
7-
version: "0.0.18",
7+
version: "0.0.19",
88
type: "action",
99
props: {
1010
slack,

components/slack/actions/create-reminder/create-reminder.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "slack-create-reminder",
55
name: "Create Reminder",
66
description: "Create a reminder. [See the documentation](https://api.slack.com/methods/reminders.add)",
7-
version: "0.0.18",
7+
version: "0.0.19",
88
type: "action",
99
props: {
1010
slack,

components/slack/actions/delete-file/delete-file.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "slack-delete-file",
55
name: "Delete File",
66
description: "Delete a file. [See the documentation](https://api.slack.com/methods/files.delete)",
7-
version: "0.0.17",
7+
version: "0.0.18",
88
type: "action",
99
props: {
1010
slack,

components/slack/actions/delete-message/delete-message.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "slack-delete-message",
55
name: "Delete Message",
66
description: "Delete a message. [See the documentation](https://api.slack.com/methods/chat.delete)",
7-
version: "0.0.17",
7+
version: "0.0.18",
88
type: "action",
99
props: {
1010
slack,

components/slack/actions/find-message/find-message.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "slack-find-message",
55
name: "Find Message",
66
description: "Find a Slack message. [See the documentation](https://api.slack.com/methods/search.messages)",
7-
version: "0.0.17",
7+
version: "0.0.18",
88
type: "action",
99
props: {
1010
slack,

components/slack/actions/find-user-by-email/find-user-by-email.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "slack-find-user-by-email",
55
name: "Find User by Email",
66
description: "Find a user by matching against their email. [See the documentation](https://api.slack.com/methods/users.lookupByEmail)",
7-
version: "0.0.17",
7+
version: "0.0.18",
88
type: "action",
99
props: {
1010
slack,

0 commit comments

Comments
 (0)