Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.2 KB
Raw Blame
import { slackAuth } from '../auth';
import { createAction, Property } from '@activepieces/pieces-framework';
import { WebClient } from '@slack/web-api';
import { getBotToken, SlackAuthValue } from '../common/auth-helpers';
import { getUserByIdActionOutputSchema } from '../output-schemas';

export const findUserByIdAction = createAction({
	auth: slackAuth,
	name: 'find-user-by-id',
	classification: 'READ',
	displayName: 'Find User by ID',
	description: 'Returns the profile of a user by ID.',
	audience: 'human',
	aiMetadata: { description: 'Fetch a user profile directly by their Slack user ID; read-only and repeatable. Pick this when you already have the user ID (the fastest, exact lookup); use Find User by Handle when you only know the display-name handle.', idempotent: true },
	outputSchema: getUserByIdActionOutputSchema,
	props: {
		id: Property.ShortText({
			displayName: 'User ID',
			description: 'Starts with U or W.',
			placeholder: 'U012AB3CD',
			required: true,
		}),
	},
	async run({ auth, propsValue }) {
		const client = new WebClient(getBotToken(auth as SlackAuthValue));
		return await client.users.profile.get({
			user: propsValue.id,
		});
	},
});