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.4 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { propsValidation } from '@activepieces/pieces-common';
import { googleChatApiAuth, googleChatCommon } from '../common';
import { peoplesDropdown, spacesDropdown, spacesMembersDropdown } from '../common/props';
import { googleChatAPIService } from '../common/requests';

export const addASpaceMember = createAction({
  auth: googleChatApiAuth,
  name: 'addASpaceMember',
  classification: 'WRITE',
  displayName: 'Add a Space Member',
  description: 'Add a user to a Google Chat space.',
  audience: 'both',
  aiMetadata: {
    description: 'Adds a user as a member of a Google Chat space, identified by the space ID and the person to add. Use to grant someone access to a space. Not idempotent in effect—creating the membership again for an existing member fails or errors.',
    idempotent: false,
  },
  props: {
    spaceId: spacesDropdown({ refreshers: ['auth'], required: true }),
    personId: peoplesDropdown(['auth']),
  },
  async run({ auth, propsValue }) {
    await propsValidation.validateZod(propsValue, googleChatCommon.addSpaceMemberSchema);

    const { spaceId, personId } = propsValue;

    const userId = (personId as string).replace('people', 'users');

    const response = await googleChatAPIService.AddASpaceMember({
      accessToken: auth.access_token,
      spaceId: spaceId as string,
      userId: userId as string
    })

    return response;
  },
});