@pipedream/slack_v2 0.6.1 → 0.8.0
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/add-emoji-reaction/add-emoji-reaction.mjs +1 -1
- package/actions/add-reaction/add-reaction.mjs +2 -1
- package/actions/archive-channel/archive-channel.mjs +1 -1
- package/actions/browse-files/browse-files.mjs +2 -1
- package/actions/create-channel/create-channel.mjs +1 -1
- package/actions/create-reminder/create-reminder.mjs +1 -1
- package/actions/delete-file/delete-file.mjs +1 -1
- package/actions/delete-message/delete-message.mjs +49 -6
- package/actions/edit-message/edit-message.mjs +2 -1
- package/actions/find-message/find-message.mjs +1 -1
- package/actions/find-user-by-email/find-user-by-email.mjs +1 -1
- package/actions/find-user-by-id/find-user-by-id.mjs +1 -1
- package/actions/get-channel-details/get-channel-details.mjs +6 -3
- package/actions/get-channel-history/get-channel-history.mjs +20 -5
- package/actions/get-current-user/get-current-user.mjs +2 -2
- package/actions/get-file/get-file.mjs +1 -1
- package/actions/get-thread-replies/get-thread-replies.mjs +18 -2
- package/actions/get-user-details/get-user-details.mjs +9 -4
- package/actions/invite-user-to-channel/invite-user-to-channel.mjs +72 -14
- package/actions/kick-user/kick-user.mjs +1 -1
- package/actions/list-channels/list-channels.mjs +55 -6
- package/actions/list-emojis/list-emojis.mjs +1 -1
- package/actions/list-files/list-files.mjs +1 -1
- package/actions/list-group-members/list-group-members.mjs +1 -1
- package/actions/list-icon-emoji-options/list-icon-emoji-options.mjs +1 -1
- package/actions/list-members-in-channel/list-members-in-channel.mjs +7 -3
- package/actions/list-messages/list-messages.mjs +7 -3
- package/actions/list-reminder-options/list-reminder-options.mjs +1 -1
- package/actions/list-replies/list-replies.mjs +1 -1
- package/actions/list-user-group-options/list-user-group-options.mjs +1 -1
- package/actions/list-users/list-users.mjs +1 -1
- package/actions/post-message/post-message.mjs +2 -1
- package/actions/reply-to-a-message/reply-to-a-message.mjs +1 -1
- package/actions/search/search.mjs +2 -1
- package/actions/send-block-kit-message/send-block-kit-message.mjs +1 -1
- package/actions/send-large-message/send-large-message.mjs +1 -1
- package/actions/send-message/send-message.mjs +1 -1
- package/actions/send-message-advanced/send-message-advanced.mjs +1 -1
- package/actions/send-message-to-channel/send-message-to-channel.mjs +1 -1
- package/actions/send-message-to-user-or-group/send-message-to-user-or-group.mjs +1 -1
- package/actions/set-channel-description/set-channel-description.mjs +1 -1
- package/actions/set-channel-topic/set-channel-topic.mjs +7 -4
- package/actions/set-status/set-status.mjs +1 -1
- package/actions/update-group-members/update-group-members.mjs +1 -1
- package/actions/update-message/update-message.mjs +1 -1
- package/actions/update-profile/update-profile.mjs +1 -1
- package/actions/upload-file/upload-file.mjs +1 -1
- package/actions/verify-slack-signature/verify-slack-signature.mjs +1 -1
- package/common/utils.mjs +69 -0
- package/package.json +1 -1
- package/slack_v2.app.mjs +99 -4
- package/sources/new-channel-created/new-channel-created.mjs +1 -1
- package/sources/new-interaction-event-received/new-interaction-event-received.mjs +1 -1
- package/sources/new-keyword-mention/new-keyword-mention.mjs +1 -1
- package/sources/new-message-in-channels/new-message-in-channels.mjs +1 -1
- package/sources/new-private-channel-created/new-private-channel-created.mjs +1 -1
- package/sources/new-reaction-added/new-reaction-added.mjs +1 -1
- package/sources/new-saved-message/new-saved-message.mjs +1 -1
- package/sources/new-user-added/new-user-added.mjs +1 -1
- package/sources/new-user-mention/new-user-mention.mjs +1 -1
- package/actions/approve-workflow/approve-workflow.mjs +0 -92
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "slack_v2-add-emoji-reaction",
|
|
5
5
|
name: "Add Emoji Reaction",
|
|
6
6
|
description: "Add an emoji reaction to a message. [See the documentation](https://api.slack.com/methods/reactions.add)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.23",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
1
2
|
import slack from "../../slack_v2.app.mjs";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
@@ -9,7 +10,7 @@ export default {
|
|
|
9
10
|
+ " Use **Get Channel History** or **Search** to find the message timestamp."
|
|
10
11
|
+ " Emoji name should be without colons (e.g. `thumbsup`, `fire`, `heart`)."
|
|
11
12
|
+ " [See the documentation](https://api.slack.com/methods/reactions.add)",
|
|
12
|
-
version: "0.0.
|
|
13
|
+
version: "0.0.3",
|
|
13
14
|
type: "action",
|
|
14
15
|
annotations: {
|
|
15
16
|
destructiveHint: false,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "slack_v2-archive-channel",
|
|
6
6
|
name: "Archive Channel",
|
|
7
7
|
description: "Archive a channel. [See the documentation](https://api.slack.com/methods/conversations.archive)",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.31",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: true,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
1
2
|
import slack from "../../slack_v2.app.mjs";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
@@ -9,7 +10,7 @@ export default {
|
|
|
9
10
|
+ " Filter by file type (e.g. `images`, `pdfs`, `snippets`)."
|
|
10
11
|
+ " Returns file metadata including name, type, size, and download URL."
|
|
11
12
|
+ " [See the documentation](https://api.slack.com/methods/files.list)",
|
|
12
|
-
version: "0.0.
|
|
13
|
+
version: "0.0.3",
|
|
13
14
|
type: "action",
|
|
14
15
|
annotations: {
|
|
15
16
|
destructiveHint: false,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "slack_v2-create-channel",
|
|
5
5
|
name: "Create a Channel",
|
|
6
6
|
description: "Create a new channel. [See the documentation](https://api.slack.com/methods/conversations.create)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.31",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "slack_v2-create-reminder",
|
|
5
5
|
name: "Create Reminder",
|
|
6
6
|
description: "Create a reminder. [See the documentation](https://api.slack.com/methods/reminders.add)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.32",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "slack_v2-delete-file",
|
|
5
5
|
name: "Delete File",
|
|
6
6
|
description: "Delete a file. [See the documentation](https://api.slack.com/methods/files.delete)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.31",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: true,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
1
2
|
import slack from "../../slack_v2.app.mjs";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
key: "slack_v2-delete-message",
|
|
5
6
|
name: "Delete Message",
|
|
6
|
-
description:
|
|
7
|
-
|
|
7
|
+
description:
|
|
8
|
+
"Permanently delete a message. **This cannot be undone — confirm the exact message with the"
|
|
9
|
+
+ " user before calling it.** Identify the message first with **Get Channel History** or"
|
|
10
|
+
+ " **Search** and quote its text back, rather than deleting by position ('the last one')."
|
|
11
|
+
+ " Accepts a channel ID or NAME for the conversation, resolved automatically. Slack only"
|
|
12
|
+
+ " lets an identity delete its own messages, so this deletes as whichever identity posted:"
|
|
13
|
+
+ " it retries automatically with the other identity if the first attempt returns"
|
|
14
|
+
+ " `cant_delete_message`. [See the documentation](https://api.slack.com/methods/chat.delete)",
|
|
15
|
+
version: "0.2.1",
|
|
8
16
|
annotations: {
|
|
9
17
|
destructiveHint: true,
|
|
10
18
|
openWorldHint: true,
|
|
@@ -30,15 +38,50 @@ export default {
|
|
|
30
38
|
slack,
|
|
31
39
|
"as_user",
|
|
32
40
|
],
|
|
33
|
-
description: "Pass true to
|
|
41
|
+
description: "Pass true to delete the message as the authed user. Bot users in this context are considered authed users. Leave unset — the action falls back to the other identity automatically when Slack refuses.",
|
|
34
42
|
},
|
|
35
43
|
},
|
|
36
44
|
async run({ $ }) {
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
// conversation accepts a channel name as well as an ID (like every other AI-optimized
|
|
46
|
+
// action in this app) — resolve it once up front so both delete attempts below reuse
|
|
47
|
+
// the same ID instead of re-resolving (or silently failing on a name) per attempt.
|
|
48
|
+
const channel = await this.slack.resolveChannelId(this.conversation);
|
|
49
|
+
|
|
50
|
+
// Slack refuses `chat.delete` unless the calling identity authored the message, and
|
|
51
|
+
// this app picks the token from `as_user`: false routes to the BOT token, true/unset
|
|
52
|
+
// to the USER token. post-message sends no as_user, so it posts as the USER — meaning
|
|
53
|
+
// the old default here (as_user: false → bot token) could not delete anything
|
|
54
|
+
// post-message had just created. "Post it, then take it back" failed every single
|
|
55
|
+
// time with cant_delete_message. Rather than flip the default (a behaviour change for
|
|
56
|
+
// existing workflows), try the configured identity and fall back to the other one.
|
|
57
|
+
const attempt = (as_user) => this.slack.deleteMessage({
|
|
58
|
+
channel,
|
|
39
59
|
ts: this.timestamp,
|
|
40
|
-
as_user
|
|
60
|
+
as_user,
|
|
41
61
|
});
|
|
62
|
+
|
|
63
|
+
// makeRequest() routes to the bot token on `as_user === false` and to the user token for
|
|
64
|
+
// anything else, so the "other identity" is a flip between exactly those two values.
|
|
65
|
+
// Deriving it with `!this.as_user` made the fallback a no-op whenever as_user arrived
|
|
66
|
+
// nullish: undefined and true both route to the user token, so it retried as the same
|
|
67
|
+
// identity that had just been refused. Attempt 1 still passes the configured value
|
|
68
|
+
// verbatim, so a working call is byte-identical to before.
|
|
69
|
+
const other = this.as_user === false;
|
|
70
|
+
|
|
71
|
+
// The fallback only reaches a genuinely different identity when a bot token exists:
|
|
72
|
+
// that's the only case where flipping as_user changes which token makeRequest() picks.
|
|
73
|
+
// Without a bot token both attempts hit the same user token, so retrying just repeats
|
|
74
|
+
// the same cant_delete_message failure.
|
|
75
|
+
const hasBotToken = Boolean(this.slack.getBotToken());
|
|
76
|
+
|
|
77
|
+
let response;
|
|
78
|
+
try {
|
|
79
|
+
response = await attempt(this.as_user);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
if (!hasBotToken || !`${error}`.includes("cant_delete_message")) throw error;
|
|
82
|
+
response = await attempt(other);
|
|
83
|
+
}
|
|
84
|
+
|
|
42
85
|
$.export("$summary", "Successfully deleted message.");
|
|
43
86
|
return response;
|
|
44
87
|
},
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
1
2
|
import slack from "../../slack_v2.app.mjs";
|
|
2
3
|
import { ConfigurationError } from "@pipedream/platform";
|
|
3
4
|
|
|
@@ -10,7 +11,7 @@ export default {
|
|
|
10
11
|
+ " Requires the message timestamp (`ts`) from **Get Channel History** or **Post Message**."
|
|
11
12
|
+ " You can only edit messages posted by the same token/user."
|
|
12
13
|
+ " [See the documentation](https://api.slack.com/methods/chat.update)",
|
|
13
|
-
version: "0.0.
|
|
14
|
+
version: "0.0.3",
|
|
14
15
|
type: "action",
|
|
15
16
|
annotations: {
|
|
16
17
|
destructiveHint: false,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "slack_v2-find-message",
|
|
5
5
|
name: "Find Message",
|
|
6
6
|
description: "Find a Slack message. [See the documentation](https://api.slack.com/methods/assistant.search.context)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.5",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "slack_v2-find-user-by-email",
|
|
5
5
|
name: "Find User by Email",
|
|
6
6
|
description: "Find a user by matching against their email. [See the documentation](https://api.slack.com/methods/users.lookupByEmail)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.30",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "slack_v2-find-user-by-id",
|
|
5
5
|
name: "Find User by ID",
|
|
6
6
|
description: "Find a user by their ID. Returns user profile information including name, email (requires `users:read.email` scope), timezone, and status. [See the documentation](https://api.slack.com/methods/users.info)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.7",
|
|
8
8
|
type: "action",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
@@ -3,8 +3,8 @@ import slack from "../../slack_v2.app.mjs";
|
|
|
3
3
|
export default {
|
|
4
4
|
key: "slack_v2-get-channel-details",
|
|
5
5
|
name: "Get Channel Details",
|
|
6
|
-
description: "Retrieve details for a Slack channel by
|
|
7
|
-
version: "0.
|
|
6
|
+
description: "Retrieve details for a Slack channel, specified by ID or by name — names are resolved automatically. [See the documentation](https://api.slack.com/methods/conversations.info)",
|
|
7
|
+
version: "0.1.1",
|
|
8
8
|
type: "action",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
@@ -36,8 +36,11 @@ export default {
|
|
|
36
36
|
},
|
|
37
37
|
},
|
|
38
38
|
async run({ $ }) {
|
|
39
|
+
// Accept a channel NAME as well as an ID — agents routinely pass the "#name" they read
|
|
40
|
+
// in the prompt, and conversations.info answers that with channel_not_found.
|
|
41
|
+
const channelId = await this.slack.resolveChannelId(this.channel);
|
|
39
42
|
const response = await this.slack.conversationsInfo({
|
|
40
|
-
channel:
|
|
43
|
+
channel: channelId,
|
|
41
44
|
include_locale: this.includeLocale,
|
|
42
45
|
include_num_members: this.includeNumberOfMembers,
|
|
43
46
|
});
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
2
|
+
import utils from "../../common/utils.mjs";
|
|
1
3
|
import slack from "../../slack_v2.app.mjs";
|
|
2
4
|
|
|
3
5
|
export default {
|
|
4
6
|
key: "slack_v2-get-channel-history",
|
|
5
7
|
name: "Get Channel History",
|
|
6
8
|
description:
|
|
7
|
-
"Read the recent message history from a specific channel."
|
|
9
|
+
"Read the recent message history from a specific channel or direct message (DM)."
|
|
8
10
|
+ " Accepts a channel ID or channel name (resolved automatically)."
|
|
9
|
-
+ "
|
|
11
|
+
+ " To read a DM, pass the other person's **user ID** (e.g. `U1234567890`) as the channel — pass your OWN user ID to read your conversation with yourself."
|
|
12
|
+
+ " Use this when you want to see a channel's or DM's latest messages — unlike **Search** which finds messages by keyword."
|
|
10
13
|
+ " Returns messages with text, timestamps (ts), reactions, and user IDs."
|
|
11
14
|
+ " Message timestamps can be used with **Get Thread Replies**, **Edit Message**, and **Add Reaction**."
|
|
15
|
+
+ " **Pass `fields`** (e.g. `text,ts,user`) unless you need full message objects — raw Slack"
|
|
16
|
+
+ " messages carry blocks, attachments and edit metadata, so a busy channel can run to tens"
|
|
17
|
+
+ " of thousands of characters and be truncated before you see any of it."
|
|
12
18
|
+ " [See the documentation](https://api.slack.com/methods/conversations.history)",
|
|
13
|
-
version: "0.0
|
|
19
|
+
version: "0.2.0",
|
|
14
20
|
type: "action",
|
|
15
21
|
annotations: {
|
|
16
22
|
destructiveHint: false,
|
|
@@ -22,7 +28,7 @@ export default {
|
|
|
22
28
|
channel: {
|
|
23
29
|
type: "string",
|
|
24
30
|
label: "Channel",
|
|
25
|
-
description: "Channel ID (e.g. `C1234567890`) or channel name (e.g. `general` or `#general`). Resolved automatically.",
|
|
31
|
+
description: "Channel ID (e.g. `C1234567890`) or channel name (e.g. `general` or `#general`). For a direct message, pass a user ID (e.g. `U1234567890`) — including your own, to read your self-DM. Resolved automatically.",
|
|
26
32
|
},
|
|
27
33
|
limit: {
|
|
28
34
|
type: "integer",
|
|
@@ -43,6 +49,12 @@ export default {
|
|
|
43
49
|
description: "Only messages before this Unix timestamp. Default: now.",
|
|
44
50
|
optional: true,
|
|
45
51
|
},
|
|
52
|
+
fields: {
|
|
53
|
+
type: "string[]",
|
|
54
|
+
label: "Fields",
|
|
55
|
+
description: "Message properties to return, e.g. `text`, `ts`, `user`, `thread_ts`, `reply_count`, `reactions`. Recommended: `[\"text\", \"ts\", \"user\"]`. Omit only when you need the full message objects.",
|
|
56
|
+
optional: true,
|
|
57
|
+
},
|
|
46
58
|
},
|
|
47
59
|
async run({ $ }) {
|
|
48
60
|
const channelId = await this.slack.resolveChannelId(this.channel);
|
|
@@ -54,11 +66,14 @@ export default {
|
|
|
54
66
|
include_all_metadata: true,
|
|
55
67
|
});
|
|
56
68
|
const messages = response.messages || [];
|
|
69
|
+
|
|
57
70
|
$.export("$summary", `Retrieved ${messages.length} message${messages.length === 1
|
|
58
71
|
? ""
|
|
59
72
|
: "s"} from channel`);
|
|
60
73
|
return {
|
|
61
|
-
|
|
74
|
+
// `fields` is ADDITIVE: omitted returns exactly what this action always returned.
|
|
75
|
+
// Measured at 17k chars average (worst 49k) without it.
|
|
76
|
+
messages: utils.projectFields(messages, this.fields),
|
|
62
77
|
};
|
|
63
78
|
},
|
|
64
79
|
};
|
|
@@ -3,8 +3,8 @@ import slack from "../../slack_v2.app.mjs";
|
|
|
3
3
|
export default {
|
|
4
4
|
key: "slack_v2-get-current-user",
|
|
5
5
|
name: "Get Current User",
|
|
6
|
-
description: "
|
|
7
|
-
version: "0.0.
|
|
6
|
+
description: "Do NOT use for a plain \"who am I\" / \"what's my user ID\" question — call **Get User Details** for that; it answers the same question with a far smaller payload. Use this ONLY when you specifically need the full member profile: locale, timezone, presence/status, admin and owner flags, name variants, or workspace domain and enterprise metadata. Combines `auth.test`, `users.info`, `users.profile.get` and `team.info`. [See Slack API docs](https://api.slack.com/methods/auth.test).",
|
|
7
|
+
version: "0.0.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "slack_v2-get-file",
|
|
6
6
|
name: "Get File",
|
|
7
7
|
description: "Return information about a file. [See the documentation](https://api.slack.com/methods/files.info)",
|
|
8
|
-
version: "0.1.
|
|
8
|
+
version: "0.1.6",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
2
|
+
import utils from "../../common/utils.mjs";
|
|
1
3
|
import slack from "../../slack_v2.app.mjs";
|
|
2
4
|
|
|
3
5
|
export default {
|
|
@@ -8,8 +10,11 @@ export default {
|
|
|
8
10
|
+ " Accepts a channel ID or channel name (resolved automatically)."
|
|
9
11
|
+ " Use **Get Channel History** or **Search** to find the parent message's timestamp (thread_ts)."
|
|
10
12
|
+ " Returns the parent message followed by all replies in chronological order."
|
|
13
|
+
+ " **Pass `fields`** (e.g. `text,ts,user`) unless you need full message objects — raw"
|
|
14
|
+
+ " Slack messages carry blocks, attachments and edit metadata, so a long thread can run"
|
|
15
|
+
+ " to tens of thousands of characters and be truncated before you see any of it."
|
|
11
16
|
+ " [See the documentation](https://api.slack.com/methods/conversations.replies)",
|
|
12
|
-
version: "0.
|
|
17
|
+
version: "0.1.1",
|
|
13
18
|
type: "action",
|
|
14
19
|
annotations: {
|
|
15
20
|
destructiveHint: false,
|
|
@@ -35,6 +40,12 @@ export default {
|
|
|
35
40
|
default: 50,
|
|
36
41
|
optional: true,
|
|
37
42
|
},
|
|
43
|
+
fields: {
|
|
44
|
+
type: "string[]",
|
|
45
|
+
label: "Fields",
|
|
46
|
+
description: "Message properties to return, e.g. `text`, `ts`, `user`, `thread_ts`, `reply_count`, `reactions`, `permalink`. Recommended: `[\"text\", \"ts\", \"user\"]`. Omit only when you need the full message objects.",
|
|
47
|
+
optional: true,
|
|
48
|
+
},
|
|
38
49
|
},
|
|
39
50
|
async run({ $ }) {
|
|
40
51
|
const channelId = await this.slack.resolveChannelId(this.channel);
|
|
@@ -45,11 +56,16 @@ export default {
|
|
|
45
56
|
});
|
|
46
57
|
const messages = response.messages || [];
|
|
47
58
|
const replyCount = Math.max(messages.length - 1, 0);
|
|
59
|
+
|
|
48
60
|
$.export("$summary", `Retrieved ${replyCount} repl${replyCount === 1
|
|
49
61
|
? "y"
|
|
50
62
|
: "ies"} in thread`);
|
|
51
63
|
return {
|
|
52
|
-
|
|
64
|
+
// `fields` is ADDITIVE: omitted returns exactly what this action always returned.
|
|
65
|
+
// Supplied, it plucks per message — measured at 25k chars average on a busy thread,
|
|
66
|
+
// which is the difference between the agent reading the replies and being handed a
|
|
67
|
+
// file path instead.
|
|
68
|
+
messages: utils.projectFields(messages, this.fields),
|
|
53
69
|
};
|
|
54
70
|
},
|
|
55
71
|
};
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
1
2
|
import slack from "../../slack_v2.app.mjs";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
key: "slack_v2-get-user-details",
|
|
5
6
|
name: "Get User Details",
|
|
6
7
|
description:
|
|
7
|
-
"
|
|
8
|
+
"**Use when the user asks who am I, what's my user ID, what's my username, which workspace"
|
|
9
|
+
+ " am I in, or what's my email** — this is the default identity lookup and the one to call"
|
|
10
|
+
+ " first in any session."
|
|
8
11
|
+ " Returns user ID, name, email, timezone, profile, and workspace metadata."
|
|
9
|
-
+ "
|
|
10
|
-
+ "
|
|
12
|
+
+ " Other tools like **Search** and **List Channels** can then filter by your user ID,"
|
|
13
|
+
+ " and **Post Message** can use it as the channel to DM yourself."
|
|
14
|
+
+ " Prefer this over **Get Current User**, which returns a much larger payload and is only"
|
|
15
|
+
+ " needed for full profile detail (locale, status, admin flags)."
|
|
11
16
|
+ " [See the documentation](https://api.slack.com/methods/auth.test)",
|
|
12
|
-
version: "0.0.
|
|
17
|
+
version: "0.0.3",
|
|
13
18
|
type: "action",
|
|
14
19
|
annotations: {
|
|
15
20
|
destructiveHint: false,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
1
2
|
import slack from "../../slack_v2.app.mjs";
|
|
2
3
|
|
|
3
4
|
export default {
|
|
4
5
|
key: "slack_v2-invite-user-to-channel",
|
|
5
6
|
name: "Invite User to Channel",
|
|
6
|
-
description: "Invite
|
|
7
|
-
version: "0.
|
|
7
|
+
description: "Invite one or more users to an existing channel. Accepts a channel ID or NAME, and a user ID, EMAIL address or display name — all resolved automatically. Pass several users as a comma-separated list. [See the documentation](https://api.slack.com/methods/conversations.invite)",
|
|
8
|
+
version: "0.1.1",
|
|
8
9
|
annotations: {
|
|
9
10
|
destructiveHint: false,
|
|
10
11
|
openWorldHint: true,
|
|
@@ -27,19 +28,76 @@ export default {
|
|
|
27
28
|
},
|
|
28
29
|
},
|
|
29
30
|
async run({ $ }) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
// Agents pass whatever identifier the user said — an email in "invite
|
|
32
|
+
// dylan@pipedream.com", a "#channel-name" lifted from the prompt. The raw API answers
|
|
33
|
+
// user_not_found / channel_not_found, which reads as a broken tool rather than a
|
|
34
|
+
// wrong-shaped argument. Every AI-optimized tool in this app resolves names already.
|
|
35
|
+
//
|
|
36
|
+
// resolveUserIds (plural) so the comma-separated list Slack has always accepted here
|
|
37
|
+
// keeps working — each token is resolved independently.
|
|
38
|
+
const channel = await this.slack.resolveChannelId(this.conversation);
|
|
39
|
+
const user = await this.slack.resolveUserIds(this.user);
|
|
40
|
+
const userIds = user.split(",").filter(Boolean);
|
|
41
|
+
|
|
42
|
+
if (!userIds.length) {
|
|
43
|
+
throw new ConfigurationError(`No valid user was resolved from "${this.user}". Provide a user ID, an email address, or a display name.`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// already_in_channel means the invite is a no-op because the user's already a member.
|
|
47
|
+
// cant_invite_self means the resolved user IS the calling identity — Slack refuses to
|
|
48
|
+
// let an identity invite itself, which reads the same way to the caller: the user is
|
|
49
|
+
// already effectively "in" the channel via that identity, no action needed.
|
|
50
|
+
const isNoopOutcome = (error) => `${error}`.includes("already_in_channel") || `${error}`.includes("cant_invite_self");
|
|
51
|
+
|
|
52
|
+
if (userIds.length === 1) {
|
|
53
|
+
try {
|
|
54
|
+
const response = await this.slack.inviteToConversation({
|
|
55
|
+
channel,
|
|
56
|
+
users: user,
|
|
57
|
+
});
|
|
58
|
+
$.export("$summary", `Successfully invited user ${this.user} to channel with ID ${channel}`);
|
|
59
|
+
return response;
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (isNoopOutcome(error)) {
|
|
62
|
+
$.export("$summary", `The user ${this.user} is already in the channel`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
throw error;
|
|
41
66
|
}
|
|
42
|
-
throw error;
|
|
43
67
|
}
|
|
68
|
+
|
|
69
|
+
// already_in_channel/cant_invite_self can only be safely swallowed for a single-user
|
|
70
|
+
// request. For multiple users, one bad token turning the whole request into "success"
|
|
71
|
+
// would hide that the others were never invited, so each user is invited individually
|
|
72
|
+
// and reported on its own.
|
|
73
|
+
const results = [];
|
|
74
|
+
for (const userId of userIds) {
|
|
75
|
+
try {
|
|
76
|
+
await this.slack.inviteToConversation({
|
|
77
|
+
channel,
|
|
78
|
+
users: userId,
|
|
79
|
+
});
|
|
80
|
+
results.push({
|
|
81
|
+
user: userId,
|
|
82
|
+
status: "invited",
|
|
83
|
+
});
|
|
84
|
+
} catch (error) {
|
|
85
|
+
results.push({
|
|
86
|
+
user: userId,
|
|
87
|
+
status: isNoopOutcome(error)
|
|
88
|
+
? "already_in_channel"
|
|
89
|
+
: "error",
|
|
90
|
+
error: `${error}`,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const invited = results.filter(({ status }) => status === "invited").length;
|
|
96
|
+
const failed = results.filter(({ status }) => status === "error").length;
|
|
97
|
+
const failedSuffix = failed
|
|
98
|
+
? ` (${failed} failed)`
|
|
99
|
+
: "";
|
|
100
|
+
$.export("$summary", `Invited ${invited} of ${userIds.length} user(s) to channel with ID ${channel}${failedSuffix}`);
|
|
101
|
+
return results;
|
|
44
102
|
},
|
|
45
103
|
};
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "slack_v2-kick-user",
|
|
6
6
|
name: "Kick User",
|
|
7
7
|
description: "Remove a user from a conversation. [See the documentation](https://api.slack.com/methods/conversations.kick)",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.31",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: true,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
+
// x-pd-ai: optimized
|
|
2
|
+
import utils from "../../common/utils.mjs";
|
|
1
3
|
import slack from "../../slack_v2.app.mjs";
|
|
2
4
|
|
|
3
5
|
export default {
|
|
4
6
|
key: "slack_v2-list-channels",
|
|
5
7
|
name: "List Channels",
|
|
6
|
-
description:
|
|
7
|
-
|
|
8
|
+
description:
|
|
9
|
+
"Return a list of channels in a workspace."
|
|
10
|
+
+ " **Always pass `fields`** with just the properties you need (e.g. `id,name`) —"
|
|
11
|
+
+ " a full channel object is ~1KB, so a workspace of any real size returns a payload"
|
|
12
|
+
+ " large enough to be truncated before you ever see it. `id,name` covers most tasks;"
|
|
13
|
+
+ " every other tool here accepts a channel NAME and resolves it, so you rarely need more."
|
|
14
|
+
+ " Returns `has_more: true` and `next_cursor` when more channels exist than were"
|
|
15
|
+
+ " fetched — when you see that, raise `numPages` (or pass `cursor`) before answering"
|
|
16
|
+
+ " any 'how many' or 'list every' question, otherwise your answer is silently incomplete."
|
|
17
|
+
+ " [See the documentation](https://api.slack.com/methods/conversations.list)",
|
|
18
|
+
version: "0.2.1",
|
|
8
19
|
annotations: {
|
|
9
20
|
destructiveHint: false,
|
|
10
21
|
openWorldHint: true,
|
|
@@ -34,6 +45,15 @@ export default {
|
|
|
34
45
|
default: "public_channel",
|
|
35
46
|
optional: true,
|
|
36
47
|
},
|
|
48
|
+
fields: {
|
|
49
|
+
type: "string[]",
|
|
50
|
+
label: "Fields",
|
|
51
|
+
description:
|
|
52
|
+
"Channel properties to return, e.g. `id`, `name`, `is_private`, `is_archived`, `num_members`, `topic`, `purpose`, `created`."
|
|
53
|
+
+ " Strongly recommended: `[\"id\", \"name\"]` is enough for almost every task and keeps the response small."
|
|
54
|
+
+ " Omit ONLY when you genuinely need the full channel objects — the response is then ~1KB per channel and may be truncated.",
|
|
55
|
+
optional: true,
|
|
56
|
+
},
|
|
37
57
|
pageSize: {
|
|
38
58
|
propDefinition: [
|
|
39
59
|
slack,
|
|
@@ -46,6 +66,12 @@ export default {
|
|
|
46
66
|
"numPages",
|
|
47
67
|
],
|
|
48
68
|
},
|
|
69
|
+
cursor: {
|
|
70
|
+
type: "string",
|
|
71
|
+
label: "Cursor",
|
|
72
|
+
description: "Resume from a previous call's `next_cursor` to fetch the following page.",
|
|
73
|
+
optional: true,
|
|
74
|
+
},
|
|
49
75
|
},
|
|
50
76
|
async run({ $ }) {
|
|
51
77
|
const allChannels = [];
|
|
@@ -56,22 +82,45 @@ export default {
|
|
|
56
82
|
limit: this.pageSize,
|
|
57
83
|
types,
|
|
58
84
|
};
|
|
85
|
+
if (this.cursor) params.cursor = this.cursor;
|
|
59
86
|
let page = 0;
|
|
87
|
+
let nextCursor;
|
|
60
88
|
|
|
61
89
|
do {
|
|
62
90
|
const {
|
|
63
|
-
channels, response_metadata:
|
|
91
|
+
channels, response_metadata: metadata,
|
|
64
92
|
} = await this.slack.conversationsList(params);
|
|
65
93
|
allChannels.push(...channels);
|
|
94
|
+
nextCursor = metadata?.next_cursor;
|
|
66
95
|
params.cursor = nextCursor;
|
|
67
96
|
page++;
|
|
68
97
|
} while (params.cursor && page < this.numPages);
|
|
69
98
|
|
|
70
|
-
|
|
99
|
+
// `fields` is ADDITIVE: omitted returns exactly what this action has always
|
|
100
|
+
// returned, so existing workflows are unaffected. Supplied, it plucks per channel —
|
|
101
|
+
// the difference between ~1KB and ~40 bytes per row, which is what decides whether
|
|
102
|
+
// an agent receives the data or a "result too large" file path.
|
|
103
|
+
const channels = utils.projectFields(allChannels, this.fields);
|
|
104
|
+
|
|
105
|
+
// Truncation must be VISIBLE. numPages defaults to 1, so the previous version
|
|
106
|
+
// silently dropped every channel past the first page and the caller had no way to
|
|
107
|
+
// know the list was partial — a confidently wrong answer to "list every channel".
|
|
108
|
+
const hasMore = Boolean(nextCursor);
|
|
109
|
+
|
|
110
|
+
$.export("$summary", `Successfully found ${channels.length} channel${channels.length === 1
|
|
71
111
|
? ""
|
|
72
|
-
: "s"}
|
|
112
|
+
: "s"}${hasMore
|
|
113
|
+
? " (more available — raise Number of Pages or pass the cursor)"
|
|
114
|
+
: ""}`);
|
|
115
|
+
|
|
73
116
|
return {
|
|
74
|
-
channels
|
|
117
|
+
channels,
|
|
118
|
+
has_more: hasMore,
|
|
119
|
+
...(hasMore
|
|
120
|
+
? {
|
|
121
|
+
next_cursor: nextCursor,
|
|
122
|
+
}
|
|
123
|
+
: {}),
|
|
75
124
|
};
|
|
76
125
|
},
|
|
77
126
|
};
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
name: "List Emojis",
|
|
6
6
|
description:
|
|
7
7
|
"List all available emojis in the Slack workspace. Optionally include emoji image URLs. [See the documentation](https://api.slack.com/methods/emoji.list)",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.5",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -5,7 +5,7 @@ export default {
|
|
|
5
5
|
key: "slack_v2-list-files",
|
|
6
6
|
name: "List Files",
|
|
7
7
|
description: "Return a list of files within a team. [See the documentation](https://api.slack.com/methods/files.list)",
|
|
8
|
-
version: "0.1.
|
|
8
|
+
version: "0.1.6",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
|
11
11
|
openWorldHint: true,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "slack_v2-list-group-members",
|
|
5
5
|
name: "List Group Members",
|
|
6
6
|
description: "List all users in a User Group. [See the documentation](https://api.slack.com/methods/usergroups.users.list)",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.15",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|