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 { createAction } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { sendrAuth } from '../auth';
import { sheetDropdown, sendrApiCall } from '../common';

export const getSheetColumns = createAction({
  auth: sendrAuth,
  name: 'get_sheet_columns',
  displayName: 'Get Sheet Columns',
  description: 'Returns all columns (fields) of a contact list, including their enrichment status.',
  audience: 'both',
  aiMetadata: { description: 'Lists the columns (fields) of a contact list (sheet), including each column type and enrichment status. Use it to discover the valid column names before building row data for Add Row to Sheet. Read-only; requires the sheet id.', idempotent: true },
  props: {
    sheet: sheetDropdown,
  },
  async run(context) {
    const response = await sendrApiCall<{
      columns: { id: string; name?: string; type?: string; enriched?: boolean; [key: string]: unknown }[];
    }>({
      token: context.auth.secret_text,
      method: HttpMethod.GET,
      path: `/sheet/${context.propsValue.sheet}/column`,
    });

    const columns = response.body?.columns ?? [];
    return columns.map((col) => ({
      id: col.id,
      name: col.name ?? null,
      type: col.type ?? null,
      enriched: col.enriched ?? null,
    }));
  },
});