slack_get_user_profiles
Retrieve profile information for multiple Slack users in bulk by providing their user IDs, enabling efficient user data management and integration.
Instructions
Get multiple users profile information in bulk
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_ids | Yes | Array of user IDs to retrieve profiles for (max 100) |
Implementation Reference
- src/index.ts:307-345 (handler)The handler function for slack_get_user_profiles. Parses input arguments, fetches user profiles concurrently using slackClient.users.profile.get for each user ID, handles individual errors, parses response with GetUserProfilesResponseSchema, and returns JSON stringified result.case 'slack_get_user_profiles': { const args = GetUserProfilesRequestSchema.parse( request.params.arguments ); // Use Promise.all for concurrent API calls const profilePromises = args.user_ids.map(async (userId) => { try { const response = await slackClient.users.profile.get({ user: userId, }); if (!response.ok) { return { user_id: userId, error: response.error || 'Unknown error', }; } const parsed = UserProfileResponseSchema.parse(response); return { user_id: userId, profile: parsed.profile, }; } catch (error) { return { user_id: userId, error: error instanceof Error ? error.message : 'Unknown error', }; } }); const results = await Promise.all(profilePromises); const responseData = GetUserProfilesResponseSchema.parse({ profiles: results, }); return { content: [{ type: 'text', text: JSON.stringify(responseData) }], }; }
- src/index.ts:153-157 (registration)Tool registration in the ListToolsRequestSchema handler, defining name, description, and input schema.{ name: 'slack_get_user_profiles', description: 'Get multiple users profile information in bulk', inputSchema: zodToJsonSchema(GetUserProfilesRequestSchema), },
- src/schemas.ts:176-182 (schema)Input schema validation using Zod for the tool, defining user_ids as array of strings (1-100).export const GetUserProfilesRequestSchema = z.object({ user_ids: z .array(z.string()) .min(1) .max(100) .describe('Array of user IDs to retrieve profiles for (max 100)'), });
- src/schemas.ts:406-414 (schema)Output response schema defining profiles array with user_id, optional profile and error.export const GetUserProfilesResponseSchema = z.object({ profiles: z.array( z.object({ user_id: z.string(), profile: ProfileSchema.optional(), error: z.string().optional(), }) ), });
- src/schemas.ts:67-79 (schema)Profile schema used in user profile responses, defining common profile fields.const ProfileSchema = z .object({ display_name: z.string().optional(), display_name_normalized: z.string().optional(), email: z.string().email().optional(), first_name: z.string().optional(), last_name: z.string().optional(), phone: z.string().optional(), real_name: z.string().optional(), real_name_normalized: z.string().optional(), title: z.string().optional(), }) .strip();