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.1 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { paperformAuth } from '../common/auth';
import { paperformCommon } from '../common/client';

export const findSpace = createAction({
  auth: paperformAuth,
  name: 'findSpace',
  displayName: 'Find Space',
  description: 'Finds a space by name.',
  audience: 'both',
  aiMetadata: { description: 'Searches the account\'s Paperform spaces by name and returns matching spaces. Use to resolve a space ID from its name before updating it; this is a read-only search and is idempotent.', idempotent: true },
  props: {
    search: Property.ShortText({
      displayName: 'Space Name',
      required: true,
    }),
  },
  async run({ auth, propsValue }) {
    const { search } = propsValue;

    try {
      const response = await paperformCommon.getSpaces({
        auth: auth.secret_text,
        search: search as string,
        limit: 100,
      });

      return {
        found: response.results.spaces.length > 0,
        data: response.results.spaces,
      };
    } catch (error: any) {
      throw new Error(`Failed to find spaces: ${error.message}`);
    }
  },
});