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,
createTrigger,
TriggerStrategy,
} from '@activepieces/pieces-framework';
import {
DedupeStrategy,
httpClient,
HttpMethod,
Polling,
pollingHelper,
} from '@activepieces/pieces-common';
import { timeOpsAuth } from '../..';
import { BASE_URL } from '../common';
interface User {
id: number;
name: string | null;
eMail: string | null;
accessLevel: 'User' | 'ProjectManager' | 'Admin';
deactivatedAt: string | null;
}
const polling: Polling<AppConnectionValueForAuthProperty<typeof timeOpsAuth>, Record<string, never>> = {
strategy: DedupeStrategy.LAST_ITEM,
items: async ({ auth }) => {
const response = await httpClient.sendRequest<User[]>({
method: HttpMethod.GET,
url: `${BASE_URL}/users`,
headers: {
'x-api-key': auth.secret_text,
},
});
const users = response.body ?? [];
return users
.sort((a, b) => b.id - a.id)
.map((user) => ({
id: user.id,
data: user,
}));
},
};
export const newUser = createTrigger({
auth: timeOpsAuth,
name: 'new_user',
displayName: 'New User',
description: 'Triggers when a new user has been created.',
aiMetadata: {
description: 'Fires when a new user is added to the TimeOps account. Polls the user list and emits each newly seen user record, including name, email, and access level. Use to automate team-member onboarding such as welcome messages or provisioning.',
},
type: TriggerStrategy.POLLING,
props: {},
sampleData: {
id: 1,
name: 'John Doe',
eMail: '[email protected]',
accessLevel: 'User',
deactivatedAt: null,
},
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);
},
async test(context) {
return await pollingHelper.test(polling, context);
},
});