@pipedream/slack_v2 0.0.1

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.
Files changed (58) hide show
  1. package/LICENSE +41 -0
  2. package/actions/add-emoji-reaction/add-emoji-reaction.mjs +48 -0
  3. package/actions/approve-workflow/approve-workflow.mjs +92 -0
  4. package/actions/archive-channel/archive-channel.mjs +38 -0
  5. package/actions/common/build-blocks.mjs +182 -0
  6. package/actions/common/send-message.mjs +264 -0
  7. package/actions/create-channel/create-channel.mjs +40 -0
  8. package/actions/create-reminder/create-reminder.mjs +52 -0
  9. package/actions/delete-file/delete-file.mjs +39 -0
  10. package/actions/delete-message/delete-message.mjs +45 -0
  11. package/actions/find-message/find-message.mjs +83 -0
  12. package/actions/find-user-by-email/find-user-by-email.mjs +32 -0
  13. package/actions/get-current-user/get-current-user.mjs +68 -0
  14. package/actions/get-file/get-file.mjs +59 -0
  15. package/actions/invite-user-to-channel/invite-user-to-channel.mjs +45 -0
  16. package/actions/kick-user/kick-user.mjs +56 -0
  17. package/actions/list-channels/list-channels.mjs +52 -0
  18. package/actions/list-files/list-files.mjs +93 -0
  19. package/actions/list-group-members/list-group-members.mjs +68 -0
  20. package/actions/list-members-in-channel/list-members-in-channel.mjs +71 -0
  21. package/actions/list-replies/list-replies.mjs +74 -0
  22. package/actions/list-users/list-users.mjs +60 -0
  23. package/actions/reply-to-a-message/reply-to-a-message.mjs +54 -0
  24. package/actions/send-block-kit-message/send-block-kit-message.mjs +48 -0
  25. package/actions/send-large-message/send-large-message.mjs +95 -0
  26. package/actions/send-message/send-message.mjs +56 -0
  27. package/actions/send-message-advanced/send-message-advanced.mjs +75 -0
  28. package/actions/send-message-to-channel/send-message-to-channel.mjs +45 -0
  29. package/actions/send-message-to-user-or-group/send-message-to-user-or-group.mjs +93 -0
  30. package/actions/set-channel-description/set-channel-description.mjs +37 -0
  31. package/actions/set-channel-topic/set-channel-topic.mjs +37 -0
  32. package/actions/set-status/set-status.mjs +49 -0
  33. package/actions/update-group-members/update-group-members.mjs +72 -0
  34. package/actions/update-message/update-message.mjs +59 -0
  35. package/actions/update-profile/update-profile.mjs +94 -0
  36. package/actions/upload-file/upload-file.mjs +104 -0
  37. package/common/constants.mjs +31 -0
  38. package/package.json +22 -0
  39. package/slack_v2.app.mjs +1112 -0
  40. package/sources/common/base.mjs +184 -0
  41. package/sources/common/constants.mjs +58 -0
  42. package/sources/new-channel-created/new-channel-created.mjs +32 -0
  43. package/sources/new-channel-created/test-event.mjs +44 -0
  44. package/sources/new-interaction-event-received/README.md +85 -0
  45. package/sources/new-interaction-event-received/new-interaction-event-received.mjs +105 -0
  46. package/sources/new-interaction-event-received/test-event.mjs +86 -0
  47. package/sources/new-keyword-mention/new-keyword-mention.mjs +99 -0
  48. package/sources/new-keyword-mention/test-event.mjs +28 -0
  49. package/sources/new-message-in-channels/new-message-in-channels.mjs +106 -0
  50. package/sources/new-message-in-channels/test-event.mjs +45 -0
  51. package/sources/new-reaction-added/new-reaction-added.mjs +119 -0
  52. package/sources/new-reaction-added/test-event.mjs +193 -0
  53. package/sources/new-saved-message/new-saved-message.mjs +32 -0
  54. package/sources/new-saved-message/test-event.mjs +37 -0
  55. package/sources/new-user-added/new-user-added.mjs +32 -0
  56. package/sources/new-user-added/test-event.mjs +48 -0
  57. package/sources/new-user-mention/new-user-mention.mjs +124 -0
  58. package/sources/new-user-mention/test-event.mjs +28 -0
@@ -0,0 +1,68 @@
1
+ import slack from "../../slack_v2.app.mjs";
2
+
3
+ export default {
4
+ key: "slack_v2-list-group-members",
5
+ name: "List Group Members",
6
+ description: "List all users in a User Group. [See the documentation](https://api.slack.com/methods/usergroups.users.list)",
7
+ version: "0.0.10",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: true,
12
+ },
13
+ type: "action",
14
+ props: {
15
+ slack,
16
+ userGroup: {
17
+ propDefinition: [
18
+ slack,
19
+ "userGroup",
20
+ ],
21
+ },
22
+ team: {
23
+ propDefinition: [
24
+ slack,
25
+ "team",
26
+ ],
27
+ optional: true,
28
+ description: "Encoded team id where the user group exists, required if org token is used.",
29
+ },
30
+ pageSize: {
31
+ propDefinition: [
32
+ slack,
33
+ "pageSize",
34
+ ],
35
+ },
36
+ numPages: {
37
+ propDefinition: [
38
+ slack,
39
+ "numPages",
40
+ ],
41
+ },
42
+ },
43
+ async run({ $ }) {
44
+ const members = [];
45
+ const params = {
46
+ usergroup: this.userGroup,
47
+ team_id: this.team,
48
+ limit: this.pageSize,
49
+ };
50
+ let page = 0;
51
+
52
+ do {
53
+ const {
54
+ users, response_metadata: { next_cursor: nextCursor },
55
+ } = await this.slack.listGroupMembers(params);
56
+ members.push(...users);
57
+ params.cursor = nextCursor;
58
+ page++;
59
+ } while (params.cursor && page < this.numPages);
60
+
61
+ if (members?.length) {
62
+ $.export("$summary", `Successfully retrieved ${members.length} user${members.length === 1
63
+ ? ""
64
+ : "s"}`);
65
+ }
66
+ return members;
67
+ },
68
+ };
@@ -0,0 +1,71 @@
1
+ import slack from "../../slack_v2.app.mjs";
2
+
3
+ export default {
4
+ key: "slack_v2-list-members-in-channel",
5
+ name: "List Members in Channel",
6
+ description: "Retrieve members of a channel. [See the documentation](https://api.slack.com/methods/conversations.members)",
7
+ version: "0.0.25",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: true,
12
+ },
13
+ type: "action",
14
+ props: {
15
+ slack,
16
+ conversation: {
17
+ propDefinition: [
18
+ slack,
19
+ "conversation",
20
+ ],
21
+ },
22
+ returnUsernames: {
23
+ type: "boolean",
24
+ label: "Return Usernames",
25
+ description: "Optionally, return usernames in addition to IDs",
26
+ optional: true,
27
+ },
28
+ pageSize: {
29
+ propDefinition: [
30
+ slack,
31
+ "pageSize",
32
+ ],
33
+ },
34
+ numPages: {
35
+ propDefinition: [
36
+ slack,
37
+ "numPages",
38
+ ],
39
+ },
40
+ },
41
+ async run({ $ }) {
42
+ let channelMembers = [];
43
+ const params = {
44
+ channel: this.conversation,
45
+ limit: this.pageSize,
46
+ };
47
+ let page = 0;
48
+
49
+ do {
50
+ const {
51
+ members, response_metadata: { next_cursor: nextCursor },
52
+ } = await this.slack.listChannelMembers(params);
53
+ channelMembers.push(...members);
54
+ params.cursor = nextCursor;
55
+ page++;
56
+ } while (params.cursor && page < this.numPages);
57
+
58
+ if (this.returnUsernames) {
59
+ const usernames = await this.slack.userNameLookup(channelMembers);
60
+ channelMembers = channelMembers?.map((id) => ({
61
+ id,
62
+ username: usernames[id],
63
+ })) || [];
64
+ }
65
+
66
+ $.export("$summary", `Successfully retrieved ${channelMembers.length} member${channelMembers.length === 1
67
+ ? ""
68
+ : "s"}`);
69
+ return channelMembers;
70
+ },
71
+ };
@@ -0,0 +1,74 @@
1
+ import constants from "../../common/constants.mjs";
2
+ import slack from "../../slack_v2.app.mjs";
3
+
4
+ export default {
5
+ key: "slack_v2-list-replies",
6
+ name: "List Replies",
7
+ description: "Retrieve a thread of messages posted to a conversation. [See the documentation](https://api.slack.com/methods/conversations.replies)",
8
+ version: "0.0.25",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ type: "action",
15
+ props: {
16
+ slack,
17
+ conversation: {
18
+ propDefinition: [
19
+ slack,
20
+ "conversation",
21
+ () => ({
22
+ types: [
23
+ constants.CHANNEL_TYPE.PUBLIC,
24
+ constants.CHANNEL_TYPE.PRIVATE,
25
+ ],
26
+ }),
27
+ ],
28
+ description: "Select a public or private channel",
29
+ },
30
+ timestamp: {
31
+ propDefinition: [
32
+ slack,
33
+ "messageTs",
34
+ ],
35
+ },
36
+ pageSize: {
37
+ propDefinition: [
38
+ slack,
39
+ "pageSize",
40
+ ],
41
+ },
42
+ numPages: {
43
+ propDefinition: [
44
+ slack,
45
+ "numPages",
46
+ ],
47
+ },
48
+ },
49
+ async run({ $ }) {
50
+ const replies = [];
51
+ const params = {
52
+ channel: this.conversation,
53
+ ts: this.timestamp,
54
+ limit: this.pageSize,
55
+ };
56
+ let page = 0;
57
+
58
+ do {
59
+ const {
60
+ messages, response_metadata: { next_cursor: nextCursor },
61
+ } = await this.slack.getConversationReplies(params);
62
+ replies.push(...messages);
63
+ params.cursor = nextCursor;
64
+ page++;
65
+ } while (params.cursor && page < this.numPages);
66
+
67
+ $.export("$summary", `Successfully retrieved ${replies.length} reply message${replies.length === 1
68
+ ? ""
69
+ : "s"}`);
70
+ return {
71
+ messages: replies,
72
+ };
73
+ },
74
+ };
@@ -0,0 +1,60 @@
1
+ import slack from "../../slack_v2.app.mjs";
2
+
3
+ export default {
4
+ key: "slack_v2-list-users",
5
+ name: "List Users",
6
+ description: "Return a list of all users in a workspace. [See the documentation](https://api.slack.com/methods/users.list)",
7
+ version: "0.0.25",
8
+ annotations: {
9
+ destructiveHint: false,
10
+ openWorldHint: true,
11
+ readOnlyHint: true,
12
+ },
13
+ type: "action",
14
+ props: {
15
+ slack,
16
+ teamId: {
17
+ propDefinition: [
18
+ slack,
19
+ "team",
20
+ ],
21
+ optional: true,
22
+ },
23
+ pageSize: {
24
+ propDefinition: [
25
+ slack,
26
+ "pageSize",
27
+ ],
28
+ },
29
+ numPages: {
30
+ propDefinition: [
31
+ slack,
32
+ "numPages",
33
+ ],
34
+ },
35
+ },
36
+ async run({ $ }) {
37
+ const users = [];
38
+ const params = {
39
+ team_id: this.teamId,
40
+ limit: this.pageSize,
41
+ };
42
+ let page = 0;
43
+
44
+ do {
45
+ const {
46
+ members, response_metadata: { next_cursor: nextCursor },
47
+ } = await this.slack.usersList(params);
48
+ users.push(...members);
49
+ params.cursor = nextCursor;
50
+ page++;
51
+ } while (params.cursor && page < (this.numPages ?? 1));
52
+
53
+ $.export("$summary", `Successfully retrieved ${users.length} user${users.length === 1
54
+ ? ""
55
+ : "s"}`);
56
+ return {
57
+ members: users,
58
+ };
59
+ },
60
+ };
@@ -0,0 +1,54 @@
1
+ import slack from "../../slack_v2.app.mjs";
2
+ import common from "../common/send-message.mjs";
3
+
4
+ export default {
5
+ ...common,
6
+ key: "slack_v2-reply-to-a-message",
7
+ name: "Reply to a Message Thread",
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.2.0",
10
+ annotations: {
11
+ destructiveHint: false,
12
+ openWorldHint: true,
13
+ readOnlyHint: false,
14
+ },
15
+ type: "action",
16
+ props: {
17
+ slack: common.props.slack,
18
+ conversation: {
19
+ propDefinition: [
20
+ slack,
21
+ "conversation",
22
+ ],
23
+ },
24
+ text: {
25
+ propDefinition: [
26
+ slack,
27
+ "text",
28
+ ],
29
+ },
30
+ mrkdwn: {
31
+ propDefinition: [
32
+ slack,
33
+ "mrkdwn",
34
+ ],
35
+ },
36
+ ...common.props,
37
+ replyToThread: {
38
+ ...common.props.replyToThread,
39
+ hidden: true,
40
+ },
41
+ thread_ts: {
42
+ propDefinition: [
43
+ slack,
44
+ "messageTs",
45
+ ],
46
+ },
47
+ thread_broadcast: {
48
+ propDefinition: [
49
+ slack,
50
+ "thread_broadcast",
51
+ ],
52
+ },
53
+ },
54
+ };
@@ -0,0 +1,48 @@
1
+ import buildBlocks from "../common/build-blocks.mjs";
2
+ import common from "../common/send-message.mjs";
3
+
4
+ export default {
5
+ ...common,
6
+ ...buildBlocks,
7
+ key: "slack_v2-send-block-kit-message",
8
+ name: "Build and Send a Block Kit Message",
9
+ description: "Configure custom blocks and send to a channel, group, or user. [See the documentation](https://api.slack.com/tools/block-kit-builder).",
10
+ version: "0.5.0",
11
+ annotations: {
12
+ destructiveHint: false,
13
+ openWorldHint: true,
14
+ readOnlyHint: false,
15
+ },
16
+ type: "action",
17
+ props: {
18
+ slack: common.props.slack,
19
+ conversation: {
20
+ propDefinition: [
21
+ common.props.slack,
22
+ "conversation",
23
+ ],
24
+ },
25
+ text: {
26
+ type: "string",
27
+ label: "Notification Text",
28
+ description: "Optionally provide a string for Slack to display as the new message notification (if you do not provide this, notification will be blank).",
29
+ optional: true,
30
+ },
31
+ ...common.props,
32
+ ...buildBlocks.props,
33
+ },
34
+ methods: {
35
+ ...common.methods,
36
+ ...buildBlocks.methods,
37
+ async getGeneratedBlocks() {
38
+ return await buildBlocks.run.call(this); // call buildBlocks.run with the current context
39
+ },
40
+ },
41
+ async run({ $ }) {
42
+ this.blocks = await this.getGeneratedBlocks(); // set the blocks prop for common.run to use
43
+ const resp = await common.run.call(this, {
44
+ $,
45
+ }); // call common.run with the current context
46
+ return resp;
47
+ },
48
+ };
@@ -0,0 +1,95 @@
1
+ import common from "../common/send-message.mjs";
2
+
3
+ export default {
4
+ ...common,
5
+ key: "slack_v2-send-large-message",
6
+ name: "Send a Large Message (3000+ characters)",
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.1.0",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: false,
13
+ },
14
+ type: "action",
15
+ props: {
16
+ slack: common.props.slack,
17
+ conversation: {
18
+ propDefinition: [
19
+ common.props.slack,
20
+ "conversation",
21
+ ],
22
+ },
23
+ text: {
24
+ propDefinition: [
25
+ common.props.slack,
26
+ "text",
27
+ ],
28
+ },
29
+ mrkdwn: {
30
+ propDefinition: [
31
+ common.props.slack,
32
+ "mrkdwn",
33
+ ],
34
+ },
35
+ ...common.props,
36
+ },
37
+ async run({ $ }) {
38
+ if (this.addToChannel) {
39
+ await this.slack.maybeAddAppToChannels([
40
+ this.conversation,
41
+ ]);
42
+ }
43
+
44
+ if (this.include_sent_via_pipedream_flag) {
45
+ const sentViaPipedreamText = this._makeSentViaPipedreamBlock();
46
+ this.text += `\n\n\n${sentViaPipedreamText.elements[0].text}`;
47
+ }
48
+
49
+ let metadataEventPayload;
50
+
51
+ if (this.metadata_event_type) {
52
+ if (typeof this.metadata_event_payload === "string") {
53
+ try {
54
+ metadataEventPayload = JSON.parse(this.metadata_event_payload);
55
+ } catch (error) {
56
+ throw new Error(`Invalid JSON in metadata_event_payload: ${error.message}`);
57
+ }
58
+ }
59
+
60
+ this.metadata = {
61
+ event_type: this.metadata_event_type,
62
+ event_payload: metadataEventPayload,
63
+ };
64
+ }
65
+
66
+ const obj = {
67
+ text: this.text,
68
+ channel: this.conversation,
69
+ as_user: this.as_user,
70
+ username: this.username,
71
+ icon_emoji: this.icon_emoji,
72
+ icon_url: this.icon_url,
73
+ mrkdwn: this.mrkdwn,
74
+ metadata: this.metadata || null,
75
+ reply_broadcast: this.thread_broadcast,
76
+ thread_ts: this.thread_ts,
77
+ unfurl_links: this.unfurl_links,
78
+ unfurl_media: this.unfurl_media,
79
+ };
80
+
81
+ let response;
82
+ if (this.post_at) {
83
+ obj.post_at = this.post_at;
84
+ response = await this.slack.scheduleMessage(obj);
85
+ } else {
86
+ response = await this.slack.postChatMessage(obj);
87
+ }
88
+ const { channel } = await this.slack.conversationsInfo({
89
+ channel: response.channel,
90
+ });
91
+ const channelName = await this.slack.getChannelDisplayName(channel);
92
+ $.export("$summary", `Successfully sent a message to ${channelName}`);
93
+ return response;
94
+ },
95
+ };
@@ -0,0 +1,56 @@
1
+ import common from "../common/send-message.mjs";
2
+ import constants from "../../common/constants.mjs";
3
+
4
+ export default {
5
+ ...common,
6
+ key: "slack_v2-send-message",
7
+ name: "Send Message",
8
+ description: "Send a message to a user, group, private channel or public channel. [See the documentation](https://api.slack.com/methods/chat.postMessage)",
9
+ version: "0.1.0",
10
+ annotations: {
11
+ destructiveHint: false,
12
+ openWorldHint: true,
13
+ readOnlyHint: false,
14
+ },
15
+ type: "action",
16
+ props: {
17
+ slack: common.props.slack,
18
+ channelType: {
19
+ type: "string",
20
+ label: "Channel Type",
21
+ description: "The type of channel to send to. User/Direct Message (im), Group (mpim), Private Channel or Public Channel",
22
+ async options() {
23
+ return constants.CHANNEL_TYPE_OPTIONS;
24
+ },
25
+ },
26
+ conversation: {
27
+ propDefinition: [
28
+ common.props.slack,
29
+ "conversation",
30
+ (c) => ({
31
+ types: c.channelType === "Channels"
32
+ ? [
33
+ constants.CHANNEL_TYPE.PUBLIC,
34
+ constants.CHANNEL_TYPE.PRIVATE,
35
+ ]
36
+ : [
37
+ c.channelType,
38
+ ],
39
+ }),
40
+ ],
41
+ },
42
+ text: {
43
+ propDefinition: [
44
+ common.props.slack,
45
+ "text",
46
+ ],
47
+ },
48
+ mrkdwn: {
49
+ propDefinition: [
50
+ common.props.slack,
51
+ "mrkdwn",
52
+ ],
53
+ },
54
+ ...common.props,
55
+ },
56
+ };
@@ -0,0 +1,75 @@
1
+ import common from "../common/send-message.mjs";
2
+ import buildBlocks from "../common/build-blocks.mjs";
3
+
4
+ export default {
5
+ ...common,
6
+ ...buildBlocks,
7
+ key: "slack_v2-send-message-advanced",
8
+ name: "Send Message (Advanced)",
9
+ description: "Customize advanced settings 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",
10
+ version: "0.1.0",
11
+ annotations: {
12
+ destructiveHint: false,
13
+ openWorldHint: true,
14
+ readOnlyHint: false,
15
+ },
16
+ type: "action",
17
+ props: {
18
+ slack: common.props.slack,
19
+ conversation: {
20
+ propDefinition: [
21
+ common.props.slack,
22
+ "conversation",
23
+ ],
24
+ },
25
+ text: {
26
+ propDefinition: [
27
+ common.props.slack,
28
+ "text",
29
+ ],
30
+ description: "If you're using `blocks`, this is used as a fallback string to display in notifications. If you aren't, this is the main body text of the message. It can be formatted as plain text, or with mrkdwn.",
31
+ },
32
+ mrkdwn: {
33
+ propDefinition: [
34
+ common.props.slack,
35
+ "mrkdwn",
36
+ ],
37
+ },
38
+ attachments: {
39
+ propDefinition: [
40
+ common.props.slack,
41
+ "attachments",
42
+ ],
43
+ },
44
+ parse: {
45
+ propDefinition: [
46
+ common.props.slack,
47
+ "parse",
48
+ ],
49
+ },
50
+ link_names: {
51
+ propDefinition: [
52
+ common.props.slack,
53
+ "link_names",
54
+ ],
55
+ },
56
+ ...common.props,
57
+ ...buildBlocks.props,
58
+ },
59
+ methods: {
60
+ ...common.methods,
61
+ ...buildBlocks.methods,
62
+ async getGeneratedBlocks() {
63
+ return await buildBlocks.run.call(this); // call buildBlocks.run with the current context
64
+ },
65
+ },
66
+ async run({ $ }) {
67
+ if (this.passArrayOrConfigure) {
68
+ this.blocks = await this.getGeneratedBlocks(); // set the blocks prop for common.run to use
69
+ }
70
+ const resp = await common.run.call(this, {
71
+ $,
72
+ }); // call common.run with the current context
73
+ return resp;
74
+ },
75
+ };
@@ -0,0 +1,45 @@
1
+ import common from "../common/send-message.mjs";
2
+ import constants from "../../common/constants.mjs";
3
+
4
+ export default {
5
+ ...common,
6
+ key: "slack_v2-send-message-to-channel",
7
+ name: "Send Message to Channel",
8
+ description: "Send a message to a public or private channel. [See the documentation](https://api.slack.com/methods/chat.postMessage)",
9
+ version: "0.1.0",
10
+ annotations: {
11
+ destructiveHint: false,
12
+ openWorldHint: true,
13
+ readOnlyHint: false,
14
+ },
15
+ type: "action",
16
+ props: {
17
+ slack: common.props.slack,
18
+ conversation: {
19
+ propDefinition: [
20
+ common.props.slack,
21
+ "conversation",
22
+ () => ({
23
+ types: [
24
+ constants.CHANNEL_TYPE.PUBLIC,
25
+ constants.CHANNEL_TYPE.PRIVATE,
26
+ ],
27
+ }),
28
+ ],
29
+ description: "Select a public or private channel",
30
+ },
31
+ text: {
32
+ propDefinition: [
33
+ common.props.slack,
34
+ "text",
35
+ ],
36
+ },
37
+ mrkdwn: {
38
+ propDefinition: [
39
+ common.props.slack,
40
+ "mrkdwn",
41
+ ],
42
+ },
43
+ ...common.props,
44
+ },
45
+ };