Skip to content

Commit 199c500

Browse files
Add Find User by ID action for slack_v2 (#19758)
* Add Find User by ID action for slack_v2 * fix: explicitly handle error case * fix: remove redundant checks * bump component version * Bump version to 0.2.0 in package.json --------- Co-authored-by: Guilherme Falcão <48412907+GTFalcao@users.noreply.github.com>
1 parent ef1c33e commit 199c500

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import slack from "../../slack_v2.app.mjs";
2+
3+
export default {
4+
key: "slack_v2-find-user-by-id",
5+
name: "Find User by ID",
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.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
14+
props: {
15+
slack,
16+
user: {
17+
propDefinition: [
18+
slack,
19+
"user",
20+
],
21+
description: "Select a user or enter a user ID (e.g., `U1234567890`)",
22+
},
23+
includeLocale: {
24+
type: "boolean",
25+
label: "Include Locale",
26+
description: "Set to `true` to receive the locale for this user",
27+
default: false,
28+
optional: true,
29+
},
30+
},
31+
async run({ $ }) {
32+
let response;
33+
try {
34+
response = await this.slack.usersInfo({
35+
user: this.user,
36+
include_locale: this.includeLocale,
37+
});
38+
} catch (err) {
39+
$.export("$summary", `Failed to find user ${this.user}: ${err.message || err}`);
40+
throw err;
41+
}
42+
43+
const displayName = response.user.profile?.display_name
44+
|| response.user.profile?.real_name
45+
|| response.user.name
46+
|| this.user;
47+
$.export("$summary", `Successfully found user ${displayName}`);
48+
49+
return response;
50+
},
51+
};

components/slack_v2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/slack_v2",
3-
"version": "0.1.2",
3+
"version": "0.2.0",
44
"description": "Pipedream Slack_v2 Components",
55
"main": "slack_v2.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)