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 { AuthenticationType, httpClient, HttpMethod } from '@activepieces/pieces-common';
import { getHubspotAccessToken, hubspotAuth } from '../auth';
import { createAction, Property } from '@activepieces/pieces-framework';
import { pageType } from '../common/props';
import { pageOutputSchema } from '../output-schemas';
export const createPageAction = createAction({
auth: hubspotAuth,
name: 'create-page',
classification: 'WRITE',
displayName: 'Create Page',
description: 'Creates a landing page or site page.',
audience: 'both',
aiMetadata: { description: 'Create a new HubSpot CMS landing page or site page (choose via Page Type) from a template, then optionally publish it when State is set to publish rather than leaving it as a draft. Each call creates a distinct page, so it is not idempotent.', idempotent: false },
outputSchema: pageOutputSchema,
propertyGroups: [
{
key: 'page',
display: 'section',
label: 'Page',
icon: 'file',
props: ['pageType', 'pageTitle', 'internalPageName', 'templatePath', 'slug', 'language'],
},
{
key: 'publishing',
display: 'section',
label: 'Publishing',
icon: 'send',
props: ['state'],
},
],
props: {
pageType: pageType,
pageTitle: Property.ShortText({
displayName: 'Page Title',
required: true,
width: 'half',
}),
internalPageName: Property.ShortText({
displayName: 'Internal Page Name',
required: true,
width: 'half',
}),
templatePath: Property.ShortText({
displayName: 'Template Path',
description: 'The theme template to use, without a leading slash.',
placeholder: '@hubspot/elevate/templates/blank.hubl.html',
required: true,
}),
slug: Property.ShortText({
displayName: 'Slug',
placeholder: 'spring-sale',
required: true,
width: 'half',
}),
language: Property.ShortText({
displayName: 'Language',
description: 'A language code such as en-us or de-de.',
required: false,
defaultValue: 'en-us',
width: 'half',
}),
metaDescription: Property.LongText({
displayName: 'Meta Description',
required: false,
advanced: true,
}),
state: Property.StaticDropdown({
displayName: 'Status',
required: false,
defaultValue: 'DRAFT',
options: {
disabled: false,
options: [
{
label: 'Draft',
value: 'DRAFT',
description: 'Kept unpublished',
icon: 'file',
},
{
label: 'Publish',
value: 'PUBLISHED_OR_SCHEDULED',
description: 'Live once created',
icon: 'send',
},
],
},
}),
headHtml: Property.LongText({
displayName: 'Additional Head HTML',
required: false,
advanced: true,
}),
footerHtml: Property.LongText({
displayName: 'Additional Footer HTML',
required: false,
advanced: true,
}),
},
async run(context) {
const url = `https://api.hubapi.com/cms/v3/pages/${
context.propsValue.pageType === 'site_page' ? 'site-pages' : 'landing-pages'
}`;
const {
pageTitle,
internalPageName,
metaDescription,
templatePath,
language,
state,
headHtml,
footerHtml,
slug,
} = context.propsValue;
const createdPage = await httpClient.sendRequest<{ id: string }>({
method: HttpMethod.POST,
url,
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token: getHubspotAccessToken(context.auth),
},
body: {
htmlTitle: pageTitle,
name: internalPageName,
metaDescription,
templatePath,
slug,
language,
headHtml,
footerHtml,
},
});
if (state === 'PUBLISHED_OR_SCHEDULED') {
await httpClient.sendRequest({
method: HttpMethod.POST,
url: `https://api.hubapi.com/content/api/v2/pages/${createdPage.body.id}/publish-action`,
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token: getHubspotAccessToken(context.auth),
},
body: { action: 'schedule-publish' },
});
}
const pageDetails = await httpClient.sendRequest({
method: HttpMethod.GET,
url: `${url}/${createdPage.body.id}`,
authentication: { type: AuthenticationType.BEARER_TOKEN, token: getHubspotAccessToken(context.auth) },
});
return pageDetails.body;
},
});