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.3 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 { findUserByEmailActionOutputSchema } from '../output-schemas';

export const findUserByEmailAction = createAction({
  auth: slackAuth,
  name: 'slack-find-user-by-email',
  classification: 'READ',
  displayName: 'Find User by Email',
  description: 'Finds a user by matching against their email address.',
  audience: 'human',
  aiMetadata: {
    description:
      'Look up a single Slack user by their exact email address, returning their profile and user ID. Pick this to resolve an email into a Slack user ID before messaging or referencing that user. Read-only and idempotent; errors if no workspace member matches the email.',
    idempotent: true,
  },
  outputSchema: findUserByEmailActionOutputSchema,
  props: {
    email: Property.ShortText({
      displayName: 'Email',
      description: 'Must match the email on the Slack profile.',
      placeholder: '[email protected]',
      required: true,
    }),
  },
  async run({ auth, propsValue }) {
    const email = propsValue.email;
    const client = new WebClient(getBotToken(auth as SlackAuthValue));
    return await client.users.lookupByEmail({
      email,
    });
  },
});