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

export const getPageTemplateVariables = createAction({
  auth: sendrAuth,
  name: 'get_page_template_variables',
  displayName: 'Get Page Template Variables',
  description: 'Returns the custom variables (placeholders) defined in a selected page template � for example first_name, company, or email.',
  audience: 'both',
  aiMetadata: { description: 'Lists the variables (placeholders) defined in a page template, such as first_name or company, with each variable name, type, and default value. Use it to learn which variable keys to supply when calling Generate Sendr Page. Read-only; requires the template id.', idempotent: true },
  props: {
    template: pageTemplateDropdown,
  },
  async run(context) {
    const response = await sendrApiCall<{
      variables: { id: string; name?: string; type?: string; defaultValue?: string; [key: string]: unknown }[];
    }>({
      token: context.auth.secret_text,
      method: HttpMethod.GET,
      path: `/page-template/${context.propsValue.template}/variables`,
    });
    const variables = response.body?.variables ?? [];
    return variables.map((v) => ({
      id: v.id,
      name: v.name ?? null,
      type: v.type ?? null,
      default_value: v.defaultValue ?? null,
    }));
  },
});