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 {
DedupeStrategy,
Polling,
pollingHelper,
} from '@activepieces/pieces-common';
import { makeRequest } from '../common/client';
import { HttpMethod } from '@activepieces/pieces-common';
import dayjs from 'dayjs';
import { skyprepAuth } from '../common/auth';
const polling: Polling<
AppConnectionValueForAuthProperty<typeof skyprepAuth>,
Record<string, never>
> = {
strategy: DedupeStrategy.TIMEBASED,
items: async ({ propsValue, lastFetchEpochMS, auth }) => {
const response = await makeRequest(
auth.secret_text,
HttpMethod.POST,
'/get_users',
{
created_within_the_past_day: false,
order_by_created_at_desc: true,
limit: 100,
include_groups: false,
include_courses: false,
}
);
return (response || [])
.filter(
(user: any) => dayjs(user.updated_at).valueOf() > lastFetchEpochMS
)
.map((user: any) => ({
epochMilliSeconds: dayjs(user.created_at).valueOf(),
data: user,
}));
},
};
export const newUser = createTrigger({
auth: skyprepAuth,
name: 'newUser',
displayName: 'New User',
description: 'Trigger when a new user is created in SkyPrep',
aiMetadata: {
description:
'Fires when a new user account is created in SkyPrep, emitting the new user record. Use to react to learner onboarding, such as auto-enrolling new users into courses or groups.',
},
props: {},
sampleData: {
id: 32,
first_name: 'John',
last_name: 'Doe',
username: '[email protected]',
card_no: 'Emp. # 3211221',
created_at: '2021-01-01T12:00: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);
},
});