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
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { createAction, Property } from '@activepieces/pieces-framework';
import { ApitemplateAuth } from '../common/auth';
import { ApitemplateAuthConfig, ApitemplateRegion, makeRequest } from '../common/client';
import { HttpMethod } from '@activepieces/pieces-common';
import { templateIdDropdown } from '../common/props';
import { createImageOutputSchema } from '../output-schemas';
export const createImage = createAction({
auth: ApitemplateAuth,
name: 'createImage',
outputSchema: createImageOutputSchema,
classification: 'WRITE',
displayName: 'Create Image',
description: 'Creates an image from a template with provided data.',
audience: 'both',
aiMetadata: { description: 'Renders a new image from a saved APITemplate.io template, merging in the supplied JSON `overrides` array to fill template objects. Requires a template ID (pick from the dropdown). Not idempotent: each call generates and stores a new image with its own transaction reference.', idempotent: false },
props: {
templateId: templateIdDropdown,
data: Property.Json({
displayName: 'Template Data',
description:
'JSON data with overrides array to populate the template. Format: {"overrides": [{"name": "object_name", "property": "value"}]}.',
required: true,
}),
generationDelay: Property.Number({
displayName: 'Generation Delay (ms)',
description: 'Delay in milliseconds before PDF generation',
required: false,
}),
meta: Property.ShortText({
displayName: 'External Reference ID',
description: 'Specify an external reference ID for your own reference',
required: false,
}),
},
async run({ auth, propsValue }) {
const authConfig = auth.props;
const {
templateId,
data,
generationDelay,
meta,
} = propsValue;
// Build query parameters
const queryParams = new URLSearchParams();
queryParams.append('template_id', templateId);
if (generationDelay) {
queryParams.append('generation_delay', generationDelay.toString());
}
if (meta) {
queryParams.append('meta', meta);
}
const endpoint = `/create-image?${queryParams.toString()}`;
const response = await makeRequest(
authConfig.apiKey,
HttpMethod.POST,
endpoint,
data,
undefined,
authConfig.region as ApitemplateRegion
);
return response;
},
});