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

2.4 KB
Raw Blame
import { HttpMethod } from '@activepieces/pieces-common';
import { createAction, Property } from '@activepieces/pieces-framework';
import { webflowAuth } from '../../../auth';
import { webflowAiProps } from '../../../common/ai-props';
import { webflowClient } from '../../../common/client';
import { webflowGetComponentContentOutputSchema } from '../../../output-schemas';

export const getComponentContentAction = createAction({
	auth: webflowAuth,
	name: 'webflow_get_component_content',
	outputSchema: webflowGetComponentContentOutputSchema,
	displayName: 'Get Component Content',
	description: 'Gets the content nodes of a component.',
	audience: 'ai',
	classification: 'READ',
	aiMetadata: {
		description:
			"Gets a component's content as nodes (text, images, nested component instances) with their ids. Pages with limit and offset. Use Get Component Properties for its property defaults. Get the site id from List Sites and the component id from List Components.",
		idempotent: true,
	},
	props: {
		siteId: webflowAiProps.siteId({ required: true }),
		componentId: Property.ShortText({
			displayName: 'Component ID',
			description: 'Component ID. Use List Components to find it.',
			required: true,
		}),
		localeId: Property.ShortText({
			displayName: 'Locale ID',
			description: 'Locale ID to read. Leave empty for the primary locale.',
			required: false,
		}),
		translatable: Property.ShortText({
			displayName: 'Translatable Into Locale ID',
			description: 'Secondary locale ID you are translating into. Returns only content not excluded from translation for that locale.',
			required: false,
		}),
		branchId: Property.ShortText({
			displayName: 'Branch ID',
			description: 'Page branch ID to read from. Leave empty for the main site.',
			required: false,
		}),
		limit: webflowAiProps.limit({ required: false }),
		offset: webflowAiProps.offset({ required: false }),
	},
	async run(context) {
		const { siteId, componentId, localeId, translatable, branchId, limit, offset } = context.propsValue;
		return await webflowClient.request<unknown>({
			auth: context.auth,
			method: HttpMethod.GET,
			path: `/v2/sites/${encodeURIComponent(siteId)}/components/${encodeURIComponent(componentId)}/dom`,
			query: {
				limit: String(limit ?? 100),
				offset: String(offset ?? 0),
				...(localeId ? { localeId } : {}),
				...(translatable ? { translatable } : {}),
				...(branchId ? { branchId } : {}),
			},
		});
	},
});