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 {
createTrigger,
TriggerStrategy,
PiecePropValueSchema,
AppConnectionValueForAuthProperty
} from '@activepieces/pieces-framework';
import { HttpMethod, DedupeStrategy, Polling, pollingHelper } from '@activepieces/pieces-common';
import { zendeskSellAuth } from '../common/auth';
import { callZendeskApi } from '../common/client';
interface ZendeskContactItem {
data: ZendeskContact;
meta: { type: string };
}
interface ZendeskContact {
id: number;
name: string;
email?: string;
created_at: string;
}
const polling: Polling<AppConnectionValueForAuthProperty<typeof zendeskSellAuth>, Record<string, never>> = {
strategy: DedupeStrategy.TIMEBASED,
async items({ auth, lastFetchEpochMS }) {
const response = await callZendeskApi<{ items: ZendeskContactItem[] }>(
HttpMethod.GET,
'v2/contacts',
auth,
undefined,
{
sort_by: 'created_at:desc',
per_page: lastFetchEpochMS === 0 ? '10' : '100',
}
);
return response.body.items.map((item) => ({
epochMilliSeconds: new Date(item.data.created_at).getTime(),
data: item.data,
}));
},
};
export const newContact = createTrigger({
auth: zendeskSellAuth,
name: 'new_contact',
displayName: 'New Contact',
description: 'Fires when a new contact is created in Zendesk Sell (polls for new records).',
aiMetadata: {
description: 'Fires when a new contact (person or organization) is created in Zendesk Sell. Each event represents one newly added contact record, discovered by polling sorted by creation time.',
},
props: {
},
sampleData: {
"id": 2,
"creator_id": 1,
"owner_id": 1,
"is_organization": false,
"contact_id": 1,
"name": "Mark Johnson",
"first_name": "Mark",
"last_name": "Johnson",
"customer_status": "none",
"email": "[email protected]",
"phone": "508-778-6516",
"created_at": "2014-08-27T16:32:56Z",
"updated_at": "2014-08-27T16:32:56Z"
},
type: TriggerStrategy.POLLING,
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);
},
});