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 { AppConnectionValueForAuthProperty, OAuth2PropertyValue, createTrigger } from '@activepieces/pieces-framework';
import { TriggerStrategy } from '@activepieces/pieces-framework';
import {
DedupeStrategy,
Polling,
pollingHelper,
} from '@activepieces/pieces-common';
import { leadConnectorAuth } from '../..';
import { getContacts } from '../common';
const polling: Polling<AppConnectionValueForAuthProperty<typeof leadConnectorAuth>, unknown> = {
strategy: DedupeStrategy.LAST_ITEM,
items: async ({ auth, lastItemId }) => {
const currentValues =
(await getContacts(auth, {
startAfterId: lastItemId as string,
sortOrder: 'asc',
})) ?? [];
return currentValues.map((contact) => {
return {
id: contact.id,
data: contact,
};
});
},
};
export const newContact = createTrigger({
auth: leadConnectorAuth,
name: 'new_contact',
classification: 'READ',
displayName: 'New Contact',
description: 'Trigger when a new contact is added.',
aiMetadata: {
description: 'Fires when a new contact is added to the GoHighLevel/LeadConnector location, polling for contacts not seen before. Represents the newly created contact; does not fire on updates to existing contacts.',
},
props: {},
type: TriggerStrategy.POLLING,
sampleData: {},
onEnable: async (context) => {
await pollingHelper.onEnable(polling, context);
},
onDisable: async (context) => {
await pollingHelper.onDisable(polling, context);
},
run: async (context) => {
return await pollingHelper.poll(polling, context);
},
test: async (context) => {
return await pollingHelper.test(polling, context);
},
});