@pipedream/slack 0.4.29 → 0.4.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/actions/common/build-blocks.mjs +180 -0
- package/actions/common/send-message.mjs +4 -3
- package/actions/reply-to-a-message/reply-to-a-message.mjs +1 -1
- package/actions/send-block-kit-message/send-block-kit-message.mjs +21 -12
- package/actions/send-custom-message/send-custom-message.mjs +1 -1
- package/actions/send-direct-message/send-direct-message.mjs +1 -1
- package/actions/send-group-message/send-group-message.mjs +1 -1
- package/actions/send-large-message/send-large-message.mjs +1 -1
- package/actions/send-message-private-channel/send-message-private-channel.mjs +1 -1
- package/actions/send-message-public-channel/send-message-public-channel.mjs +1 -1
- package/package.json +1 -1
- package/sources/new-message-in-channels/new-message-in-channels.mjs +14 -1
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import common from "./send-message.mjs";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable pipedream/required-properties-key, pipedream/required-properties-name,
|
|
4
|
+
pipedream/required-properties-version, pipedream/required-properties-description */
|
|
5
|
+
export default {
|
|
6
|
+
type: "action",
|
|
7
|
+
props: {
|
|
8
|
+
passArrayOrConfigure: {
|
|
9
|
+
type: "string",
|
|
10
|
+
label: "Reference Existing Blocks Array or Configure Manually?",
|
|
11
|
+
description: "Would you like to reference an array of blocks from a previous step (for example, `{{steps.blocks.$return_value}}`), or configure them in this action?",
|
|
12
|
+
options: [
|
|
13
|
+
{
|
|
14
|
+
label: "Reference an array of blocks",
|
|
15
|
+
value: "array",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
label: "Configure blocks individually (maximum 5 blocks)",
|
|
19
|
+
value: "configure",
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
reloadProps: true,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
methods: {
|
|
26
|
+
// This adds a visual separator in the props form between each block
|
|
27
|
+
separator() {
|
|
28
|
+
return `
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
`;
|
|
33
|
+
},
|
|
34
|
+
createBlockProp(type, label, description) {
|
|
35
|
+
return {
|
|
36
|
+
type,
|
|
37
|
+
label,
|
|
38
|
+
description: `${description} ${this.separator()}`,
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
createBlock(type, text) {
|
|
42
|
+
if (type === "section") {
|
|
43
|
+
return {
|
|
44
|
+
type: "section",
|
|
45
|
+
text: {
|
|
46
|
+
type: "mrkdwn",
|
|
47
|
+
text,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
} else if (type === "context") {
|
|
51
|
+
const elements = Array.isArray(text)
|
|
52
|
+
? text.map((t) => ({
|
|
53
|
+
type: "mrkdwn",
|
|
54
|
+
text: t,
|
|
55
|
+
}))
|
|
56
|
+
: [
|
|
57
|
+
{
|
|
58
|
+
type: "mrkdwn",
|
|
59
|
+
text,
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
return {
|
|
63
|
+
type: "context",
|
|
64
|
+
elements,
|
|
65
|
+
};
|
|
66
|
+
} else if (type === "link_button") {
|
|
67
|
+
const buttons = Object.keys(text).map((buttonText) => ({
|
|
68
|
+
type: "button",
|
|
69
|
+
text: {
|
|
70
|
+
type: "plain_text",
|
|
71
|
+
text: buttonText,
|
|
72
|
+
emoji: true,
|
|
73
|
+
},
|
|
74
|
+
url: text[buttonText], // Access the URL using buttonText as the key
|
|
75
|
+
action_id: `actionId-${Math.random().toString(36)
|
|
76
|
+
.substr(2, 9)}`, // Generates a random action_id
|
|
77
|
+
}));
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
type: "actions",
|
|
81
|
+
elements: buttons,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
async additionalProps() {
|
|
87
|
+
const props = {};
|
|
88
|
+
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.";
|
|
89
|
+
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.";
|
|
90
|
+
const linkButtonDescription = "Add a **link button** to your message. Enter the button text as the key and the link URL as the value. Configure multiple buttons in the array to render them inline, or add additional Button Link blocks to render them vertically. See [Slack's docs](https://api.slack.com/reference/block-kit/blocks?ref=bk#actions) for more info.";
|
|
91
|
+
const propsSection = this.createBlockProp("string", "Section Block Text", sectionDescription);
|
|
92
|
+
const propsContext = this.createBlockProp("string[]", "Context Block Text", contextDescription);
|
|
93
|
+
const propsLinkButton = this.createBlockProp("object", "Link Button", linkButtonDescription);
|
|
94
|
+
|
|
95
|
+
if (this.passArrayOrConfigure == "array") {
|
|
96
|
+
props.blocks = {
|
|
97
|
+
type: common.props.slack.propDefinitions.blocks.type,
|
|
98
|
+
label: common.props.slack.propDefinitions.blocks.label,
|
|
99
|
+
description: common.props.slack.propDefinitions.blocks.description,
|
|
100
|
+
};
|
|
101
|
+
} else {
|
|
102
|
+
props.blockType = {
|
|
103
|
+
type: "string",
|
|
104
|
+
label: "Block Type",
|
|
105
|
+
description: "Select the type of block to add. Refer to [Slack's docs](https://api.slack.com/reference/block-kit/blocks) for more info.",
|
|
106
|
+
options: [
|
|
107
|
+
{
|
|
108
|
+
label: "Section",
|
|
109
|
+
value: "section",
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
label: "Context",
|
|
113
|
+
value: "context",
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
label: "Link Button",
|
|
117
|
+
value: "link_button",
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
reloadProps: true,
|
|
121
|
+
};}
|
|
122
|
+
let currentBlockType = this.blockType;
|
|
123
|
+
for (let i = 1; i <= 5; i++) {
|
|
124
|
+
if (currentBlockType === "section") {
|
|
125
|
+
props[`section${i}`] = propsSection;
|
|
126
|
+
} else if (currentBlockType === "context") {
|
|
127
|
+
props[`context${i}`] = propsContext;
|
|
128
|
+
} else if (currentBlockType === "link_button") {
|
|
129
|
+
props[`linkButton${i}`] = propsLinkButton;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (i < 5 && currentBlockType) { // Check if currentBlockType is set before adding nextBlockType
|
|
133
|
+
props[`nextBlockType${i}`] = {
|
|
134
|
+
type: "string",
|
|
135
|
+
label: "Next Block Type",
|
|
136
|
+
options: [
|
|
137
|
+
{
|
|
138
|
+
label: "Section",
|
|
139
|
+
value: "section",
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
label: "Context",
|
|
143
|
+
value: "context",
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
label: "Link Button",
|
|
147
|
+
value: "link_button",
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
optional: true,
|
|
151
|
+
reloadProps: true,
|
|
152
|
+
};
|
|
153
|
+
currentBlockType = this[`nextBlockType${i}`];
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return props;
|
|
157
|
+
},
|
|
158
|
+
async run() {
|
|
159
|
+
let blocks = [];
|
|
160
|
+
if (this.passArrayOrConfigure == "array") {
|
|
161
|
+
blocks = this.blocks;
|
|
162
|
+
} else {
|
|
163
|
+
for (let i = 1; i <= 5; i++) {
|
|
164
|
+
if (this[`section${i}`]) {
|
|
165
|
+
blocks.push(this.createBlock("section", this[`section${i}`]));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (this[`context${i}`]) {
|
|
169
|
+
blocks.push(this.createBlock("context", this[`context${i}`]));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (this[`linkButton${i}`]) {
|
|
173
|
+
blocks.push(this.createBlock("link_button", this[`linkButton${i}`]));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return blocks;
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
|
|
@@ -91,7 +91,7 @@ export default {
|
|
|
91
91
|
};
|
|
92
92
|
},
|
|
93
93
|
},
|
|
94
|
-
async run() {
|
|
94
|
+
async run({ $ }) {
|
|
95
95
|
let blocks = this.blocks;
|
|
96
96
|
|
|
97
97
|
if (!blocks) {
|
|
@@ -167,7 +167,8 @@ export default {
|
|
|
167
167
|
obj.post_at = this.post_at;
|
|
168
168
|
return await this.slack.sdk().chat.scheduleMessage(obj);
|
|
169
169
|
}
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
const resp = await this.slack.sdk().chat.postMessage(obj);
|
|
171
|
+
$.export("$summary", "Successfully sent a message to channel ID " + resp.channel);
|
|
172
|
+
return resp;
|
|
172
173
|
},
|
|
173
174
|
};
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "slack-reply-to-a-message",
|
|
7
7
|
name: "Reply to a Message Thread",
|
|
8
8
|
description: "Send a message as a threaded reply. See [postMessage](https://api.slack.com/methods/chat.postMessage) or [scheduleMessage](https://api.slack.com/methods/chat.scheduleMessage) docs here",
|
|
9
|
-
version: "0.1.
|
|
9
|
+
version: "0.1.18",
|
|
10
10
|
type: "action",
|
|
11
11
|
props: {
|
|
12
12
|
slack: common.props.slack,
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import common from "../common/send-message.mjs";
|
|
2
|
+
import buildBlocks from "../common/build-blocks.mjs";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
...common,
|
|
5
|
-
|
|
6
|
-
name: "Send
|
|
7
|
-
description: "
|
|
8
|
-
version: "0.
|
|
6
|
+
...buildBlocks,
|
|
7
|
+
name: "Build and Send a Block Kit Message (Beta)",
|
|
8
|
+
description: "Configure custom blocks and send to a channel, group, or user. [See Slack's docs for more info](https://api.slack.com/tools/block-kit-builder).",
|
|
9
|
+
version: "0.3.0",
|
|
9
10
|
type: "action",
|
|
11
|
+
key: "slack-send-block-kit-message",
|
|
10
12
|
props: {
|
|
11
13
|
slack: common.props.slack,
|
|
12
14
|
conversation: {
|
|
@@ -14,14 +16,6 @@ export default {
|
|
|
14
16
|
common.props.slack,
|
|
15
17
|
"conversation",
|
|
16
18
|
],
|
|
17
|
-
optional: false,
|
|
18
|
-
},
|
|
19
|
-
blocks: {
|
|
20
|
-
propDefinition: [
|
|
21
|
-
common.props.slack,
|
|
22
|
-
"blocks",
|
|
23
|
-
],
|
|
24
|
-
optional: false,
|
|
25
19
|
},
|
|
26
20
|
text: {
|
|
27
21
|
propDefinition: [
|
|
@@ -30,5 +24,20 @@ export default {
|
|
|
30
24
|
],
|
|
31
25
|
},
|
|
32
26
|
...common.props,
|
|
27
|
+
...buildBlocks.props,
|
|
28
|
+
},
|
|
29
|
+
methods: {
|
|
30
|
+
...common.methods,
|
|
31
|
+
...buildBlocks.methods,
|
|
32
|
+
async getGeneratedBlocks() {
|
|
33
|
+
return await buildBlocks.run.call(this); // call buildBlocks.run with the current context
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
async run({ $ }) {
|
|
37
|
+
this.blocks = await this.getGeneratedBlocks(); // set the blocks prop for common.run to use
|
|
38
|
+
const resp = await common.run.call(this, {
|
|
39
|
+
$,
|
|
40
|
+
}); // call common.run with the current context
|
|
41
|
+
return resp;
|
|
33
42
|
},
|
|
34
43
|
};
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "slack-send-custom-message",
|
|
6
6
|
name: "Send a Custom Message",
|
|
7
7
|
description: "Customize advanced setttings and send a message to a channel, group or user. See [postMessage](https://api.slack.com/methods/chat.postMessage) or [scheduleMessage](https://api.slack.com/methods/chat.scheduleMessage) docs here",
|
|
8
|
-
version: "0.2.
|
|
8
|
+
version: "0.2.17",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
slack: common.props.slack,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "slack-send-direct-message",
|
|
6
6
|
name: "Send a Direct Message",
|
|
7
7
|
description: "Send a direct message to a single user. See [postMessage](https://api.slack.com/methods/chat.postMessage) or [scheduleMessage](https://api.slack.com/methods/chat.scheduleMessage) docs here",
|
|
8
|
-
version: "0.2.
|
|
8
|
+
version: "0.2.18",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
slack: common.props.slack,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "slack-send-group-message",
|
|
6
6
|
name: "Send Group Message",
|
|
7
7
|
description: "Send a direct message to a group of users. See [postMessage](https://api.slack.com/methods/chat.postMessage) or [scheduleMessage](https://api.slack.com/methods/chat.scheduleMessage) docs here",
|
|
8
|
-
version: "0.2.
|
|
8
|
+
version: "0.2.18",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
slack: common.props.slack,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "slack-send-large-message",
|
|
6
6
|
name: "Send a Large Message (3000+ characters)",
|
|
7
7
|
description: "Send a large message (more than 3000 characters) to a channel, group or user. See [postMessage](https://api.slack.com/methods/chat.postMessage) or [scheduleMessage](https://api.slack.com/methods/chat.scheduleMessage) docs here",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.13",
|
|
9
9
|
type: "action",
|
|
10
10
|
props: {
|
|
11
11
|
slack: common.props.slack,
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "slack-send-message-private-channel",
|
|
7
7
|
name: "Send Message to a Private Channel",
|
|
8
8
|
description: "Send a message to a private channel and customize the name and avatar of the bot that posts the message. See [postMessage](https://api.slack.com/methods/chat.postMessage) or [scheduleMessage](https://api.slack.com/methods/chat.scheduleMessage) docs here",
|
|
9
|
-
version: "0.2.
|
|
9
|
+
version: "0.2.18",
|
|
10
10
|
type: "action",
|
|
11
11
|
props: {
|
|
12
12
|
slack: common.props.slack,
|
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
key: "slack-send-message-public-channel",
|
|
7
7
|
name: "Send Message to a Public Channel",
|
|
8
8
|
description: "Send a message to a public channel and customize the name and avatar of the bot that posts the message. See [postMessage](https://api.slack.com/methods/chat.postMessage) or [scheduleMessage](https://api.slack.com/methods/chat.scheduleMessage) docs here",
|
|
9
|
-
version: "0.2.
|
|
9
|
+
version: "0.2.17",
|
|
10
10
|
type: "action",
|
|
11
11
|
props: {
|
|
12
12
|
slack: common.props.slack,
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ export default {
|
|
|
6
6
|
...common,
|
|
7
7
|
key: "slack-new-message-in-channels",
|
|
8
8
|
name: "New Message In Channels (Instant)",
|
|
9
|
-
version: "1.0.
|
|
9
|
+
version: "1.0.14",
|
|
10
10
|
description: "Emit new event when a new message is posted to one or more channels",
|
|
11
11
|
type: "source",
|
|
12
12
|
dedupe: "unique",
|
|
@@ -44,6 +44,12 @@ export default {
|
|
|
44
44
|
"ignoreBot",
|
|
45
45
|
],
|
|
46
46
|
},
|
|
47
|
+
ignoreThreads: {
|
|
48
|
+
type: "boolean",
|
|
49
|
+
label: "Ignore replies in threads",
|
|
50
|
+
description: "Ignore replies to messages in threads",
|
|
51
|
+
optional: true,
|
|
52
|
+
},
|
|
47
53
|
},
|
|
48
54
|
methods: {
|
|
49
55
|
...common.methods,
|
|
@@ -66,6 +72,13 @@ export default {
|
|
|
66
72
|
if ((this.ignoreBot) && (event.subtype == "bot_message" || event.bot_id)) {
|
|
67
73
|
return;
|
|
68
74
|
}
|
|
75
|
+
console.log(event.s);
|
|
76
|
+
// There is no thread message type only the thread_ts field
|
|
77
|
+
// indicates if the message is part of a thread in the event.
|
|
78
|
+
if (this.ignoreThreads && event.thread_ts) {
|
|
79
|
+
console.log("Ignoring reply in thread");
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
69
82
|
if (this.resolveNames) {
|
|
70
83
|
if (event.user) {
|
|
71
84
|
event.user_id = event.user;
|