Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "slack-add-emoji-reaction",
name: "Add Emoji Reaction",
description: "Add an emoji reaction to a message. [See the documentation](https://api.slack.com/methods/reactions.add)",
version: "0.0.14",
version: "0.0.15",
type: "action",
props: {
slack,
Expand Down Expand Up @@ -32,7 +32,7 @@ export default {
},
},
async run({ $ }) {
const response = await this.slack.sdk().reactions.add({
const response = await this.slack.addReactions({
channel: this.conversation,
timestamp: this.timestamp,
name: this.icon_emoji,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "slack-approve-workflow",
name: "Approve Workflow",
description: "Suspend the workflow until approved by a Slack message. [See the documentation](https://pipedream.com/docs/code/nodejs/rerun#flowsuspend)",
version: "0.0.3",
version: "0.0.4",
type: "action",
props: {
slack,
Expand Down Expand Up @@ -44,7 +44,7 @@ export default {
resume_url, cancel_url,
} = $.flow.suspend();

const response = await this.slack.sdk().chat.postMessage({
const response = await this.slack.postChatMessage({
text: "Click here to approve or cancel workflow",
blocks: [
{
Expand Down
4 changes: 2 additions & 2 deletions components/slack/actions/archive-channel/archive-channel.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "slack-archive-channel",
name: "Archive Channel",
description: "Archive a channel. [See the documentation](https://api.slack.com/methods/conversations.archive)",
version: "0.0.22",
version: "0.0.23",
type: "action",
props: {
slack,
Expand All @@ -24,7 +24,7 @@ export default {
},
},
async run({ $ }) {
const response = await this.slack.sdk().conversations.archive({
const response = await this.slack.archiveConversations({
channel: this.conversation,
});
$.export("$summary", "Successfully archived channel.");
Expand Down
10 changes: 6 additions & 4 deletions components/slack/actions/common/send-message.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,18 @@ export default {

if (this.post_at) {
obj.post_at = Math.floor(new Date(this.post_at).getTime() / 1000);
return await this.slack.sdk().chat.scheduleMessage(obj);
return await this.slack.scheduleMessage(obj);
}
const resp = await this.slack.sdk().chat.postMessage(obj);
const resp = await this.slack.postChatMessage(obj);
const { channel } = await this.slack.conversationsInfo({
channel: resp.channel,
});
let channelName = `#${channel?.name}`;
if (channel.is_im) {
const usernames = await this.slack.userNames();
channelName = `@${usernames[channel.user]}`;
const { profile } = await this.slack.getUserProfile({
user: channel.user,
});
channelName = `@${profile.real_name}`;
} else if (channel.is_mpim) {
channelName = `@${channel.purpose.value}`;
}
Expand Down
4 changes: 2 additions & 2 deletions components/slack/actions/create-channel/create-channel.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "slack-create-channel",
name: "Create a Channel",
description: "Create a new channel. [See the documentation](https://api.slack.com/methods/conversations.create)",
version: "0.0.23",
version: "0.0.24",
type: "action",
props: {
slack,
Expand All @@ -25,7 +25,7 @@ export default {
// parse name
const name = this.channelName.replace(/\s+/g, "-").toLowerCase();

const response = await this.slack.sdk().conversations.create({
const response = await this.slack.createConversations({
name,
is_private: this.isPrivate,
});
Expand Down
4 changes: 2 additions & 2 deletions components/slack/actions/create-reminder/create-reminder.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "slack-create-reminder",
name: "Create Reminder",
description: "Create a reminder. [See the documentation](https://api.slack.com/methods/reminders.add)",
version: "0.0.23",
version: "0.0.24",
type: "action",
props: {
slack,
Expand Down Expand Up @@ -35,7 +35,7 @@ export default {
},
},
async run({ $ }) {
const response = await this.slack.sdk().reminders.add({
const response = await this.slack.addReminders({
text: this.text,
team_id: this.team_id,
time: this.timestamp,
Expand Down
4 changes: 2 additions & 2 deletions components/slack/actions/delete-file/delete-file.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "slack-delete-file",
name: "Delete File",
description: "Delete a file. [See the documentation](https://api.slack.com/methods/files.delete)",
version: "0.0.22",
version: "0.0.23",
type: "action",
props: {
slack,
Expand All @@ -16,7 +16,7 @@ export default {
},
},
async run({ $ }) {
const response = await this.slack.sdk().files.delete({
const response = await this.slack.deleteFiles({
file: this.file,
});
$.export("$summary", `Successfully deleted file with ID ${this.file}`);
Expand Down
4 changes: 2 additions & 2 deletions components/slack/actions/delete-message/delete-message.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "slack-delete-message",
name: "Delete Message",
description: "Delete a message. [See the documentation](https://api.slack.com/methods/chat.delete)",
version: "0.0.22",
version: "0.0.23",
type: "action",
props: {
slack,
Expand All @@ -29,7 +29,7 @@ export default {
},
},
async run({ $ }) {
const response = await this.slack.sdk().chat.delete({
const response = await this.slack.deleteMessage({
channel: this.conversation,
ts: this.timestamp,
as_user: this.as_user,
Expand Down
2 changes: 1 addition & 1 deletion components/slack/actions/find-message/find-message.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "slack-find-message",
name: "Find Message",
description: "Find a Slack message. [See the documentation](https://api.slack.com/methods/search.messages)",
version: "0.0.22",
version: "0.0.23",
type: "action",
props: {
slack,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "slack-find-user-by-email",
name: "Find User by Email",
description: "Find a user by matching against their email. [See the documentation](https://api.slack.com/methods/users.lookupByEmail)",
version: "0.0.22",
version: "0.0.23",
type: "action",
props: {
slack,
Expand All @@ -16,7 +16,7 @@ export default {
},
},
async run({ $ }) {
const response = await this.slack.sdk().users.lookupByEmail({
const response = await this.slack.lookupUserByEmail({
email: this.email,
});
if (response.ok) {
Expand Down
4 changes: 2 additions & 2 deletions components/slack/actions/get-file/get-file.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "slack-get-file",
name: "Get File",
description: "Return information about a file. [See the documentation](https://api.slack.com/methods/files.info)",
version: "0.0.22",
version: "0.0.23",
type: "action",
props: {
slack,
Expand All @@ -16,7 +16,7 @@ export default {
},
},
async run({ $ }) {
const response = await this.slack.sdk().files.info({
const response = await this.slack.getFileInfo({
file: this.file,
});
$.export("$summary", `Successfully retrieved file with ID ${this.file}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "slack-invite-user-to-channel",
name: "Invite User to Channel",
description: "Invite a user to an existing channel. [See the documentation](https://api.slack.com/methods/conversations.invite)",
version: "0.0.22",
version: "0.0.23",
type: "action",
props: {
slack,
Expand All @@ -22,7 +22,7 @@ export default {
},
},
async run({ $ }) {
const response = await this.slack.sdk().conversations.invite({
const response = await this.slack.inviteToConversation({
channel: this.conversation,
users: this.user,
});
Expand Down
4 changes: 2 additions & 2 deletions components/slack/actions/kick-user/kick-user.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "slack-kick-user",
name: "Kick User",
description: "Remove a user from a conversation. [See the documentation](https://api.slack.com/methods/conversations.kick)",
version: "0.0.22",
version: "0.0.23",
type: "action",
props: {
slack,
Expand Down Expand Up @@ -33,7 +33,7 @@ export default {
},
},
async run({ $ }) {
const response = await this.slack.sdk().conversations.kick({
const response = await this.slack.kickUserFromConversation({
channel: this.conversation,
user: this.user,
});
Expand Down
36 changes: 32 additions & 4 deletions components/slack/actions/list-channels/list-channels.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,44 @@ export default {
key: "slack-list-channels",
name: "List Channels",
description: "Return a list of all channels in a workspace. [See the documentation](https://api.slack.com/methods/conversations.list)",
version: "0.0.22",
version: "0.0.23",
type: "action",
props: {
slack,
pageSize: {
propDefinition: [
slack,
"pageSize",
],
},
numPages: {
propDefinition: [
slack,
"numPages",
],
},
},
async run({ $ }) {
const response = await this.slack.sdk().conversations.list();
$.export("$summary", `Successfully found ${response.length} channel${response.length === 1
const allChannels = [];
const params = {
limit: this.pageSize,
};
let page = 0;

do {
const {
channels, response_metadata: { next_cursor: nextCursor },
} = await this.slack.conversationsList(params);
allChannels.push(...channels);
params.cursor = nextCursor;
page++;
} while (params.cursor && page < this.numPages);

$.export("$summary", `Successfully found ${allChannels.length} channel${allChannels.length === 1
? ""
: "s"}`);
return response;
return {
channels: allChannels,
};
},
};
19 changes: 16 additions & 3 deletions components/slack/actions/list-files/list-files.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "slack-list-files",
name: "List Files",
description: "Return a list of files within a team. [See the documentation](https://api.slack.com/methods/files.list)",
version: "0.0.50",
version: "0.0.51",
type: "action",
props: {
slack,
Expand All @@ -28,6 +28,18 @@ export default {
],
optional: true,
},
pageSize: {
propDefinition: [
slack,
"pageSize",
],
},
numPages: {
propDefinition: [
slack,
"numPages",
],
},
},
async run({ $ }) {
const allFiles = [];
Expand All @@ -36,15 +48,16 @@ export default {
user: this.user,
team_id: this.team_id,
page: 1,
count: this.pageSize,
};
let hasMore;

do {
const { files } = await this.slack.sdk().files.list(params);
const { files } = await this.slack.listFiles(params);
allFiles.push(...files);
hasMore = files.length;
params.page++;
} while (hasMore);
} while (hasMore && params.page <= this.numPages);

$.export("$summary", `Successfully retrieved ${allFiles.length} file${allFiles.length === 1
? ""
Expand Down
45 changes: 33 additions & 12 deletions components/slack/actions/list-group-members/list-group-members.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "slack-list-group-members",
name: "List Group Members",
description: "List all users in a User Group. [See the documentation](https://api.slack.com/methods/usergroups.users.list)",
version: "0.0.7",
version: "0.0.8",
type: "action",
props: {
slack,
Expand All @@ -22,21 +22,42 @@ export default {
optional: true,
description: "Encoded team id where the user group exists, required if org token is used.",
},
pageSize: {
propDefinition: [
slack,
"pageSize",
],
},
numPages: {
propDefinition: [
slack,
"numPages",
],
},
},
async run({ $ }) {
const {
userGroup,
team,
} = this;
const response = await this.slack.sdk().usergroups.users.list({
usergroup: userGroup,
team_id: team,
});
if (response.users?.length) {
$.export("$summary", `Successfully retrieved ${response.users.length} user${response.users.length === 1
const members = [];
const params = {
usergroup: this.userGroup,
team_id: this.team,
limit: this.pageSize,
};
let page = 0;

do {
const {
users, response_metadata: { next_cursor: nextCursor },
} = await this.slack.listGroupMembers(params);
members.push(...users);
params.cursor = nextCursor;
page++;
} while (params.cursor && page < this.numPages);

if (members?.length) {
$.export("$summary", `Successfully retrieved ${members.length} user${members.length === 1
? ""
: "s"}`);
}
return response;
return members;
},
};
Loading
Loading