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, isNil, TriggerStrategy } from '@activepieces/pieces-framework';
import { assembledCommon } from '../common';
import { HttpMethod } from '@activepieces/pieces-common';
import { assembledAuth } from '../common/auth';
export const scheduleUpdated = createTrigger({
auth: assembledAuth,
name: 'schedule_updated',
classification: 'READ',
displayName: 'Schedule Updated',
description: 'Triggers when user schedule is modified.',
aiMetadata: {
description: 'Fires when a user\'s schedule changes in Assembled (for example a shift added or modified), polling for schedule-update events since the last check. Use to react to scheduling changes such as added or edited shifts.',
},
type: TriggerStrategy.POLLING,
props: {},
sampleData: {
user_id: 'user_456',
schedule_id: 'sched_123',
changes: ['shift_added', 'shift_modified'],
updated_at: '2025-01-15T10:00:00Z',
},
async onEnable(context) {
if (context.isRepublish && !isNil(await context.store.get('lastScheduleCheck'))) {
return;
}
await context.store.put('lastScheduleCheck', new Date().toISOString());
},
async onDisable() {
// Cleanup if needed
},
async run(context) {
const lastCheck = await context.store.get('lastScheduleCheck') || new Date(Date.now() - 60 * 60 * 1000).toISOString();
const response = await assembledCommon.makeRequest(
context.auth.secret_text,
HttpMethod.GET,
`/events?type=schedule_updated&after=${lastCheck}&limit=100`
);
const scheduleUpdates = response.body.data || [];
if (scheduleUpdates.length > 0) {
await context.store.put('lastScheduleCheck', new Date().toISOString());
}
return scheduleUpdates;
},
});