Skip to content

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

feat(calendly): add agent actions and output schemas (#15731)

Kishan Parmar4edda84387ff
diff --git a/bun.lock b/bun.lock
index 38acaabdf07..efe97ce9f77 100644
--- a/bun.lock
+++ b/bun.lock
@@ -1476,7 +1476,7 @@
},
"packages/pieces/community/calendly": {
"name": "@activepieces/piece-calendly",
- "version": "0.5.0",
+ "version": "0.6.0",
"dependencies": {
"@activepieces/core-piece-types": "workspace:*",
"@activepieces/core-utils": "workspace:*",
diff --git a/packages/pieces/community/calendly/.babelrc b/packages/pieces/community/calendly/.babelrc
deleted file mode 100644
index fc2ad0f36c4..00000000000
--- a/packages/pieces/community/calendly/.babelrc
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "presets": [["@nx/js/babel", { "useBuiltIns": "usage" }]]
-}
diff --git a/packages/pieces/community/calendly/package.json b/packages/pieces/community/calendly/package.json
index 19e41a6303d..f185f038e4f 100644
--- a/packages/pieces/community/calendly/package.json
+++ b/packages/pieces/community/calendly/package.json
@@ -1,6 +1,6 @@
{
"name": "@activepieces/piece-calendly",
- "version": "0.5.0",
+ "version": "0.6.0",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"scripts": {
diff --git a/packages/pieces/community/calendly/src/index.ts b/packages/pieces/community/calendly/src/index.ts
index 93a86ac0c87..f4e3e6d7039 100644
--- a/packages/pieces/community/calendly/src/index.ts
+++ b/packages/pieces/community/calendly/src/index.ts
@@ -1,28 +1,74 @@
import { createCustomApiCallAction } from '@activepieces/pieces-common';
-import { PieceAuth, createPiece } from '@activepieces/pieces-framework';
+import { createPiece } from '@activepieces/pieces-framework';
import { PieceCategory } from '@activepieces/pieces-framework';
import { calendlyCommon } from './lib/common';
import { calendlyInviteeCanceled } from './lib/trigger/invitee-canceled.trigger';
import { calendlyInviteeCreated } from './lib/trigger/invitee-created.trigger';
import { calendlyAuth } from './lib/auth';
+import { cancelScheduledEventAction } from './lib/actions/cancel-scheduled-event';
+import { createEventTypeAction } from './lib/actions/create-event-type';
+import { createOneOffEventTypeAction } from './lib/actions/create-one-off-event-type';
+import { createSchedulingLinkAction } from './lib/actions/create-scheduling-link';
+import { createShareAction } from './lib/actions/create-share';
+import { findInviteeBookingsAction } from './lib/actions/find-invitee-bookings';
+import { findUserAction } from './lib/actions/find-user';
+import { getEventInviteeAction } from './lib/actions/get-event-invitee';
+import { getEventTypeAvailabilityAction } from './lib/actions/get-event-type-availability';
+import { getEventTypeAction } from './lib/actions/get-event-type';
+import { getOrganizationMembershipAction } from './lib/actions/get-organization-membership';
+import { getOrganizationAction } from './lib/actions/get-organization';
+import { getScheduledEventAction } from './lib/actions/get-scheduled-event';
+import { getUserAvailabilityScheduleAction } from './lib/actions/get-user-availability-schedule';
+import { getUserAction } from './lib/actions/get-user';
+import { listAvailableTimesAction } from './lib/actions/list-available-times';
+import { listEventInviteesAction } from './lib/actions/list-event-invitees';
+import { listEventTypeHostsAction } from './lib/actions/list-event-type-hosts';
+import { listEventTypesAction } from './lib/actions/list-event-types';
+import { listOrganizationMembershipsAction } from './lib/actions/list-organization-memberships';
+import { listScheduledEventsAction } from './lib/actions/list-scheduled-events';
+import { listUserAvailabilitySchedulesAction } from './lib/actions/list-user-availability-schedules';
+import { listUserBusyTimesAction } from './lib/actions/list-user-busy-times';
+import { listUserLocationsAction } from './lib/actions/list-user-locations';
+import { updateEventTypeAvailabilityAction } from './lib/actions/update-event-type-availability';
+import { updateEventTypeAction } from './lib/actions/update-event-type';
-const markdown = `
-## Obtain your Calendly Personal Token
-1. Go to https://calendly.com/integrations/api_webhooks
-2. Click on "Create New Token"
-3. Copy the token and paste it in the field below
-`;
export const calendly = createPiece({
displayName: 'Calendly',
description: 'Simple, modern scheduling',
- minimumSupportedRelease: '0.30.0',
+ minimumSupportedRelease: '0.87.0',
logoUrl: 'https://cdn.activepieces.com/pieces/calendly.png',
categories: [PieceCategory.PRODUCTIVITY],
authors: ["kishanprmr","MoShizzle","AbdulTheActivePiecer","khaledmashaly","abuaboud"],
auth: calendlyAuth,
actions: [
+ cancelScheduledEventAction,
+ createEventTypeAction,
+ createOneOffEventTypeAction,
+ createSchedulingLinkAction,
+ createShareAction,
+ findInviteeBookingsAction,
+ findUserAction,
+ getEventInviteeAction,
+ getEventTypeAvailabilityAction,
+ getEventTypeAction,
+ getOrganizationMembershipAction,
+ getOrganizationAction,
+ getScheduledEventAction,
+ getUserAvailabilityScheduleAction,
+ getUserAction,
+ listAvailableTimesAction,
+ listEventInviteesAction,
+ listEventTypeHostsAction,
+ listEventTypesAction,
+ listOrganizationMembershipsAction,
+ listScheduledEventsAction,
+ listUserAvailabilitySchedulesAction,
+ listUserBusyTimesAction,
+ listUserLocationsAction,
+ updateEventTypeAvailabilityAction,
+ updateEventTypeAction,
createCustomApiCallAction({
- baseUrl: () => calendlyCommon.baseUrl, // Replace with the actual base URL
+ baseUrl: () => calendlyCommon.baseUrl,
auth: calendlyAuth,
authMapping: async (auth) => ({
Authorization: `Bearer ${auth.secret_text}`,
diff --git a/packages/pieces/community/calendly/src/lib/actions/cancel-scheduled-event.ts b/packages/pieces/community/calendly/src/lib/actions/cancel-scheduled-event.ts
new file mode 100644
index 00000000000..fb5af48954f
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/cancel-scheduled-event.ts
@@ -0,0 +1,37 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyRecord } from '../common';
+import { cancellationOutputSchema } from '../output-schemas';
+
+export const cancelScheduledEventAction = createAction({
+ auth: calendlyAuth,
+ name: 'cancel_scheduled_event',
+ classification: 'DESTRUCTIVE',
+ displayName: 'Cancel Event',
+ description: 'Cancels a booked meeting and notifies the invitees.',
+ audience: 'both',
+ aiMetadata: {
+ description:
+ 'Cancel one upcoming booked Calendly meeting by URI or UUID; Calendly emails the invitees with the optional Reason. Past meetings, already canceled meetings and meetings the connected user does not host cannot be canceled. Cannot be undone; confirm with the user first.',
+ idempotent: false,
+ },
+ outputSchema: cancellationOutputSchema,
+ props: {
+ scheduledEvent: calendlyCommon.scheduledEvent,
+ reason: Property.LongText({
+ displayName: 'Reason',
+ description: 'Shown to the invitees. Up to 10,000 characters.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const response = await calendlyCommon.calendlyRequest<{ resource: CalendlyRecord }>({
+ token: auth.secret_text,
+ method: HttpMethod.POST,
+ path: `/scheduled_events/${calendlyCommon.toUuid({ value: propsValue.scheduledEvent })}/cancellation`,
+ body: calendlyCommon.isProvided(propsValue.reason) ? { reason: propsValue.reason } : {},
+ });
+ return response.resource;
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/create-event-type.ts b/packages/pieces/community/calendly/src/lib/actions/create-event-type.ts
new file mode 100644
index 00000000000..a248062c3f7
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/create-event-type.ts
@@ -0,0 +1,46 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyRecord } from '../common';
+import { eventTypeOutputSchema } from '../output-schemas';
+
+export const createEventTypeAction = createAction({
+ auth: calendlyAuth,
+ name: 'create_event_type',
+ classification: 'WRITE',
+ displayName: 'Create Event Type',
+ description: 'Creates a one-on-one event type.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Create a new one-on-one (solo) Calendly event type owned by a user (defaults to the connected user). Only one-on-one event types can be created through the API. Returns the new event type with its URI and scheduling URL. Not idempotent: each call creates another event type.',
+ idempotent: false,
+ },
+ outputSchema: eventTypeOutputSchema,
+ props: {
+ owner: Property.ShortText({
+ displayName: 'Owner',
+ description: 'User URI or UUID of the host. Leave empty for the connected user.',
+ required: false,
+ }),
+ name: Property.ShortText({
+ displayName: 'Name',
+ required: true,
+ }),
+ ...calendlyCommon.eventTypeFields,
+ },
+ async run({ auth, propsValue }) {
+ const owner = await calendlyCommon.resolveUserUri({ token: auth.secret_text, user: propsValue.owner });
+ const response = await calendlyCommon.calendlyRequest<{ resource: CalendlyRecord }>({
+ token: auth.secret_text,
+ method: HttpMethod.POST,
+ path: '/event_types',
+ body: {
+ owner,
+ name: propsValue.name,
+ ...calendlyCommon.eventTypeBody(propsValue),
+ },
+ });
+ return response.resource;
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/create-one-off-event-type.ts b/packages/pieces/community/calendly/src/lib/actions/create-one-off-event-type.ts
new file mode 100644
index 00000000000..ba1e1c44fc5
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/create-one-off-event-type.ts
@@ -0,0 +1,104 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyRecord } from '../common';
+import { eventTypeOutputSchema } from '../output-schemas';
+
+export const createOneOffEventTypeAction = createAction({
+ auth: calendlyAuth,
+ name: 'create_one_off_event_type',
+ classification: 'WRITE',
+ displayName: 'Create One-Off Meeting Link',
+ description: 'Creates a one-off meeting and returns its booking link.',
+ audience: 'both',
+ aiMetadata: {
+ description:
+ "Create a Calendly one-off meeting: a temporary event type bookable only between Start Date and End Date, outside the host's regular event types. Returns the one-off event type with its scheduling_url to send to the invitee. Not idempotent: each call creates another one-off meeting.",
+ idempotent: false,
+ },
+ outputSchema: eventTypeOutputSchema,
+ props: {
+ name: Property.ShortText({
+ displayName: 'Name',
+ required: true,
+ }),
+ duration: Property.Number({
+ displayName: 'Duration (minutes)',
+ required: true,
+ }),
+ startDate: Property.ShortText({
+ displayName: 'Start Date',
+ description: 'First bookable date, YYYY-MM-DD.',
+ required: true,
+ }),
+ endDate: Property.ShortText({
+ displayName: 'End Date',
+ description: 'Last bookable date, YYYY-MM-DD.',
+ required: true,
+ }),
+ timezone: Property.ShortText({
+ displayName: 'Timezone',
+ description: "IANA timezone such as America/New_York. Defaults to the host's timezone.",
+ required: false,
+ }),
+ host: Property.ShortText({
+ displayName: 'Host',
+ description: 'User URI or UUID of the host. Leave empty for the connected user.',
+ required: false,
+ }),
+ locationKind: Property.StaticDropdown({
+ displayName: 'Location',
+ required: false,
+ options: {
+ options: [
+ { label: 'Google Meet', value: 'google_conference' },
+ { label: 'Zoom', value: 'zoom_conference' },
+ { label: 'Microsoft Teams', value: 'microsoft_teams_conference' },
+ { label: 'Webex', value: 'webex_conference' },
+ { label: 'GoToMeeting', value: 'gotomeeting_conference' },
+ { label: 'In person', value: 'physical' },
+ { label: 'Phone call (invitee calls host)', value: 'inbound_call' },
+ { label: 'Phone call (host calls invitee)', value: 'outbound_call' },
+ { label: 'Custom', value: 'custom' },
+ { label: 'Ask invitee', value: 'ask_invitee' },
+ ],
+ },
+ }),
+ location: Property.ShortText({
+ displayName: 'Location Details',
+ description: 'Address for in person, text for custom, or the phone number for inbound calls.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const host = await calendlyCommon.resolveUserUri({ token: auth.secret_text, user: propsValue.host });
+ const response = await calendlyCommon.calendlyRequest<{ resource: CalendlyRecord }>({
+ token: auth.secret_text,
+ method: HttpMethod.POST,
+ path: '/one_off_event_types',
+ body: {
+ name: propsValue.name,
+ host,
+ duration: propsValue.duration,
+ ...(calendlyCommon.isProvided(propsValue.timezone) ? { timezone: propsValue.timezone.trim() } : {}),
+ date_setting: {
+ type: 'date_range',
+ start_date: propsValue.startDate.trim(),
+ end_date: propsValue.endDate.trim(),
+ },
+ ...(calendlyCommon.isProvided(propsValue.locationKind)
+ ? { location: toLocation({ kind: propsValue.locationKind, details: propsValue.location }) }
+ : {}),
+ },
+ });
+ return response.resource;
+ },
+});
+
+function toLocation({ kind, details }: { kind: string; details: string | undefined }): Record<string, string> {
+ const value = details?.trim();
+ if (!value) {
+ return { kind };
+ }
+ return kind === 'inbound_call' ? { kind, phone_number: value } : { kind, location: value };
+}
diff --git a/packages/pieces/community/calendly/src/lib/actions/create-scheduling-link.ts b/packages/pieces/community/calendly/src/lib/actions/create-scheduling-link.ts
new file mode 100644
index 00000000000..fd3ccdfff42
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/create-scheduling-link.ts
@@ -0,0 +1,36 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyRecord } from '../common';
+import { schedulingLinkOutputSchema } from '../output-schemas';
+
+export const createSchedulingLinkAction = createAction({
+ auth: calendlyAuth,
+ name: 'create_scheduling_link',
+ classification: 'WRITE',
+ displayName: 'Create Single-Use Scheduling Link',
+ description: 'Creates a booking link for an event type that works for one booking.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Create a single-use Calendly booking link for an active event type: the booking_url expires after one meeting is booked. Use it to send one person a private link; use the event type scheduling_url for a reusable link. Not idempotent: each call creates a new link.',
+ idempotent: false,
+ },
+ outputSchema: schedulingLinkOutputSchema,
+ props: {
+ eventType: calendlyCommon.eventType,
+ },
+ async run({ auth, propsValue }) {
+ const response = await calendlyCommon.calendlyRequest<{ resource: CalendlyRecord }>({
+ token: auth.secret_text,
+ method: HttpMethod.POST,
+ path: '/scheduling_links',
+ body: {
+ max_event_count: 1,
+ owner: calendlyCommon.toUri({ resource: 'event_types', value: propsValue.eventType }),
+ owner_type: 'EventType',
+ },
+ });
+ return response.resource;
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/create-share.ts b/packages/pieces/community/calendly/src/lib/actions/create-share.ts
new file mode 100644
index 00000000000..097cdb09429
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/create-share.ts
@@ -0,0 +1,70 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyRecord } from '../common';
+import { shareOutputSchema } from '../output-schemas';
+
+export const createShareAction = createAction({
+ auth: calendlyAuth,
+ name: 'create_share',
+ classification: 'WRITE',
+ displayName: 'Create Customized Share Link',
+ description: 'Creates a booking link that overrides some settings of a one-on-one event type.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Create a customized one-time share of a one-on-one (solo) Calendly event type, overriding its name, duration or booking window without changing the event type itself. Returns scheduling_links with the booking_url to send. Only one-on-one event types can be shared. Not idempotent: each call creates a new share.',
+ idempotent: false,
+ },
+ outputSchema: shareOutputSchema,
+ props: {
+ eventType: calendlyCommon.eventType,
+ name: Property.ShortText({
+ displayName: 'Name',
+ required: false,
+ }),
+ duration: Property.Number({
+ displayName: 'Duration (minutes)',
+ required: false,
+ }),
+ startDate: Property.ShortText({
+ displayName: 'Start Date',
+ description: 'First bookable date, YYYY-MM-DD. Set together with End Date to limit the booking window.',
+ required: false,
+ }),
+ endDate: Property.ShortText({
+ displayName: 'End Date',
+ description: 'Last bookable date, YYYY-MM-DD.',
+ required: false,
+ }),
+ hideLocation: Property.Checkbox({
+ displayName: 'Hide Location Until Booked',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const hasStartDate = calendlyCommon.isProvided(propsValue.startDate);
+ const hasEndDate = calendlyCommon.isProvided(propsValue.endDate);
+ if (hasStartDate !== hasEndDate) {
+ throw new Error('Set both Start Date and End Date to limit the booking window, or leave both empty.');
+ }
+ const hasWindow = hasStartDate && hasEndDate;
+ const response = await calendlyCommon.calendlyRequest<{ resource: CalendlyRecord }>({
+ token: auth.secret_text,
+ method: HttpMethod.POST,
+ path: '/shares',
+ body: {
+ event_type: calendlyCommon.toUri({ resource: 'event_types', value: propsValue.eventType }),
+ ...(calendlyCommon.isProvided(propsValue.name) ? { name: propsValue.name } : {}),
+ ...(propsValue.duration !== undefined && propsValue.duration !== null
+ ? { duration: propsValue.duration }
+ : {}),
+ ...(hasWindow
+ ? { period_type: 'fixed', start_date: propsValue.startDate?.trim(), end_date: propsValue.endDate?.trim() }
+ : {}),
+ ...(propsValue.hideLocation ? { hide_location: true } : {}),
+ },
+ });
+ return response.resource;
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/find-invitee-bookings.ts b/packages/pieces/community/calendly/src/lib/actions/find-invitee-bookings.ts
new file mode 100644
index 00000000000..74b2ea4233d
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/find-invitee-bookings.ts
@@ -0,0 +1,56 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyCollection, CalendlyRecord } from '../common';
+import { findInviteeBookingsOutputSchema } from '../output-schemas';
+
+export const findInviteeBookingsAction = createAction({
+ auth: calendlyAuth,
+ name: 'find_invitee_bookings',
+ classification: 'SEARCH',
+ displayName: 'Find Invitee by Email',
+ description: "Finds the meetings an invitee booked with you, by the invitee's email.",
+ audience: 'both',
+ aiMetadata: {
+ description:
+ "Find the Calendly meetings a person booked with the connected user, by the invitee's email: up to the 100 most recent, newest first. Returns found=false when there are none. Read-only.",
+ idempotent: true,
+ },
+ outputSchema: findInviteeBookingsOutputSchema,
+ props: {
+ email: Property.ShortText({
+ displayName: 'Invitee Email',
+ required: true,
+ }),
+ status: Property.StaticDropdown({
+ displayName: 'Status',
+ required: false,
+ options: {
+ options: [
+ { label: 'Active', value: 'active' },
+ { label: 'Canceled', value: 'canceled' },
+ ],
+ },
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const user = await calendlyCommon.resolveUserUri({ token: auth.secret_text, user: undefined });
+ const response = await calendlyCommon.calendlyRequest<CalendlyCollection<CalendlyRecord>>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path: '/scheduled_events',
+ queryParams: {
+ user,
+ invitee_email: propsValue.email.trim(),
+ status: propsValue.status,
+ sort: 'start_time:desc',
+ count: '100',
+ },
+ });
+ return {
+ found: response.collection.length > 0,
+ count: response.collection.length,
+ events: response.collection,
+ };
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/find-user.ts b/packages/pieces/community/calendly/src/lib/actions/find-user.ts
new file mode 100644
index 00000000000..f8d66775b5c
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/find-user.ts
@@ -0,0 +1,54 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyCollection, CalendlyRecord } from '../common';
+import { findUserOutputSchema } from '../output-schemas';
+
+export const findUserAction = createAction({
+ auth: calendlyAuth,
+ name: 'find_user',
+ classification: 'SEARCH',
+ displayName: 'Find User',
+ description: "Finds a user in your Calendly organization by email.",
+ audience: 'both',
+ aiMetadata: {
+ description:
+ "Find a member of the connected user's Calendly organization by exact email. Returns found=false when nobody matches, otherwise the user (URI, name, email, scheduling URL, timezone) and their role. Read-only.",
+ idempotent: true,
+ },
+ outputSchema: findUserOutputSchema,
+ props: {
+ email: Property.ShortText({
+ displayName: 'Email',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const organization = await calendlyCommon.resolveOrganizationUri({
+ token: auth.secret_text,
+ organization: undefined,
+ });
+ const response = await calendlyCommon.calendlyRequest<CalendlyCollection<MembershipRecord>>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path: '/organization_memberships',
+ queryParams: { organization, email: propsValue.email.trim(), count: '1' },
+ });
+ const membership = response.collection[0];
+ if (!membership) {
+ return { found: false, user: null, role: null, membership_uri: null };
+ }
+ return {
+ found: true,
+ user: membership.user,
+ role: membership.role,
+ membership_uri: membership.uri,
+ };
+ },
+});
+
+type MembershipRecord = {
+ uri: string;
+ role: string;
+ user: CalendlyRecord;
+};
diff --git a/packages/pieces/community/calendly/src/lib/actions/get-event-invitee.ts b/packages/pieces/community/calendly/src/lib/actions/get-event-invitee.ts
new file mode 100644
index 00000000000..08112d66045
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/get-event-invitee.ts
@@ -0,0 +1,36 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyRecord } from '../common';
+import { eventInviteeOutputSchema } from '../output-schemas';
+
+export const getEventInviteeAction = createAction({
+ auth: calendlyAuth,
+ name: 'get_event_invitee',
+ classification: 'READ',
+ displayName: 'Get Event Invitee',
+ description: 'Gets one invitee of a booked meeting.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Get one invitee of a booked Calendly meeting by the invitee URI (or its UUID plus the scheduled event): name, email, status, timezone, booking question answers, UTM tracking, payment, no-show record and cancel/reschedule URLs. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: eventInviteeOutputSchema,
+ props: {
+ invitee: calendlyCommon.invitee,
+ scheduledEvent: calendlyCommon.optionalScheduledEvent,
+ },
+ async run({ auth, propsValue }) {
+ const inviteeUri = calendlyCommon.toInviteeUri({
+ invitee: propsValue.invitee,
+ scheduledEvent: propsValue.scheduledEvent,
+ });
+ const response = await calendlyCommon.calendlyRequest<{ resource: CalendlyRecord }>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path: new URL(inviteeUri).pathname,
+ });
+ return response.resource;
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/get-event-type-availability.ts b/packages/pieces/community/calendly/src/lib/actions/get-event-type-availability.ts
new file mode 100644
index 00000000000..35d7ec3775f
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/get-event-type-availability.ts
@@ -0,0 +1,34 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyCollection, CalendlyRecord } from '../common';
+import { eventTypeAvailabilityOutputSchema } from '../output-schemas';
+
+export const getEventTypeAvailabilityAction = createAction({
+ auth: calendlyAuth,
+ name: 'get_event_type_availability',
+ classification: 'READ',
+ displayName: 'Get Event Type Availability',
+ description: 'Gets the availability schedule of an event type.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Get the weekly availability schedule of one Calendly event type: timezone and rules (per weekday or per date, each with from/to intervals). Call this before Update Event Type Availability, because an update replaces every rule. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: eventTypeAvailabilityOutputSchema,
+ props: {
+ eventType: calendlyCommon.eventType,
+ },
+ async run({ auth, propsValue }) {
+ const response = await calendlyCommon.calendlyRequest<CalendlyCollection<CalendlyRecord>>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path: '/event_type_availability_schedules',
+ queryParams: {
+ event_type: calendlyCommon.toUri({ resource: 'event_types', value: propsValue.eventType }),
+ },
+ });
+ return { items: response.collection, count: response.collection.length };
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/get-event-type.ts b/packages/pieces/community/calendly/src/lib/actions/get-event-type.ts
new file mode 100644
index 00000000000..279b7eb2bf8
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/get-event-type.ts
@@ -0,0 +1,31 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyRecord } from '../common';
+import { eventTypeOutputSchema } from '../output-schemas';
+
+export const getEventTypeAction = createAction({
+ auth: calendlyAuth,
+ name: 'get_event_type',
+ classification: 'READ',
+ displayName: 'Get Event Type',
+ description: 'Gets one event type.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Get one Calendly event type by URI or UUID: name, duration and duration options, kind, active flag, locations, custom questions, profile and scheduling URL. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: eventTypeOutputSchema,
+ props: {
+ eventType: calendlyCommon.eventType,
+ },
+ async run({ auth, propsValue }) {
+ const response = await calendlyCommon.calendlyRequest<{ resource: CalendlyRecord }>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path: `/event_types/${calendlyCommon.toUuid({ value: propsValue.eventType })}`,
+ });
+ return response.resource;
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/get-organization-membership.ts b/packages/pieces/community/calendly/src/lib/actions/get-organization-membership.ts
new file mode 100644
index 00000000000..e30a19329a1
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/get-organization-membership.ts
@@ -0,0 +1,35 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyRecord } from '../common';
+import { organizationMembershipOutputSchema } from '../output-schemas';
+
+export const getOrganizationMembershipAction = createAction({
+ auth: calendlyAuth,
+ name: 'get_organization_membership',
+ classification: 'READ',
+ displayName: 'Get Organization Membership',
+ description: 'Gets one organization membership.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ "Get one Calendly organization membership by its URI or UUID (from List Organization Members): the member's role and user profile. Read-only.",
+ idempotent: true,
+ },
+ outputSchema: organizationMembershipOutputSchema,
+ props: {
+ membership: Property.ShortText({
+ displayName: 'Membership',
+ description: 'Organization membership URI or UUID.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const response = await calendlyCommon.calendlyRequest<{ resource: CalendlyRecord }>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path: `/organization_memberships/${calendlyCommon.toUuid({ value: propsValue.membership })}`,
+ });
+ return response.resource;
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/get-organization.ts b/packages/pieces/community/calendly/src/lib/actions/get-organization.ts
new file mode 100644
index 00000000000..b2f11a9fd3d
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/get-organization.ts
@@ -0,0 +1,35 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyRecord } from '../common';
+import { organizationOutputSchema } from '../output-schemas';
+
+export const getOrganizationAction = createAction({
+ auth: calendlyAuth,
+ name: 'get_organization',
+ classification: 'READ',
+ displayName: 'Get Organization',
+ description: 'Gets a Calendly organization, including its plan.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ "Get a Calendly organization's name, plan (basic, standard, teams, enterprise...) and stage (free, trial, paid). Leave Organization empty for the connected user's organization. Use it to check whether plan-gated features are available. Read-only.",
+ idempotent: true,
+ },
+ outputSchema: organizationOutputSchema,
+ props: {
+ organization: calendlyCommon.organization,
+ },
+ async run({ auth, propsValue }) {
+ const organization = await calendlyCommon.resolveOrganizationUri({
+ token: auth.secret_text,
+ organization: propsValue.organization,
+ });
+ const response = await calendlyCommon.calendlyRequest<{ resource: CalendlyRecord }>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path: `/organizations/${calendlyCommon.toUuid({ value: organization })}`,
+ });
+ return response.resource;
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/get-scheduled-event.ts b/packages/pieces/community/calendly/src/lib/actions/get-scheduled-event.ts
new file mode 100644
index 00000000000..30a8c3ba09e
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/get-scheduled-event.ts
@@ -0,0 +1,31 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyRecord } from '../common';
+import { scheduledEventOutputSchema } from '../output-schemas';
+
+export const getScheduledEventAction = createAction({
+ auth: calendlyAuth,
+ name: 'get_scheduled_event',
+ classification: 'READ',
+ displayName: 'Find Event',
+ description: 'Gets a booked meeting by its URI or UUID.',
+ audience: 'both',
+ aiMetadata: {
+ description:
+ 'Get one booked Calendly meeting by URI or UUID: name, status, start and end time, event type, location (join URL for video calls), hosts, invitee counts and cancellation details when canceled. Invitees are not included; use List Event Invitees. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: scheduledEventOutputSchema,
+ props: {
+ scheduledEvent: calendlyCommon.scheduledEvent,
+ },
+ async run({ auth, propsValue }) {
+ const response = await calendlyCommon.calendlyRequest<{ resource: CalendlyRecord }>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path: `/scheduled_events/${calendlyCommon.toUuid({ value: propsValue.scheduledEvent })}`,
+ });
+ return response.resource;
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/get-user-availability-schedule.ts b/packages/pieces/community/calendly/src/lib/actions/get-user-availability-schedule.ts
new file mode 100644
index 00000000000..e4841f23cab
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/get-user-availability-schedule.ts
@@ -0,0 +1,35 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyRecord } from '../common';
+import { userAvailabilityScheduleOutputSchema } from '../output-schemas';
+
+export const getUserAvailabilityScheduleAction = createAction({
+ auth: calendlyAuth,
+ name: 'get_user_availability_schedule',
+ classification: 'READ',
+ displayName: 'Get User Availability Schedule',
+ description: 'Gets one user availability schedule.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Get one Calendly user availability schedule by URI or UUID (from List User Availability Schedules): name, default flag, timezone and rules. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: userAvailabilityScheduleOutputSchema,
+ props: {
+ schedule: Property.ShortText({
+ displayName: 'Availability Schedule',
+ description: 'Availability schedule URI or UUID.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const response = await calendlyCommon.calendlyRequest<{ resource: CalendlyRecord }>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path: `/user_availability_schedules/${calendlyCommon.toUuid({ value: propsValue.schedule })}`,
+ });
+ return response.resource;
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/get-user.ts b/packages/pieces/community/calendly/src/lib/actions/get-user.ts
new file mode 100644
index 00000000000..f6d6c277241
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/get-user.ts
@@ -0,0 +1,38 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyRecord } from '../common';
+import { userOutputSchema } from '../output-schemas';
+
+export const getUserAction = createAction({
+ auth: calendlyAuth,
+ name: 'get_user',
+ classification: 'READ',
+ displayName: 'Get User',
+ description: 'Gets a Calendly user, or the connected user.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ "Get a Calendly user's profile: URI, name, email, scheduling URL, timezone and current organization URI. Leave User empty to get the connected account (who am I); the returned uri and current_organization are the User and Organization values other Calendly actions need. Read-only.",
+ idempotent: true,
+ },
+ outputSchema: userOutputSchema,
+ props: {
+ user: Property.ShortText({
+ displayName: 'User',
+ description: 'User URI or UUID. Leave empty to get the connected user.',
+ required: false,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const path = calendlyCommon.isProvided(propsValue.user)
+ ? `/users/${calendlyCommon.toUuid({ value: propsValue.user })}`
+ : '/users/me';
+ const response = await calendlyCommon.calendlyRequest<{ resource: CalendlyRecord }>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path,
+ });
+ return response.resource;
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/list-available-times.ts b/packages/pieces/community/calendly/src/lib/actions/list-available-times.ts
new file mode 100644
index 00000000000..08973917832
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/list-available-times.ts
@@ -0,0 +1,49 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyCollection, CalendlyRecord } from '../common';
+import { availableTimesOutputSchema } from '../output-schemas';
+
+export const listAvailableTimesAction = createAction({
+ auth: calendlyAuth,
+ name: 'list_available_times',
+ classification: 'SEARCH',
+ displayName: 'List Available Times',
+ description: 'Lists the open booking slots of an event type.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'List the open start times of one Calendly event type between Start Time and End Time (at most 31 days apart, End Time in the future; a past Start Time is moved to now). Each slot has start_time, invitees_remaining and a scheduling_url that books that slot. Use it to answer "when is X free" or before sending someone a time. Not paginated. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: availableTimesOutputSchema,
+ props: {
+ eventType: calendlyCommon.eventType,
+ startTime: Property.DateTime({
+ displayName: 'Start Time',
+ required: true,
+ }),
+ endTime: Property.DateTime({
+ displayName: 'End Time',
+ description: 'At most 31 days after Start Time.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const window = calendlyCommon.validateTimeWindow({
+ startTime: propsValue.startTime,
+ endTime: propsValue.endTime,
+ maxDays: 31,
+ });
+ const response = await calendlyCommon.calendlyRequest<CalendlyCollection<CalendlyRecord>>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path: '/event_type_available_times',
+ queryParams: {
+ event_type: calendlyCommon.toUri({ resource: 'event_types', value: propsValue.eventType }),
+ ...window,
+ },
+ });
+ return { items: response.collection, count: response.collection.length };
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/list-event-invitees.ts b/packages/pieces/community/calendly/src/lib/actions/list-event-invitees.ts
new file mode 100644
index 00000000000..3871688337d
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/list-event-invitees.ts
@@ -0,0 +1,52 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyCollection, CalendlyRecord } from '../common';
+import { eventInviteesOutputSchema } from '../output-schemas';
+
+export const listEventInviteesAction = createAction({
+ auth: calendlyAuth,
+ name: 'list_event_invitees',
+ classification: 'SEARCH',
+ displayName: 'List Event Invitees',
+ description: 'Lists the invitees of a booked meeting.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'List the invitees of one booked Calendly meeting with each invitee URI, name, email, status, timezone, answers to booking questions, no-show record and cancel/reschedule URLs. Filter by email or status. The invitee uri is what Mark Invitee as No Show needs. Paginated with Page Token. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: eventInviteesOutputSchema,
+ props: {
+ scheduledEvent: calendlyCommon.scheduledEvent,
+ email: Property.ShortText({
+ displayName: 'Email',
+ required: false,
+ }),
+ status: Property.StaticDropdown({
+ displayName: 'Status',
+ required: false,
+ options: {
+ options: [
+ { label: 'Active', value: 'active' },
+ { label: 'Canceled', value: 'canceled' },
+ ],
+ },
+ }),
+ count: calendlyCommon.count,
+ pageToken: calendlyCommon.pageToken,
+ },
+ async run({ auth, propsValue }) {
+ const response = await calendlyCommon.calendlyRequest<CalendlyCollection<CalendlyRecord>>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path: `/scheduled_events/${calendlyCommon.toUuid({ value: propsValue.scheduledEvent })}/invitees`,
+ queryParams: {
+ email: propsValue.email?.trim(),
+ status: propsValue.status,
+ ...calendlyCommon.pageQuery({ count: propsValue.count, pageToken: propsValue.pageToken }),
+ },
+ });
+ return calendlyCommon.toPage({ response });
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/list-event-type-hosts.ts b/packages/pieces/community/calendly/src/lib/actions/list-event-type-hosts.ts
new file mode 100644
index 00000000000..e2b4d46f24e
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/list-event-type-hosts.ts
@@ -0,0 +1,37 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyCollection, CalendlyRecord } from '../common';
+import { eventTypeHostsOutputSchema } from '../output-schemas';
+
+export const listEventTypeHostsAction = createAction({
+ auth: calendlyAuth,
+ name: 'list_event_type_hosts',
+ classification: 'SEARCH',
+ displayName: 'List Event Type Hosts',
+ description: 'Lists the hosts of an event type.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'List the hosts (members) of one Calendly event type, each with the member user URI, name and email. Useful for group, collective and round-robin event types. Paginated with Page Token. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: eventTypeHostsOutputSchema,
+ props: {
+ eventType: calendlyCommon.eventType,
+ count: calendlyCommon.count,
+ pageToken: calendlyCommon.pageToken,
+ },
+ async run({ auth, propsValue }) {
+ const response = await calendlyCommon.calendlyRequest<CalendlyCollection<CalendlyRecord>>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path: '/event_type_memberships',
+ queryParams: {
+ event_type: calendlyCommon.toUri({ resource: 'event_types', value: propsValue.eventType }),
+ ...calendlyCommon.pageQuery({ count: propsValue.count, pageToken: propsValue.pageToken }),
+ },
+ });
+ return calendlyCommon.toPage({ response });
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/list-event-types.ts b/packages/pieces/community/calendly/src/lib/actions/list-event-types.ts
new file mode 100644
index 00000000000..95d63d88499
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/list-event-types.ts
@@ -0,0 +1,56 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyCollection, CalendlyRecord } from '../common';
+import { eventTypesOutputSchema } from '../output-schemas';
+
+export const listEventTypesAction = createAction({
+ auth: calendlyAuth,
+ name: 'list_event_types',
+ classification: 'SEARCH',
+ displayName: 'List Event Types',
+ description: 'Lists the event types of a user or organization.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ "List Calendly event types (bookable meeting templates) with each URI, name, duration, kind, active flag and scheduling URL. Defaults to the connected user's event types; set Organization instead to list every event type in the organization (admin only). The returned uri is the Event Type value other actions need. Paginated with Page Token. Read-only.",
+ idempotent: true,
+ },
+ outputSchema: eventTypesOutputSchema,
+ props: {
+ user: calendlyCommon.user,
+ organization: Property.ShortText({
+ displayName: 'Organization',
+ description: 'Organization URI or UUID. When set, lists the whole organization instead of one user.',
+ required: false,
+ }),
+ active: Property.StaticDropdown({
+ displayName: 'Status',
+ required: false,
+ options: {
+ options: [
+ { label: 'Active only', value: 'true' },
+ { label: 'Inactive only', value: 'false' },
+ ],
+ },
+ }),
+ count: calendlyCommon.count,
+ pageToken: calendlyCommon.pageToken,
+ },
+ async run({ auth, propsValue }) {
+ const owner = calendlyCommon.isProvided(propsValue.organization)
+ ? { organization: calendlyCommon.toUri({ resource: 'organizations', value: propsValue.organization }) }
+ : { user: await calendlyCommon.resolveUserUri({ token: auth.secret_text, user: propsValue.user }) };
+ const response = await calendlyCommon.calendlyRequest<CalendlyCollection<CalendlyRecord>>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path: '/event_types',
+ queryParams: {
+ ...owner,
+ active: propsValue.active,
+ ...calendlyCommon.pageQuery({ count: propsValue.count, pageToken: propsValue.pageToken }),
+ },
+ });
+ return calendlyCommon.toPage({ response });
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/list-organization-memberships.ts b/packages/pieces/community/calendly/src/lib/actions/list-organization-memberships.ts
new file mode 100644
index 00000000000..bdda4058226
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/list-organization-memberships.ts
@@ -0,0 +1,59 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyCollection, CalendlyRecord } from '../common';
+import { organizationMembershipsOutputSchema } from '../output-schemas';
+
+export const listOrganizationMembershipsAction = createAction({
+ auth: calendlyAuth,
+ name: 'list_organization_memberships',
+ classification: 'SEARCH',
+ displayName: 'List Organization Members',
+ description: 'Lists the members of a Calendly organization.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ "List the members of a Calendly organization with each membership URI, role (owner, admin, user) and the member's user URI, name and email. Leave Organization empty for the connected user's organization. Filter by email or role. Paginated with Page Token. Read-only.",
+ idempotent: true,
+ },
+ outputSchema: organizationMembershipsOutputSchema,
+ props: {
+ organization: calendlyCommon.organization,
+ email: Property.ShortText({
+ displayName: 'Email',
+ description: 'Only return the member with this email.',
+ required: false,
+ }),
+ role: Property.StaticDropdown({
+ displayName: 'Role',
+ required: false,
+ options: {
+ options: [
+ { label: 'Owner', value: 'owner' },
+ { label: 'Admin', value: 'admin' },
+ { label: 'User', value: 'user' },
+ ],
+ },
+ }),
+ count: calendlyCommon.count,
+ pageToken: calendlyCommon.pageToken,
+ },
+ async run({ auth, propsValue }) {
+ const organization = await calendlyCommon.resolveOrganizationUri({
+ token: auth.secret_text,
+ organization: propsValue.organization,
+ });
+ const response = await calendlyCommon.calendlyRequest<CalendlyCollection<CalendlyRecord>>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path: '/organization_memberships',
+ queryParams: {
+ organization,
+ email: propsValue.email?.trim(),
+ role: propsValue.role,
+ ...calendlyCommon.pageQuery({ count: propsValue.count, pageToken: propsValue.pageToken }),
+ },
+ });
+ return calendlyCommon.toPage({ response });
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/list-scheduled-events.ts b/packages/pieces/community/calendly/src/lib/actions/list-scheduled-events.ts
new file mode 100644
index 00000000000..72bcceabb31
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/list-scheduled-events.ts
@@ -0,0 +1,83 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyCollection, CalendlyRecord } from '../common';
+import { scheduledEventsOutputSchema } from '../output-schemas';
+
+export const listScheduledEventsAction = createAction({
+ auth: calendlyAuth,
+ name: 'list_scheduled_events',
+ classification: 'SEARCH',
+ displayName: 'List Scheduled Events',
+ description: 'Lists booked Calendly meetings.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ "List booked Calendly meetings with each URI, name, status, start and end time, event type, location and invitee counts. Defaults to the connected user's meetings; set Organization to list the whole organization (admin only). Filter by invitee email, status and a start-time range (UTC ISO 8601). Invitees are not included; use List Event Invitees. Paginated with Page Token. Read-only.",
+ idempotent: true,
+ },
+ outputSchema: scheduledEventsOutputSchema,
+ props: {
+ user: calendlyCommon.user,
+ organization: Property.ShortText({
+ displayName: 'Organization',
+ description: 'Organization URI or UUID. When set, lists the whole organization instead of one user.',
+ required: false,
+ }),
+ inviteeEmail: Property.ShortText({
+ displayName: 'Invitee Email',
+ required: false,
+ }),
+ status: Property.StaticDropdown({
+ displayName: 'Status',
+ required: false,
+ options: {
+ options: [
+ { label: 'Active', value: 'active' },
+ { label: 'Canceled', value: 'canceled' },
+ ],
+ },
+ }),
+ minStartTime: Property.DateTime({
+ displayName: 'Starts After',
+ required: false,
+ }),
+ maxStartTime: Property.DateTime({
+ displayName: 'Starts Before',
+ required: false,
+ }),
+ sort: Property.StaticDropdown({
+ displayName: 'Sort',
+ required: false,
+ defaultValue: 'start_time:asc',
+ options: {
+ options: [
+ { label: 'Start time, earliest first', value: 'start_time:asc' },
+ { label: 'Start time, latest first', value: 'start_time:desc' },
+ ],
+ },
+ }),
+ count: calendlyCommon.count,
+ pageToken: calendlyCommon.pageToken,
+ },
+ async run({ auth, propsValue }) {
+ const owner = calendlyCommon.isProvided(propsValue.organization)
+ ? { organization: calendlyCommon.toUri({ resource: 'organizations', value: propsValue.organization }) }
+ : { user: await calendlyCommon.resolveUserUri({ token: auth.secret_text, user: propsValue.user }) };
+ const response = await calendlyCommon.calendlyRequest<CalendlyCollection<CalendlyRecord>>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path: '/scheduled_events',
+ queryParams: {
+ ...owner,
+ invitee_email: propsValue.inviteeEmail?.trim(),
+ status: propsValue.status,
+ min_start_time: propsValue.minStartTime,
+ max_start_time: propsValue.maxStartTime,
+ sort: propsValue.sort,
+ ...calendlyCommon.pageQuery({ count: propsValue.count, pageToken: propsValue.pageToken }),
+ },
+ });
+ return calendlyCommon.toPage({ response });
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/list-user-availability-schedules.ts b/packages/pieces/community/calendly/src/lib/actions/list-user-availability-schedules.ts
new file mode 100644
index 00000000000..485d41c66a8
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/list-user-availability-schedules.ts
@@ -0,0 +1,33 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyCollection, CalendlyRecord } from '../common';
+import { userAvailabilitySchedulesOutputSchema } from '../output-schemas';
+
+export const listUserAvailabilitySchedulesAction = createAction({
+ auth: calendlyAuth,
+ name: 'list_user_availability_schedules',
+ classification: 'SEARCH',
+ displayName: 'List User Availability Schedules',
+ description: "Lists a user's availability schedules.",
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ "List a Calendly user's availability schedules (working hours), each with URI, name, default flag, timezone and weekday/date rules. Defaults to the connected user. Not paginated. Read-only.",
+ idempotent: true,
+ },
+ outputSchema: userAvailabilitySchedulesOutputSchema,
+ props: {
+ user: calendlyCommon.user,
+ },
+ async run({ auth, propsValue }) {
+ const user = await calendlyCommon.resolveUserUri({ token: auth.secret_text, user: propsValue.user });
+ const response = await calendlyCommon.calendlyRequest<CalendlyCollection<CalendlyRecord>>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path: '/user_availability_schedules',
+ queryParams: { user },
+ });
+ return { items: response.collection, count: response.collection.length };
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/list-user-busy-times.ts b/packages/pieces/community/calendly/src/lib/actions/list-user-busy-times.ts
new file mode 100644
index 00000000000..f2ced1ef34a
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/list-user-busy-times.ts
@@ -0,0 +1,47 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyCollection, CalendlyRecord } from '../common';
+import { userBusyTimesOutputSchema } from '../output-schemas';
+
+export const listUserBusyTimesAction = createAction({
+ auth: calendlyAuth,
+ name: 'list_user_busy_times',
+ classification: 'SEARCH',
+ displayName: 'List User Busy Times',
+ description: "Lists a user's busy time blocks.",
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ "List a Calendly user's busy intervals between Start Time and End Time (at most 7 days apart, End Time in the future; a past Start Time is moved to now), in ascending order. Includes Calendly bookings and events from connected calendars that have conflict checking on. Each item has type (calendly or external), start_time and end_time. Defaults to the connected user. Not paginated. Read-only.",
+ idempotent: true,
+ },
+ outputSchema: userBusyTimesOutputSchema,
+ props: {
+ user: calendlyCommon.user,
+ startTime: Property.DateTime({
+ displayName: 'Start Time',
+ required: true,
+ }),
+ endTime: Property.DateTime({
+ displayName: 'End Time',
+ description: 'At most 7 days after Start Time.',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const window = calendlyCommon.validateTimeWindow({
+ startTime: propsValue.startTime,
+ endTime: propsValue.endTime,
+ maxDays: 7,
+ });
+ const user = await calendlyCommon.resolveUserUri({ token: auth.secret_text, user: propsValue.user });
+ const response = await calendlyCommon.calendlyRequest<CalendlyCollection<CalendlyRecord>>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path: '/user_busy_times',
+ queryParams: { user, ...window },
+ });
+ return { items: response.collection, count: response.collection.length };
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/list-user-locations.ts b/packages/pieces/community/calendly/src/lib/actions/list-user-locations.ts
new file mode 100644
index 00000000000..ee93b963f32
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/list-user-locations.ts
@@ -0,0 +1,33 @@
+import { createAction } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyCollection, CalendlyRecord } from '../common';
+import { userLocationsOutputSchema } from '../output-schemas';
+
+export const listUserLocationsAction = createAction({
+ auth: calendlyAuth,
+ name: 'list_user_locations',
+ classification: 'SEARCH',
+ displayName: 'List User Meeting Locations',
+ description: 'Lists the meeting location types a user has set up.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'List the meeting location kinds a Calendly user can use (zoom_conference, google_conference, physical, ...) and whether each one is connected. Check this before choosing a location for Create Event Type or Create One-Off Meeting Link. Defaults to the connected user. Read-only.',
+ idempotent: true,
+ },
+ outputSchema: userLocationsOutputSchema,
+ props: {
+ user: calendlyCommon.user,
+ },
+ async run({ auth, propsValue }) {
+ const user = await calendlyCommon.resolveUserUri({ token: auth.secret_text, user: propsValue.user });
+ const response = await calendlyCommon.calendlyRequest<CalendlyCollection<CalendlyRecord>>({
+ token: auth.secret_text,
+ method: HttpMethod.GET,
+ path: '/locations',
+ queryParams: { user },
+ });
+ return { items: response.collection, count: response.collection.length };
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/update-event-type-availability.ts b/packages/pieces/community/calendly/src/lib/actions/update-event-type-availability.ts
new file mode 100644
index 00000000000..5d84879266a
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/update-event-type-availability.ts
@@ -0,0 +1,52 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyRecord } from '../common';
+import { updateEventTypeAvailabilityOutputSchema } from '../output-schemas';
+
+export const updateEventTypeAvailabilityAction = createAction({
+ auth: calendlyAuth,
+ name: 'update_event_type_availability',
+ classification: 'WRITE',
+ displayName: 'Update Event Type Availability',
+ description: 'Replaces the availability schedule of an event type.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Replace the availability schedule of one Calendly event type. Rules REPLACES every existing rule, so first call Get Event Type Availability, change the rules you need and send back the full list. Each rule is {"type":"wday","wday":"monday","intervals":[{"from":"09:00","to":"17:00"}]} or {"type":"date","date":"2026-12-24","intervals":[]} (empty intervals = unavailable that day).',
+ idempotent: true,
+ },
+ outputSchema: updateEventTypeAvailabilityOutputSchema,
+ props: {
+ eventType: calendlyCommon.eventType,
+ timezone: Property.ShortText({
+ displayName: 'Timezone',
+ description: 'IANA timezone such as America/New_York.',
+ required: true,
+ }),
+ rules: Property.Json({
+ displayName: 'Rules',
+ description:
+ 'Full list of rules, replacing the current ones. Example: [{"type":"wday","wday":"monday","intervals":[{"from":"09:00","to":"17:00"}]}]',
+ required: true,
+ }),
+ },
+ async run({ auth, propsValue }) {
+ const rules: unknown = propsValue.rules;
+ if (!Array.isArray(rules)) {
+ throw new Error('Rules must be a JSON array of availability rules.');
+ }
+ const response = await calendlyCommon.calendlyRequest<{ resource: CalendlyRecord }>({
+ token: auth.secret_text,
+ method: HttpMethod.PATCH,
+ path: '/event_type_availability_schedules',
+ queryParams: {
+ event_type: calendlyCommon.toUri({ resource: 'event_types', value: propsValue.eventType }),
+ },
+ body: {
+ availability_rule: { timezone: propsValue.timezone.trim(), rules },
+ },
+ });
+ return response.resource;
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/actions/update-event-type.ts b/packages/pieces/community/calendly/src/lib/actions/update-event-type.ts
new file mode 100644
index 00000000000..be143511050
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/actions/update-event-type.ts
@@ -0,0 +1,44 @@
+import { createAction, Property } from '@activepieces/pieces-framework';
+import { HttpMethod } from '@activepieces/pieces-common';
+import { calendlyAuth } from '../auth';
+import { calendlyCommon, CalendlyRecord } from '../common';
+import { eventTypeOutputSchema } from '../output-schemas';
+
+export const updateEventTypeAction = createAction({
+ auth: calendlyAuth,
+ name: 'update_event_type',
+ classification: 'WRITE',
+ displayName: 'Update Event Type',
+ description: 'Updates a one-on-one event type.',
+ audience: 'ai',
+ aiMetadata: {
+ description:
+ 'Update a one-on-one (solo) Calendly event type: name, duration, description, color, active status or locations. Only the fields you set are changed, except Locations, which replaces the whole location list when set. Group, collective and round-robin event types cannot be updated through the API.',
+ idempotent: true,
+ },
+ outputSchema: eventTypeOutputSchema,
+ props: {
+ eventType: calendlyCommon.eventType,
+ name: Property.ShortText({
+ displayName: 'Name',
+ required: false,
+ }),
+ ...calendlyCommon.eventTypeFields,
+ },
+ async run({ auth, propsValue }) {
+ const body = {
+ ...(calendlyCommon.isProvided(propsValue.name) ? { name: propsValue.name } : {}),
+ ...calendlyCommon.eventTypeBody(propsValue),
+ };
+ if (Object.keys(body).length === 0) {
+ throw new Error('Set at least one field to update.');
+ }
+ const response = await calendlyCommon.calendlyRequest<{ resource: CalendlyRecord }>({
+ token: auth.secret_text,
+ method: HttpMethod.PATCH,
+ path: `/event_types/${calendlyCommon.toUuid({ value: propsValue.eventType })}`,
+ body,
+ });
+ return response.resource;
+ },
+});
diff --git a/packages/pieces/community/calendly/src/lib/auth.ts b/packages/pieces/community/calendly/src/lib/auth.ts
index 0adb73fa024..a355a6bc48f 100644
--- a/packages/pieces/community/calendly/src/lib/auth.ts
+++ b/packages/pieces/community/calendly/src/lib/auth.ts
@@ -5,7 +5,8 @@ const markdown = `
## Obtain your Calendly Personal Token
1. Go to https://calendly.com/integrations/api_webhooks
2. Click on "Create New Token"
-3. Copy the token and paste it in the field below
+3. Select these scopes: \`users:read\`, \`organizations:read\`, \`event_types:read\`, \`event_types:write\`, \`availability:read\`, \`availability:write\`, \`scheduled_events:read\`, \`scheduled_events:write\`, \`scheduling_links:write\`, \`shares:write\`, \`locations:read\`, \`webhooks:read\`, \`webhooks:write\`
+4. Copy the token and paste it in the field below
`;
export const calendlyAuth = PieceAuth.SecretText({
@@ -14,7 +15,7 @@ export const calendlyAuth = PieceAuth.SecretText({
description: markdown,
validate: async ({ auth }) => {
try {
- calendlyCommon.getUser(auth);
+ await calendlyCommon.getUser(auth);
return {
valid: true,
};
diff --git a/packages/pieces/community/calendly/src/lib/common/index.ts b/packages/pieces/community/calendly/src/lib/common/index.ts
index d629d62f3af..dced857f00f 100644
--- a/packages/pieces/community/calendly/src/lib/common/index.ts
+++ b/packages/pieces/community/calendly/src/lib/common/index.ts
@@ -1,24 +1,242 @@
import { Property } from '@activepieces/pieces-framework';
import {
- HttpRequest,
+ AuthenticationType,
+ HttpError,
HttpMethod,
httpClient,
} from '@activepieces/pieces-common';
-interface CalendlyUser {
- /**User uri */
- uri: string;
- email: string;
- name: string;
- /**Organization uri */
- current_organization: string;
+async function calendlyRequest<T>({
+ token,
+ method,
+ path,
+ queryParams,
+ body,
+}: CalendlyRequest): Promise<T> {
+ const response = await httpClient
+ .sendRequest<T>({
+ method,
+ url: `${BASE_URL}${path}`,
+ queryParams: compactQuery({ query: queryParams ?? {} }),
+ body,
+ authentication: { type: AuthenticationType.BEARER_TOKEN, token },
+ })
+ .catch((error: unknown) => {
+ throw toCalendlyError({ error });
+ });
+ return response.body;
}
-export interface CalendlyWebhookInformation {
- webhookId: string;
+
+async function getUser(personalToken: string): Promise<CalendlyUser> {
+ const response = await calendlyRequest<{ resource: CalendlyUser }>({
+ token: personalToken,
+ method: HttpMethod.GET,
+ path: '/users/me',
+ });
+ return response.resource;
+}
+
+async function resolveUserUri({
+ token,
+ user,
+}: {
+ token: string;
+ user: string | undefined;
+}): Promise<string> {
+ if (isProvided(user)) {
+ return toUri({ resource: 'users', value: user });
+ }
+ const currentUser = await getUser(token);
+ return currentUser.uri;
+}
+
+async function resolveOrganizationUri({
+ token,
+ organization,
+}: {
+ token: string;
+ organization: string | undefined;
+}): Promise<string> {
+ if (isProvided(organization)) {
+ return toUri({ resource: 'organizations', value: organization });
+ }
+ const currentUser = await getUser(token);
+ return currentUser.current_organization;
+}
+
+function toUri({ resource, value }: { resource: string; value: string }): string {
+ const trimmed = value.trim();
+ return trimmed.startsWith('https://')
+ ? trimmed
+ : `${BASE_URL}/${resource}/${encodeURIComponent(trimmed)}`;
+}
+
+function toUuid({ value }: { value: string }): string {
+ const segments = value.trim().replace(/\/+$/, '').split('/');
+ return encodeURIComponent(segments[segments.length - 1]);
+}
+
+function toInviteeUri({
+ invitee,
+ scheduledEvent,
+}: {
+ invitee: string;
+ scheduledEvent: string | undefined;
+}): string {
+ const trimmed = invitee.trim();
+ if (trimmed.startsWith('https://')) {
+ return trimmed;
+ }
+ if (!isProvided(scheduledEvent)) {
+ throw new Error('Pass the full invitee URI, or set Scheduled Event when Invitee is a UUID.');
+ }
+ return `${BASE_URL}/scheduled_events/${toUuid({ value: scheduledEvent })}/invitees/${encodeURIComponent(trimmed)}`;
+}
+
+function UuidFromUri(uri: string): string | undefined {
+ return uri.split('/').pop();
+}
+
+function authorizationHeader(personalToken: string): string {
+ return `Bearer ${personalToken}`;
+}
+
+function pageQuery({
+ count,
+ pageToken,
+}: {
+ count: number | undefined;
+ pageToken: string | undefined;
+}): Record<string, string | undefined> {
+ return {
+ count: String(
+ Math.min(MAX_PAGE_SIZE, Math.max(1, Math.floor(count ?? DEFAULT_PAGE_SIZE)))
+ ),
+ page_token: isProvided(pageToken) ? pageToken.trim() : undefined,
+ };
+}
+
+function toPage<T>({ response }: { response: CalendlyCollection<T> }) {
+ return {
+ items: response.collection,
+ count: response.collection.length,
+ next_page_token: response.pagination?.next_page_token ?? null,
+ };
+}
+
+function validateTimeWindow({
+ startTime,
+ endTime,
+ maxDays,
+}: {
+ startTime: string;
+ endTime: string;
+ maxDays: number;
+}): { start_time: string; end_time: string } {
+ const start = Date.parse(startTime);
+ const end = Date.parse(endTime);
+ if (Number.isNaN(start) || Number.isNaN(end)) {
+ throw new Error('Start Time and End Time must be valid ISO 8601 date-times.');
+ }
+ const effectiveStart = Math.max(start, Date.now() + FUTURE_START_BUFFER_MS);
+ if (end <= effectiveStart) {
+ throw new Error('End Time must be after Start Time and in the future.');
+ }
+ if (end - effectiveStart > maxDays * DAY_MS) {
+ throw new Error(`The range between Start Time and End Time can be at most ${maxDays} days.`);
+ }
+ return {
+ start_time: new Date(effectiveStart).toISOString(),
+ end_time: new Date(end).toISOString(),
+ };
+}
+
+function isProvided(value: string | undefined | null): value is string {
+ return value !== undefined && value !== null && value.trim().length > 0;
+}
+
+function compactQuery({
+ query,
+}: {
+ query: Record<string, string | undefined>;
+}): Record<string, string> {
+ return Object.fromEntries(
+ Object.entries(query).filter(
+ (entry): entry is [string, string] => entry[1] !== undefined && entry[1] !== ''
+ )
+ );
+}
+
+function toCalendlyError({ error }: { error: unknown }): unknown {
+ if (!(error instanceof HttpError)) {
+ return error;
+ }
+ const { status, body } = error.response;
+ if (!isRecord(body)) {
+ return error;
+ }
+ const requiredScopes = Array.isArray(body['required_scopes'])
+ ? body['required_scopes'].filter((scope): scope is string => typeof scope === 'string')
+ : [];
+ if (status === 403 && requiredScopes.length > 0) {
+ return new Error(
+ `Your Calendly Personal Access Token is missing the scope(s): ${requiredScopes.join(', ')}. Create a new token with these scopes and reconnect.`
+ );
+ }
+ const title = typeof body['title'] === 'string' ? body['title'] : 'Calendly error';
+ const message = typeof body['message'] === 'string' ? body['message'] : '';
+ const details = Array.isArray(body['details']) ? ` ${JSON.stringify(body['details'])}` : '';
+ return new Error(`${title} (${status}): ${message}${details}`.trim());
+}
+
+function eventTypeBody({
+ duration,
+ description,
+ color,
+ active,
+ locations,
+}: EventTypeFieldValues): Record<string, unknown> {
+ const locationList = (locations ?? []).filter(isRecord).map((location) =>
+ Object.fromEntries(
+ Object.entries(location).filter(
+ (entry): entry is [string, string] => typeof entry[1] === 'string' && entry[1].trim() !== ''
+ )
+ )
+ );
+ return {
+ ...(duration !== undefined && duration !== null ? { duration } : {}),
+ ...(isProvided(description) ? { description } : {}),
+ ...(isProvided(color) ? { color: color.trim() } : {}),
+ ...(isProvided(active) ? { active: active === 'true' } : {}),
+ ...(locationList.length > 0 ? { locations: locationList } : {}),
+ };
+}
+
+function isRecord(value: unknown): value is Record<string, unknown> {
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
}
+const BASE_URL = 'https://api.calendly.com';
+const DEFAULT_PAGE_SIZE = 20;
+const MAX_PAGE_SIZE = 100;
+const DAY_MS = 24 * 60 * 60 * 1000;
+const FUTURE_START_BUFFER_MS = 60 * 1000;
+
+const LOCATION_KINDS = [
+ { label: 'Zoom', value: 'zoom_conference' },
+ { label: 'Google Meet', value: 'google_conference' },
+ { label: 'Microsoft Teams', value: 'microsoft_teams_conference' },
+ { label: 'Webex', value: 'webex_conference' },
+ { label: 'GoToMeeting', value: 'gotomeeting_conference' },
+ { label: 'In person', value: 'physical' },
+ { label: 'Phone call (host calls invitee)', value: 'outbound_call' },
+ { label: 'Phone call (invitee calls host)', value: 'inbound_call' },
+ { label: 'Custom', value: 'custom' },
+ { label: 'Ask invitee', value: 'ask_invitee' },
+];
+
export const calendlyCommon = {
- baseUrl: 'https://api.calendly.com',
+ baseUrl: BASE_URL,
scope: Property.StaticDropdown({
displayName: 'Scope',
required: true,
@@ -30,19 +248,150 @@ export const calendlyCommon = {
disabled: false,
},
}),
- getUser: async (personalToken: string) => {
- const request: HttpRequest = {
- method: HttpMethod.GET,
- url: `${calendlyCommon.baseUrl}/users/me`,
- headers: {
- Authorization: calendlyCommon.authorizationHeader(personalToken),
+ user: Property.ShortText({
+ displayName: 'User',
+ description:
+ 'User URI (https://api.calendly.com/users/...) or UUID. Leave empty to use the connected user.',
+ required: false,
+ }),
+ organization: Property.ShortText({
+ displayName: 'Organization',
+ description:
+ "Organization URI (https://api.calendly.com/organizations/...) or UUID. Leave empty to use the connected user's organization.",
+ required: false,
+ }),
+ eventType: Property.ShortText({
+ displayName: 'Event Type',
+ description: 'Event type URI (https://api.calendly.com/event_types/...) or UUID, from List Event Types.',
+ required: true,
+ }),
+ scheduledEvent: Property.ShortText({
+ displayName: 'Scheduled Event',
+ description:
+ 'Scheduled event URI (https://api.calendly.com/scheduled_events/...) or UUID, from List Scheduled Events or a trigger.',
+ required: true,
+ }),
+ invitee: Property.ShortText({
+ displayName: 'Invitee',
+ description:
+ 'Invitee URI (https://api.calendly.com/scheduled_events/.../invitees/...), or its UUID together with Scheduled Event.',
+ required: true,
+ }),
+ optionalScheduledEvent: Property.ShortText({
+ displayName: 'Scheduled Event',
+ description: 'Scheduled event URI or UUID. Only needed when Invitee is a UUID.',
+ required: false,
+ }),
+ count: Property.Number({
+ displayName: 'Page Size',
+ description: 'How many items to return, from 1 to 100.',
+ required: false,
+ defaultValue: DEFAULT_PAGE_SIZE,
+ }),
+ pageToken: Property.ShortText({
+ displayName: 'Page Token',
+ description: 'Next Page Token from a previous call. Leave empty for the first page.',
+ required: false,
+ }),
+ eventTypeFields: {
+ duration: Property.Number({
+ displayName: 'Duration (minutes)',
+ required: false,
+ }),
+ description: Property.LongText({
+ displayName: 'Description',
+ required: false,
+ }),
+ color: Property.ShortText({
+ displayName: 'Color',
+ description: 'Hex color, for example #ff5733.',
+ required: false,
+ }),
+ active: Property.StaticDropdown({
+ displayName: 'Status',
+ required: false,
+ options: {
+ options: [
+ { label: 'Active', value: 'true' },
+ { label: 'Inactive', value: 'false' },
+ ],
},
- };
- const response = await httpClient.sendRequest<{ resource: CalendlyUser }>(
- request
- );
- return response.body.resource;
+ }),
+ locations: Property.Array({
+ displayName: 'Locations',
+ description: 'Replaces all locations of the event type when set.',
+ required: false,
+ properties: {
+ kind: Property.StaticDropdown({
+ displayName: 'Kind',
+ required: true,
+ options: {
+ options: LOCATION_KINDS.map((kind) => ({ label: kind.label, value: kind.value })),
+ },
+ }),
+ location: Property.ShortText({
+ displayName: 'Location',
+ description: 'Address or link, for physical and custom locations.',
+ required: false,
+ }),
+ phone_number: Property.ShortText({
+ displayName: 'Phone Number',
+ description: 'Required for inbound calls.',
+ required: false,
+ }),
+ additional_info: Property.ShortText({
+ displayName: 'Additional Info',
+ required: false,
+ }),
+ },
+ }),
},
- authorizationHeader: (personalToken: string) => `Bearer ${personalToken}`,
- UuidFromUri: (uri: string) => uri.split('/').pop(),
+ calendlyRequest,
+ getUser,
+ resolveUserUri,
+ resolveOrganizationUri,
+ toUri,
+ toUuid,
+ toInviteeUri,
+ pageQuery,
+ toPage,
+ validateTimeWindow,
+ eventTypeBody,
+ isProvided,
+ authorizationHeader,
+ UuidFromUri,
+};
+
+export interface CalendlyWebhookInformation {
+ webhookId: string;
+}
+
+export type CalendlyRecord = Record<string, unknown>;
+
+export type CalendlyCollection<T> = {
+ collection: T[];
+ pagination?: { next_page_token: string | null };
+};
+
+type EventTypeFieldValues = {
+ duration?: number | null;
+ description?: string | null;
+ color?: string | null;
+ active?: string | null;
+ locations?: unknown[] | null;
+};
+
+type CalendlyRequest = {
+ token: string;
+ method: HttpMethod;
+ path: string;
+ queryParams?: Record<string, string | undefined>;
+ body?: unknown;
+};
+
+type CalendlyUser = {
+ uri: string;
+ email: string;
+ name: string;
+ current_organization: string;
};
diff --git a/packages/pieces/community/calendly/src/lib/output-schemas.ts b/packages/pieces/community/calendly/src/lib/output-schemas.ts
new file mode 100644
index 00000000000..11a931b51d2
--- /dev/null
+++ b/packages/pieces/community/calendly/src/lib/output-schemas.ts
@@ -0,0 +1,428 @@
+import { OutputSchema, OutputSchemaField } from '@activepieces/pieces-framework';
+
+const pageFields: OutputSchemaField[] = [
+ { key: 'count', label: 'Count', format: 'number' },
+ {
+ key: 'next_page_token',
+ label: 'Next Page Token',
+ description: 'Pass as Page Token to fetch the next page. Empty on the last page.',
+ },
+];
+
+const userFields: OutputSchemaField[] = [
+ { key: 'uri', label: 'User URI', format: 'url' },
+ { key: 'name', label: 'Name' },
+ { key: 'email', label: 'Email', format: 'email' },
+ { key: 'slug', label: 'Slug' },
+ { key: 'scheduling_url', label: 'Scheduling URL', format: 'url' },
+ { key: 'timezone', label: 'Timezone' },
+ { key: 'avatar_url', label: 'Avatar', format: 'image' },
+ { key: 'locale', label: 'Locale' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+];
+
+const membershipFields: OutputSchemaField[] = [
+ { key: 'uri', label: 'Membership URI', format: 'url' },
+ { key: 'role', label: 'Role' },
+ { key: 'organization', label: 'Organization URI', format: 'url' },
+ { key: 'user', label: 'User', children: userFields },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+];
+
+const eventTypeFields: OutputSchemaField[] = [
+ { key: 'uri', label: 'Event Type URI', format: 'url' },
+ { key: 'name', label: 'Name' },
+ { key: 'slug', label: 'Slug' },
+ { key: 'scheduling_url', label: 'Scheduling URL', format: 'url' },
+ { key: 'active', label: 'Active', format: 'boolean' },
+ { key: 'duration', label: 'Duration (minutes)', format: 'number' },
+ { key: 'kind', label: 'Kind' },
+ { key: 'type', label: 'Type' },
+ { key: 'pooling_type', label: 'Pooling Type' },
+ { key: 'secret', label: 'Secret', format: 'boolean' },
+ { key: 'color', label: 'Color' },
+ { key: 'description_plain', label: 'Description' },
+ { key: 'locations', label: 'Locations', labelKey: 'kind', listItems: [{ key: 'kind', label: 'Kind' }, { key: 'location', label: 'Location' }] },
+ {
+ key: 'profile',
+ label: 'Host',
+ children: [
+ { key: 'name', label: 'Name' },
+ { key: 'owner', label: 'Owner URI', format: 'url' },
+ { key: 'type', label: 'Type' },
+ ],
+ },
+ {
+ key: 'custom_questions',
+ label: 'Booking Questions',
+ labelKey: 'name',
+ listItems: [
+ { key: 'name', label: 'Question' },
+ { key: 'type', label: 'Type' },
+ { key: 'required', label: 'Required', format: 'boolean' },
+ { key: 'enabled', label: 'Enabled', format: 'boolean' },
+ ],
+ },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+];
+
+const availabilityRuleFields: OutputSchemaField[] = [
+ { key: 'type', label: 'Type' },
+ { key: 'wday', label: 'Weekday' },
+ { key: 'date', label: 'Date', format: 'date' },
+ {
+ key: 'intervals',
+ label: 'Intervals',
+ labelKey: 'from',
+ listItems: [
+ { key: 'from', label: 'From' },
+ { key: 'to', label: 'To' },
+ ],
+ },
+];
+
+const availabilityScheduleFields: OutputSchemaField[] = [
+ { key: 'uri', label: 'Schedule URI', format: 'url' },
+ { key: 'name', label: 'Name' },
+ { key: 'default', label: 'Default', format: 'boolean' },
+ { key: 'timezone', label: 'Timezone' },
+ { key: 'user', label: 'User URI', format: 'url' },
+ { key: 'rules', label: 'Rules', labelKey: 'wday', listItems: availabilityRuleFields },
+];
+
+const eventTypeAvailabilityFields: OutputSchemaField[] = [
+ { key: 'event_type', label: 'Event Type URI', format: 'url' },
+ { key: 'availability_setting', label: 'Availability Setting' },
+ {
+ key: 'availability_rule',
+ label: 'Availability',
+ children: [
+ { key: 'uri', label: 'Schedule URI', format: 'url' },
+ { key: 'name', label: 'Schedule Name' },
+ { key: 'timezone', label: 'Timezone' },
+ { key: 'rules', label: 'Rules', labelKey: 'wday', listItems: availabilityRuleFields },
+ ],
+ },
+];
+
+const schedulingLinkFields: OutputSchemaField[] = [
+ { key: 'booking_url', label: 'Booking URL', format: 'url' },
+ { key: 'owner', label: 'Event Type URI', format: 'url' },
+ { key: 'owner_type', label: 'Owner Type' },
+];
+
+const cancellationFields: OutputSchemaField[] = [
+ { key: 'canceled_by', label: 'Canceled By' },
+ { key: 'canceler_type', label: 'Canceler Type' },
+ { key: 'reason', label: 'Reason' },
+ { key: 'created_at', label: 'Canceled At', format: 'datetime' },
+];
+
+const scheduledEventFields: OutputSchemaField[] = [
+ { key: 'uri', label: 'Event URI', format: 'url' },
+ { key: 'name', label: 'Name' },
+ { key: 'status', label: 'Status' },
+ { key: 'start_time', label: 'Start Time', format: 'datetime' },
+ { key: 'end_time', label: 'End Time', format: 'datetime' },
+ { key: 'event_type', label: 'Event Type URI', format: 'url' },
+ {
+ key: 'location',
+ label: 'Location',
+ children: [
+ { key: 'type', label: 'Type' },
+ { key: 'join_url', label: 'Join URL', format: 'url' },
+ { key: 'location', label: 'Location' },
+ { key: 'status', label: 'Status' },
+ ],
+ },
+ {
+ key: 'invitees_counter',
+ label: 'Invitees',
+ children: [
+ { key: 'active', label: 'Active', format: 'number' },
+ { key: 'total', label: 'Total', format: 'number' },
+ { key: 'limit', label: 'Limit', format: 'number' },
+ ],
+ },
+ {
+ key: 'event_memberships',
+ label: 'Hosts',
+ labelKey: 'user_name',
+ listItems: [
+ { key: 'user', label: 'User URI', format: 'url' },
+ { key: 'user_name', label: 'Name' },
+ { key: 'user_email', label: 'Email', format: 'email' },
+ ],
+ },
+ { key: 'cancellation', label: 'Cancellation', children: cancellationFields },
+ { key: 'meeting_notes_plain', label: 'Meeting Notes' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+];
+
+const inviteeFields: OutputSchemaField[] = [
+ { key: 'uri', label: 'Invitee URI', format: 'url' },
+ { key: 'name', label: 'Name' },
+ { key: 'email', label: 'Email', format: 'email' },
+ { key: 'first_name', label: 'First Name' },
+ { key: 'last_name', label: 'Last Name' },
+ { key: 'status', label: 'Status' },
+ { key: 'timezone', label: 'Timezone' },
+ { key: 'event', label: 'Event URI', format: 'url' },
+ { key: 'rescheduled', label: 'Rescheduled', format: 'boolean' },
+ { key: 'cancel_url', label: 'Cancel URL', format: 'url' },
+ { key: 'reschedule_url', label: 'Reschedule URL', format: 'url' },
+ {
+ key: 'questions_and_answers',
+ label: 'Answers',
+ labelKey: 'question',
+ listItems: [
+ { key: 'question', label: 'Question' },
+ { key: 'answer', label: 'Answer' },
+ ],
+ },
+ {
+ key: 'tracking',
+ label: 'Tracking',
+ children: [
+ { key: 'utm_source', label: 'UTM Source' },
+ { key: 'utm_medium', label: 'UTM Medium' },
+ { key: 'utm_campaign', label: 'UTM Campaign' },
+ { key: 'utm_content', label: 'UTM Content' },
+ { key: 'utm_term', label: 'UTM Term' },
+ ],
+ },
+ {
+ key: 'no_show',
+ label: 'No Show',
+ children: [
+ { key: 'uri', label: 'No Show URI', format: 'url' },
+ { key: 'created_at', label: 'Marked At', format: 'datetime' },
+ ],
+ },
+ {
+ key: 'payment',
+ label: 'Payment',
+ children: [
+ { key: 'external_id', label: 'Payment ID' },
+ { key: 'provider', label: 'Provider' },
+ { key: 'amount', label: 'Amount', format: 'number' },
+ { key: 'currency', label: 'Currency' },
+ { key: 'successful', label: 'Successful', format: 'boolean' },
+ { key: 'terms', label: 'Terms' },
+ ],
+ },
+ {
+ key: 'reconfirmation',
+ label: 'Reconfirmation',
+ children: [
+ { key: 'created_at', label: 'Requested At', format: 'datetime' },
+ { key: 'confirmed_at', label: 'Confirmed At', format: 'datetime' },
+ ],
+ },
+ { key: 'text_reminder_number', label: 'Text Reminder Number' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ { key: 'updated_at', label: 'Updated At', format: 'datetime' },
+];
+
+export const userOutputSchema: OutputSchema = {
+ fields: [...userFields, { key: 'current_organization', label: 'Organization URI', format: 'url' }],
+};
+
+export const organizationOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'uri', label: 'Organization URI', format: 'url' },
+ { key: 'name', label: 'Name' },
+ { key: 'plan', label: 'Plan' },
+ { key: 'stage', label: 'Stage' },
+ { key: 'kind', label: 'Kind' },
+ { key: 'created_at', label: 'Created At', format: 'datetime' },
+ ],
+};
+
+export const organizationMembershipsOutputSchema: OutputSchema = {
+ fields: [{ key: 'items', label: 'Members', labelKey: 'user.name', listItems: membershipFields }, ...pageFields],
+};
+
+export const organizationMembershipOutputSchema: OutputSchema = {
+ fields: membershipFields,
+};
+
+export const findUserOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'found', label: 'Found', format: 'boolean' },
+ { key: 'user', label: 'User', children: userFields },
+ { key: 'role', label: 'Role' },
+ { key: 'membership_uri', label: 'Membership URI', format: 'url' },
+ ],
+};
+
+export const eventTypesOutputSchema: OutputSchema = {
+ fields: [{ key: 'items', label: 'Event Types', labelKey: 'name', listItems: eventTypeFields }, ...pageFields],
+};
+
+export const eventTypeOutputSchema: OutputSchema = {
+ fields: eventTypeFields,
+};
+
+export const eventTypeHostsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'items',
+ label: 'Hosts',
+ labelKey: 'member.name',
+ listItems: [
+ { key: 'uri', label: 'Host Membership URI', format: 'url' },
+ { key: 'member', label: 'Host', children: userFields },
+ { key: 'created_at', label: 'Added At', format: 'datetime' },
+ ],
+ },
+ ...pageFields,
+ ],
+};
+
+export const availableTimesOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'items',
+ label: 'Available Times',
+ labelKey: 'start_time',
+ listItems: [
+ { key: 'start_time', label: 'Start Time', format: 'datetime' },
+ { key: 'status', label: 'Status' },
+ { key: 'invitees_remaining', label: 'Spots Left', format: 'number' },
+ { key: 'scheduling_url', label: 'Booking URL', format: 'url' },
+ ],
+ },
+ { key: 'count', label: 'Count', format: 'number' },
+ ],
+};
+
+export const userBusyTimesOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'items',
+ label: 'Busy Times',
+ labelKey: 'start_time',
+ listItems: [
+ { key: 'type', label: 'Type' },
+ { key: 'start_time', label: 'Start Time', format: 'datetime' },
+ { key: 'end_time', label: 'End Time', format: 'datetime' },
+ { key: 'buffered_start_time', label: 'Buffered Start Time', format: 'datetime' },
+ { key: 'buffered_end_time', label: 'Buffered End Time', format: 'datetime' },
+ { key: 'event', label: 'Event', children: [{ key: 'uri', label: 'Event URI', format: 'url' }] },
+ ],
+ },
+ { key: 'count', label: 'Count', format: 'number' },
+ ],
+};
+
+export const eventTypeAvailabilityOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'items', label: 'Availability Schedules', labelKey: 'availability_rule.name', listItems: eventTypeAvailabilityFields },
+ { key: 'count', label: 'Count', format: 'number' },
+ ],
+};
+
+export const updateEventTypeAvailabilityOutputSchema: OutputSchema = {
+ fields: eventTypeAvailabilityFields,
+};
+
+export const userAvailabilitySchedulesOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'items', label: 'Availability Schedules', labelKey: 'name', listItems: availabilityScheduleFields },
+ { key: 'count', label: 'Count', format: 'number' },
+ ],
+};
+
+export const userAvailabilityScheduleOutputSchema: OutputSchema = {
+ fields: availabilityScheduleFields,
+};
+
+export const userLocationsOutputSchema: OutputSchema = {
+ fields: [
+ {
+ key: 'items',
+ label: 'Locations',
+ labelKey: 'kind',
+ listItems: [
+ { key: 'kind', label: 'Kind' },
+ { key: 'connected', label: 'Connected', format: 'boolean' },
+ ],
+ },
+ { key: 'count', label: 'Count', format: 'number' },
+ ],
+};
+
+export const schedulingLinkOutputSchema: OutputSchema = {
+ fields: schedulingLinkFields,
+};
+
+export const shareOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'uri', label: 'Share URI', format: 'url' },
+ { key: 'scheduling_links', label: 'Booking Links', labelKey: 'booking_url', listItems: schedulingLinkFields },
+ {
+ key: 'share_override',
+ label: 'Overrides',
+ children: [
+ { key: 'name', label: 'Name' },
+ { key: 'duration', label: 'Duration (minutes)', format: 'number' },
+ { key: 'period_type', label: 'Booking Window' },
+ { key: 'start_date', label: 'Start Date', format: 'date' },
+ { key: 'end_date', label: 'End Date', format: 'date' },
+ { key: 'hide_location', label: 'Hide Location', format: 'boolean' },
+ ],
+ },
+ ],
+};
+
+export const scheduledEventsOutputSchema: OutputSchema = {
+ fields: [{ key: 'items', label: 'Events', labelKey: 'name', listItems: scheduledEventFields }, ...pageFields],
+};
+
+export const scheduledEventOutputSchema: OutputSchema = {
+ fields: scheduledEventFields,
+};
+
+export const findInviteeBookingsOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'found', label: 'Found', format: 'boolean' },
+ { key: 'count', label: 'Count', format: 'number' },
+ { key: 'events', label: 'Events', labelKey: 'start_time', listItems: scheduledEventFields },
+ ],
+};
+
+export const cancellationOutputSchema: OutputSchema = {
+ fields: cancellationFields,
+};
+
+export const eventInviteesOutputSchema: OutputSchema = {
+ fields: [{ key: 'items', label: 'Invitees', labelKey: 'name', listItems: inviteeFields }, ...pageFields],
+};
+
+export const eventInviteeOutputSchema: OutputSchema = {
+ fields: inviteeFields,
+};
+
+export const inviteeTriggerOutputSchema: OutputSchema = {
+ fields: [
+ { key: 'event', label: 'Webhook Event' },
+ { key: 'created_at', label: 'Received At', format: 'datetime' },
+ {
+ key: 'payload',
+ label: 'Invitee',
+ children: [
+ ...inviteeFields,
+ { key: 'cancellation', label: 'Cancellation', children: cancellationFields },
+ {
+ key: 'scheduled_event',
+ label: 'Scheduled Event',
+ children: scheduledEventFields,
+ },
+ ],
+ },
+ ],
+};
diff --git a/packages/pieces/community/calendly/src/lib/trigger/invitee-canceled.trigger.ts b/packages/pieces/community/calendly/src/lib/trigger/invitee-canceled.trigger.ts
index e8a2f6d4218..932749a88ec 100644
--- a/packages/pieces/community/calendly/src/lib/trigger/invitee-canceled.trigger.ts
+++ b/packages/pieces/community/calendly/src/lib/trigger/invitee-canceled.trigger.ts
@@ -7,6 +7,7 @@ import {
} from '@activepieces/pieces-common';
import { calendlyCommon, CalendlyWebhookInformation } from '../common';
import { calendlyAuth } from '../auth';
+import { inviteeTriggerOutputSchema } from '../output-schemas';
const triggerNameInStore = 'calendly_invitee_canceled_trigger';
@@ -64,6 +65,7 @@ export const calendlyInviteeCanceled = createTrigger({
uri: 'https://api.calendly.com/scheduled_events/AAAAAAAAAAAaA/invitees/AAAAAAAA',
},
},
+ outputSchema: inviteeTriggerOutputSchema,
type: TriggerStrategy.WEBHOOK,
async onEnable(context) {
const calendlyUser = await calendlyCommon.getUser(context.auth.secret_text);
diff --git a/packages/pieces/community/calendly/src/lib/trigger/invitee-created.trigger.ts b/packages/pieces/community/calendly/src/lib/trigger/invitee-created.trigger.ts
index 845308afc88..bc83542e76f 100644
--- a/packages/pieces/community/calendly/src/lib/trigger/invitee-created.trigger.ts
+++ b/packages/pieces/community/calendly/src/lib/trigger/invitee-created.trigger.ts
@@ -7,6 +7,7 @@ import {
} from '@activepieces/pieces-common';
import { calendlyCommon, CalendlyWebhookInformation } from '../common';
import { calendlyAuth } from '../auth';
+import { inviteeTriggerOutputSchema } from '../output-schemas';
const triggerNameInStore = 'calendly_invitee_created_trigger';
@@ -50,6 +51,7 @@ export const calendlyInviteeCreated = createTrigger({
uri: 'https://api.calendly.com/scheduled_events/AAAAAAAAAAAaA/invitees/AAAAAAAAAAAA',
},
},
+ outputSchema: inviteeTriggerOutputSchema,
type: TriggerStrategy.WEBHOOK,
async onEnable(context) {
const calendlyUser = await calendlyCommon.getUser(context.auth.secret_text);