@pipedream/slack 0.4.28 → 0.4.30
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/README.md +4 -4
- 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 +3 -2
- package/actions/send-block-kit-message/send-block-kit-message.mjs +23 -13
- package/actions/send-custom-message/send-custom-message.mjs +3 -2
- package/actions/send-direct-message/send-direct-message.mjs +3 -2
- package/actions/send-group-message/send-group-message.mjs +3 -2
- package/actions/send-large-message/send-large-message.mjs +3 -2
- package/actions/send-message-private-channel/send-message-private-channel.mjs +3 -2
- package/actions/send-message-public-channel/send-message-public-channel.mjs +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,11 +21,11 @@ However, if you'd like to use your own bot registered with the [Slack API](https
|
|
|
21
21
|
|
|
22
22
|
The Slack Bot requires a bot token to allow your Pipedream workflows to authenticate as your bot. The extra set up steps allow you to list your custom bot on the Slack Marketplace, or install the bot on other workspaces as your bot's name instead of as Pipedream.
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
# Getting Started
|
|
25
25
|
|
|
26
26
|
You can install the Pipedream Slack app in the [Accounts](https://pipedream.com/accounts) section of your account, or directly in a workflow
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
## Accounts
|
|
29
29
|
|
|
30
30
|
1. Visit [https://pipedream.com/accounts](https://pipedream.com/accounts).
|
|
31
31
|
2. Click on the **Click Here To Connect An App** button in the top-right.
|
|
@@ -33,7 +33,7 @@ You can install the Pipedream Slack app in the [Accounts](https://pipedream.com/
|
|
|
33
33
|
4. This will open a new window asking you to allow Pipedream access to your Slack workspace. Choose the right workspace where you'd like to install the app, then click **Allow**.
|
|
34
34
|
5. That's it! You can now use this Slack account in any [actions](#workflow-actions), or [link it to any code step](/connected-accounts/#connecting-accounts).
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
## Within a workflow
|
|
37
37
|
|
|
38
38
|
1. [Create a new workflow](https://pipedream.com/new).
|
|
39
39
|
2. Select your trigger (HTTP, Cron, etc.).
|
|
@@ -42,6 +42,6 @@ You can install the Pipedream Slack app in the [Accounts](https://pipedream.com/
|
|
|
42
42
|
5. Click the **Connect Account** button near the top of the step. This will prompt you to select any existing Slack accounts you've previously authenticated with Pipedream, or you can select a **New** account. Clicking **New** opens a new window asking you to allow Pipedream access to your Slack workspace. Choose the right workspace where you'd like to install the app, then click **Allow**.
|
|
43
43
|
6. That's it! You can now connect to the Slack API using any of the Slack actions within a Pipedream workflow.
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
# Troubleshooting
|
|
46
46
|
|
|
47
47
|
Please [reach out](https://pipedream.com/support/) to the Pipedream team with any technical issues or questions about the Slack integration. We're happy to help!
|
|
@@ -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,10 +6,10 @@ 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,
|
|
13
13
|
thread_ts: {
|
|
14
14
|
propDefinition: [
|
|
15
15
|
slack,
|
|
@@ -43,5 +43,6 @@ export default {
|
|
|
43
43
|
"mrkdwn",
|
|
44
44
|
],
|
|
45
45
|
},
|
|
46
|
+
...common.props,
|
|
46
47
|
},
|
|
47
48
|
};
|
|
@@ -1,27 +1,21 @@
|
|
|
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: {
|
|
13
15
|
propDefinition: [
|
|
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: [
|
|
@@ -29,5 +23,21 @@ export default {
|
|
|
29
23
|
"notificationText",
|
|
30
24
|
],
|
|
31
25
|
},
|
|
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;
|
|
32
42
|
},
|
|
33
43
|
};
|
|
@@ -5,10 +5,10 @@ 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,
|
|
12
12
|
conversation: {
|
|
13
13
|
propDefinition: [
|
|
14
14
|
common.props.slack,
|
|
@@ -75,5 +75,6 @@ export default {
|
|
|
75
75
|
"thread_ts",
|
|
76
76
|
],
|
|
77
77
|
},
|
|
78
|
+
...common.props,
|
|
78
79
|
},
|
|
79
80
|
};
|
|
@@ -5,10 +5,10 @@ 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,
|
|
12
12
|
conversation: {
|
|
13
13
|
propDefinition: [
|
|
14
14
|
common.props.slack,
|
|
@@ -48,5 +48,6 @@ export default {
|
|
|
48
48
|
],
|
|
49
49
|
description: "Optionally provide an image URL to use as the bot icon for this message.",
|
|
50
50
|
},
|
|
51
|
+
...common.props,
|
|
51
52
|
},
|
|
52
53
|
};
|
|
@@ -5,10 +5,10 @@ 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,
|
|
12
12
|
conversation: {
|
|
13
13
|
propDefinition: [
|
|
14
14
|
common.props.slack,
|
|
@@ -48,5 +48,6 @@ export default {
|
|
|
48
48
|
],
|
|
49
49
|
description: "Optionally provide an image URL to use as the bot icon for this message.",
|
|
50
50
|
},
|
|
51
|
+
...common.props,
|
|
51
52
|
},
|
|
52
53
|
};
|
|
@@ -5,10 +5,10 @@ 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,
|
|
12
12
|
conversation: {
|
|
13
13
|
propDefinition: [
|
|
14
14
|
common.props.slack,
|
|
@@ -48,6 +48,7 @@ export default {
|
|
|
48
48
|
],
|
|
49
49
|
description: "Optionally provide an image URL to use as the bot icon for this message.",
|
|
50
50
|
},
|
|
51
|
+
...common.props,
|
|
51
52
|
},
|
|
52
53
|
async run() {
|
|
53
54
|
if (this.include_sent_via_pipedream_flag) {
|
|
@@ -6,10 +6,10 @@ 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,
|
|
13
13
|
conversation: {
|
|
14
14
|
propDefinition: [
|
|
15
15
|
common.props.slack,
|
|
@@ -54,5 +54,6 @@ export default {
|
|
|
54
54
|
],
|
|
55
55
|
description: "Optionally provide an image URL to use as the bot icon for this message.",
|
|
56
56
|
},
|
|
57
|
+
...common.props,
|
|
57
58
|
},
|
|
58
59
|
};
|
|
@@ -6,10 +6,10 @@ 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,
|
|
13
13
|
conversation: {
|
|
14
14
|
propDefinition: [
|
|
15
15
|
common.props.slack,
|
|
@@ -54,5 +54,6 @@ export default {
|
|
|
54
54
|
],
|
|
55
55
|
description: "Optionally provide an image URL to use as the bot icon for this message.",
|
|
56
56
|
},
|
|
57
|
+
...common.props,
|
|
57
58
|
},
|
|
58
59
|
};
|