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.TIMEBASED,
items: async ({ auth }) => {
const currentValues =
(await getContacts(auth, {
sortBy: 'date_updated',
sortOrder: 'asc',
})) ?? [];
return currentValues.map((contact) => {
return {
epochMilliSeconds: new Date(contact.dateUpdated).getTime(),
data: contact,
};
});
},
};
export const contactUpdated = createTrigger({
auth: leadConnectorAuth,
name: 'contact_updated',
classification: 'READ',
displayName: 'Contact Created or Updated',
description: 'Trigger when a contact is created or updated.',
aiMetadata: {
description: 'Fires when a contact in the GoHighLevel/LeadConnector location is created or has any field changed, polling by last-updated timestamp. Represents the latest state of the affected contact.',
},
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);
},
});