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,
MarkdownVariant,
Property,
StaticPropsValue,
TriggerStrategy,
} from '@activepieces/pieces-framework';
import {
DedupeStrategy,
HttpMethod,
Polling,
pollingHelper,
} from '@activepieces/pieces-common';
import { calltidycalapi } from '../common';
import { tidyCalAuth } from '../auth';
import dayjs from 'dayjs';
const props = {
info: Property.MarkDown({
value: 'Checks TidyCal periodically and runs once for each canceled booking.',
variant: MarkdownVariant.INFO,
}),
};
export const tidycalbookingcancelled = createTrigger({
auth: tidyCalAuth,
name: 'booking_canceled',
classification: 'READ',
displayName: 'Booking Canceled',
description: 'Triggers when a booking is canceled',
aiMetadata: {
description: 'Fires when an existing TidyCal booking is canceled. The event represents the canceled appointment, including its id, booking type, start/end times, timezone, meeting URL, intake question answers, the cancellation timestamp, and the associated contact. Use this to react to cancellations, such as notifying the host, freeing resources, or updating downstream records.',
},
props,
sampleData: {
id: 1,
contact_id: 1,
booking_type_id: 1,
starts_at: '2022-01-01T00:00:00.000000Z',
ends_at: '2022-02-01T00:00:00.000000Z',
cancelled_at: '2022-02-01T00:00:00.000000Z',
created_at: '2022-02-01T00:00:00.000000Z',
updated_at: '2022-02-01T00:00:00.000000Z',
timezone: 'America/Los_Angeles',
meeting_url: 'https://zoom.us/j/949494949494',
meeting_id: 'fw44lkj48fks',
questions: [],
contact: {
id: 1,
email: '[email protected]',
name: 'John Doe',
created_at: '2022-01-01T00:00:00.000000Z',
updated_at: '2022-01-01T00:00:00.000000Z',
},
},
type: TriggerStrategy.POLLING,
onEnable: async (context) => {
await pollingHelper.onEnable(polling, context);
},
onDisable: async (context) => {
await pollingHelper.onDisable(polling, context);
},
run: async (context) => {
return await pollingHelper.poll(polling, context);
},
test: async (context) => {
return await pollingHelper.test(polling, context);
},
});
const polling: Polling<
AppConnectionValueForAuthProperty<typeof tidyCalAuth>,
StaticPropsValue<typeof props>
> = {
strategy: DedupeStrategy.TIMEBASED,
items: async ({ auth, lastFetchEpochMS }) => {
const currentValues = await calltidycalapi<{
data: {
id: number;
cancelled_at: string;
}[];
}>(HttpMethod.GET, `bookings?cancelled=true`, auth, undefined);
const cancelledBookings = currentValues.body;
const bookings = cancelledBookings.data.filter((item) => {
const cancelledAt = dayjs(item.cancelled_at);
return cancelledAt.isAfter(lastFetchEpochMS);
});
return bookings.map((item) => {
return {
epochMilliSeconds: dayjs(item.cancelled_at).valueOf(),
data: item,
};
});
},
};