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,
AppConnectionValueForAuthProperty,
} from '@activepieces/pieces-framework';
import {
HttpMethod,
DedupeStrategy,
Polling,
pollingHelper,
} from '@activepieces/pieces-common';
import { freshserviceAuth } from '../../';
import { freshserviceApiCall } from '../common/client';
interface FreshserviceRequester {
id: number;
first_name: string;
last_name: string;
primary_email: string;
job_title: string | null;
phone: string | null;
mobile_phone_number: string | null;
created_at: string;
updated_at: string;
}
const polling: Polling<
AppConnectionValueForAuthProperty<typeof freshserviceAuth>,
Record<string, never>
> = {
strategy: DedupeStrategy.TIMEBASED,
async items({ auth, lastFetchEpochMS }) {
const response = await freshserviceApiCall<{
requesters: FreshserviceRequester[];
}>({
method: HttpMethod.GET,
endpoint: 'requesters',
auth,
queryParams: {
order_by: 'created_at',
order_type: 'desc',
per_page: lastFetchEpochMS === 0 ? '10' : '100',
},
});
return response.body.requesters.map((requester) => ({
epochMilliSeconds: new Date(requester.created_at).getTime(),
data: requester,
}));
},
};
export const newRequester = createTrigger({
auth: freshserviceAuth,
name: 'new_requester',
classification: 'READ',
displayName: 'New Requester',
description: 'Triggers when a new requester (user) is created in Freshservice.',
aiMetadata: {
description: 'Fires when a new requester (end-user) record is created in Freshservice, representing a person newly onboarded into the help desk. Polls newest-first by creation time across all requesters in the account.',
},
props: {},
sampleData: {
id: 1,
first_name: 'Jane',
last_name: 'Doe',
primary_email: '[email protected]',
job_title: 'Software Engineer',
phone: '+1-555-0100',
mobile_phone_number: '+1-555-0101',
created_at: '2025-01-15T09:30:00Z',
updated_at: '2025-01-15T09:30:00Z',
},
type: TriggerStrategy.POLLING,
async test(context) {
return await pollingHelper.test(polling, context);
},
async onEnable(context) {
await pollingHelper.onEnable(polling, context);
},
async onDisable(context) {
await pollingHelper.onDisable(polling, context);
},
async run(context) {
return await pollingHelper.poll(polling, context);
},
});