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 { hunterAuth } from '../auth';
import { createTrigger, TriggerStrategy, PiecePropValueSchema, AppConnectionValueForAuthProperty } from '@activepieces/pieces-framework';
import { DedupeStrategy, HttpMethod, Polling, pollingHelper } from '@activepieces/pieces-common';
import { hunterApiCall } from '../common';
import { Lead } from '../common/types';
export const newLeadTrigger = createTrigger({
auth: hunterAuth,
name: 'new-lead',
classification: 'READ',
displayName: 'New Lead',
description: 'Fires when a new lead is created.',
aiMetadata: {
description: 'Fires when a new lead is created in the connected Hunter account, emitting that lead record. Polls the account leads list and detects entries by creation time.',
},
type: TriggerStrategy.POLLING,
props: {},
async onEnable(context) {
await pollingHelper.onEnable(polling, context);
},
async onDisable(context) {
await pollingHelper.onDisable(polling, context);
},
async test(context) {
return await pollingHelper.test(polling, context);
},
async run(context) {
return await pollingHelper.poll(polling, context);
},
sampleData: {
id: 123,
email: '[email protected]',
first_name: 'John',
last_name: 'Doe',
company: 'Example Inc.',
position: 'CEO',
created_at: '2025-07-24T12:00:00Z'
}
});
const polling: Polling<AppConnectionValueForAuthProperty<typeof hunterAuth>, Record<string, never>> = {
strategy: DedupeStrategy.TIMEBASED,
async items({ auth }) {
const response = await hunterApiCall({
apiKey: auth,
endpoint: '/leads',
method: HttpMethod.GET,
qparams: { limit: '100' }
});
const leads = (response as { data: { leads: Lead[] } }).data?.leads as Lead[];
return leads.map((lead) => ({
epochMilliSeconds: new Date(lead.created_at).valueOf(),
data: lead
}));
}
};