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 { getHubspotAccessToken, hubspotAuth } from '../auth';
import { createAction, Property } from "@activepieces/pieces-framework";
import { workflowIdDropdown } from "../common/props";
import { AuthenticationType, httpClient, HttpMethod } from "@activepieces/pieces-common";
export const addContactToWorkflowAction = createAction({
auth:hubspotAuth,
name:'add-contact-to-workflow',
classification: 'WRITE',
displayName:'Add Contact to Workflow',
description:'Adds a contact to a specified workflow in your HubSpot account.',
audience: 'both',
aiMetadata: { description: 'Enroll a contact (identified by email) into a specific HubSpot automation workflow. Only works with API-enrollable workflows. Re-enrolling an already-enrolled contact does not duplicate the enrollment, so it is effectively idempotent.', idempotent: true },
propertyGroups: [
{
key: 'workflow',
display: 'section',
label: 'Workflow',
icon: 'sliders',
props: ['workflowId'],
},
{
key: 'contact',
display: 'section',
label: 'Contact',
icon: 'user',
props: ['email'],
},
],
props:{
workflowId : workflowIdDropdown,
email:Property.ShortText({
displayName:'Contact Email',
placeholder:'[email protected]',
required:true
}),
},
async run(context) {
const contactEmail = context.propsValue.email;
const workflowId = context.propsValue.workflowId;
const response = await httpClient.sendRequest({
method: HttpMethod.POST,
url: `https://api.hubapi.com/automation/v2/workflows/${workflowId}/enrollments/contacts/${contactEmail}`,
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token: getHubspotAccessToken(context.auth),
},
})
return response;
},
})