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

6.0 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { MeetingMessageBody } from '../common/models';
import { zoomMeetingDropdown } from '../common/props';
import { zoomClient } from '../common/client';
import { updateMeetingOutputSchema } from '../output-schemas';
import { zoomAuth } from '../..';

export const zoomUpdateMeeting = createAction({
  auth: zoomAuth,
  name: 'zoom_update_meeting',
  classification: 'WRITE',
  displayName: 'Update Zoom Meeting',
  description: 'Update the details of an existing meeting.',
  audience: 'human',
  aiMetadata: { description: 'Modifies an existing Zoom meeting identified by its meeting ID, applying only the fields you supply (topic, start time, duration, timezone, password, and audio/video/recording/waiting-room settings). Use to reschedule or reconfigure a meeting. Repeating the call with the same values produces the same end state, so it is idempotent.', idempotent: true },
  outputSchema: updateMeetingOutputSchema,
  props: {
    meeting_id: zoomMeetingDropdown,
    topic: Property.ShortText({
      displayName: "Meeting's topic",
      description: "The meeting's topic",
      required: false,
    }),
    start_time: Property.ShortText({
      displayName: 'Start Time',
      description:
        'Meeting start date-time (ISO 8601 format, e.g., 2023-05-01T12:00:00Z)',
      required: false,
    }),
    duration: Property.Number({
      displayName: 'Duration (in Minutes)',
      description: 'Duration of the meeting',
      required: false,
    }),
    timezone: Property.ShortText({
      displayName: 'Timezone',
      description: 'Timezone for the meeting (e.g., UTC, America/New_York)',
      required: false,
    }),
    auto_recording: Property.StaticDropdown({
      displayName: 'Auto Recording',
      required: false,
      options: {
        disabled: false,
        options: [
          { label: 'Local', value: 'local' },
          { label: 'Cloud', value: 'cloud' },
          { label: 'None', value: 'none' },
        ],
      },
    }),
    audio: Property.StaticDropdown({
      displayName: 'Audio',
      required: false,
      options: {
        disabled: false,
        options: [
          { label: 'Both telephony and VoIP', value: 'both' },
          { label: 'Telephony only', value: 'telephony' },
          { label: 'VoIP only', value: 'voip' },
          { label: 'Third party audio conference', value: 'thirdParty' },
        ],
      },
    }),
    agenda: Property.LongText({
      displayName: 'Agenda',
      description: "The meeting's agenda",
      required: false,
    }),
    password: Property.ShortText({
      displayName: 'Password',
      description:
        'The password required to join the meeting. By default, a password can only have a maximum length of 10 characters and only contain alphanumeric characters and the @, -, _, and * characters.',
      required: false,
    }),
    host_video: Property.Checkbox({
      displayName: 'Host Video',
      description: 'Whether to start video when the host joins the meeting.',
      required: false,
    }),
    participant_video: Property.Checkbox({
      displayName: 'Participant Video',
      description: 'Whether to start video when participants join the meeting.',
      required: false,
    }),
    join_before_host: Property.Checkbox({
      displayName: 'Join Before Host',
      description:
        'Whether participants can join the meeting before the host starts the meeting.',
      required: false,
    }),
    mute_upon_entry: Property.Checkbox({
      displayName: 'Mute Upon Entry',
      description: 'Whether to mute participants upon entry.',
      required: false,
    }),
    waiting_room: Property.Checkbox({
      displayName: 'Waiting Room',
      description: 'Whether to enable waiting room.',
      required: false,
    }),
  },
  async run(context) {
    const cleanMeetingId = zoomClient.normalizeMeetingId(context.propsValue.meeting_id);

    const body: Partial<MeetingMessageBody> = {};

    if (context.propsValue.topic) body.topic = context.propsValue.topic;
    if (context.propsValue.start_time)
      body.start_time = context.propsValue.start_time;
    if (context.propsValue.duration)
      body.duration = context.propsValue.duration;
    if (context.propsValue.timezone)
      body.timezone = context.propsValue.timezone;
    if (context.propsValue.agenda) body.agenda = context.propsValue.agenda;
    if (context.propsValue.password)
      body.password = context.propsValue.password;

    const settings: MeetingMessageBody['settings'] = {};
    let hasSettings = false;

    if (context.propsValue.auto_recording) {
      settings.auto_recording = context.propsValue.auto_recording;
      hasSettings = true;
    }
    if (context.propsValue.audio) {
      settings.audio = context.propsValue.audio;
      hasSettings = true;
    }
    if (context.propsValue.host_video !== undefined) {
      settings.host_video = context.propsValue.host_video;
      hasSettings = true;
    }
    if (context.propsValue.participant_video !== undefined) {
      settings.participant_video = context.propsValue.participant_video;
      hasSettings = true;
    }
    if (context.propsValue.join_before_host !== undefined) {
      settings.join_before_host = context.propsValue.join_before_host;
      hasSettings = true;
    }
    if (context.propsValue.mute_upon_entry !== undefined) {
      settings.mute_upon_entry = context.propsValue.mute_upon_entry;
      hasSettings = true;
    }
    if (context.propsValue.waiting_room !== undefined) {
      settings.waiting_room = context.propsValue.waiting_room;
      hasSettings = true;
    }

    if (hasSettings) {
      body.settings = settings;
    }

    await zoomClient.request({
      accessToken: context.auth.access_token,
      method: HttpMethod.PATCH,
      path: `/meetings/${cleanMeetingId}`,
      body,
      scope: 'meeting:update:meeting',
    });

    return { success: true, message: 'Meeting updated successfully', meeting_id: cleanMeetingId };
  },
});