How to Schedule a Meeting in Google Meet with Apps Script easy steps

Advertisements

Google Calendar API is used in this Apps Script sample to arrange video meetings in Google Meet with one or more participants. Teachers who want to meet with their students on a regular basis but don’t want to manually create meeting invites may use this tool to automate the entire procedure for the entire class.

setup Google Meeting with Apps Script

Give your Google meeting a name, a start date, an end date, a list of attendees, and a frequency with which you’d want to be reminded. Your Google Calendar will be updated with a new meeting date and time, and you’ll receive a Google Meet link that you can email to students and coworkers.

const createGoogleMeeting = () => {
  // The default calendar where this meeting should be created
  const calendarId = 'primary';

  // Schedule a meeting for May 30, 2022 at 1:45 PM
  // January = 0, February = 1, March = 2, and so on
  const eventStartDate = new Date(2022, 5, 30, 13, 45);

  // Set the meeting duration to 45 minutes
  const eventEndDate = new Date(eventStartDate.getTime());
  eventEndDate.setMinutes(eventEndDate.getMinutes() + 45);

  const getEventDate = (eventDate) => {
    // Dates are computed as per the script's default timezone
    const timeZone = Session.getScriptTimeZone();

    // Format the datetime in `full-date T full-time` format
    return {
      timeZone,
      dateTime: Utilities.formatDate(eventDate, timeZone, "yyyy-MM-dd'T'HH:mm:ss"),
    };
  };

  // Email addresses and names (optional) of meeting attendees
  const meetingAttendees = [
    {
      displayName: 'Amit Agarwal',
      email: '[email protected]',
      responseStatus: 'accepted',
    },
    { email: '[email protected]', responseStatus: 'needsAction' },
    { email: '[email protected]', responseStatus: 'needsAction' },
    {
      displayName: 'Angus McDonald',
      email: '[email protected]',
      responseStatus: 'tentative',
    },
  ];

  // Generate a random id
  const meetingRequestId = Utilities.getUuid();

  // Send an email reminder a day prior to the meeting and also
  // browser notifications15 minutes before the event start time
  const meetingReminders = [
    {
      method: 'email',
      minutes: 24 * 60,
    },
    {
      method: 'popup',
      minutes: 15,
    },
  ];

  const { hangoutLink, htmlLink } = Calendar.Events.insert(
    {
      summary: 'Maths 101: Trigonometry Lecture',
      description: 'Analyzing the graphs of Trigonometric Functions',
      location: '10 Hanover Square, NY 10005',
      attendees: meetingAttendees,
      conferenceData: {
        createRequest: {
          requestId: meetingRequestId,
          conferenceSolutionKey: {
            type: 'hangoutsMeet',
          },
        },
      },
      start: getEventDate(eventStartDate),
      end: getEventDate(eventEndDate),
      guestsCanInviteOthers: false,
      guestsCanModify: false,
      status: 'confirmed',
      reminders: {
        useDefault: false,
        overrides: meetingReminders,
      },
    },
    calendarId,
    { conferenceDataVersion: 1 }
  );

  Logger.log('Launch meeting in Google Meet: %s', hangoutLink);
  Logger.log('Open event inside Google Calendar: %s', htmlLink);
};

Google Meeting with Recurring Schedule

The code shown above may be used to set up meetings that take place on a regular basis.

Advertisements

Recurrence attributes may easily be added to the meeting event resource that specifies the RRULE notation for repeating events. Using the rules below, you may set up an 8-week cycle of weekly video meetings for your math lesson on Monday and Thursday.

{
  ...event,
  recurrence: ["RRULE:FREQ=WEEKLY;COUNT=8;INTERVAL=1;WKST=MO;BYDAY=MO,TH"];
}

Here are some other useful RRULE examples:

  • FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR – Occurs every week except on weekends
  • FREQ=MONTHLY;INTERVAL=2;BYDAY=TU – Occurs every Tuesday, every other month
  • INTERVAL=2;FREQ=WEEKLY – Occurs every other week
  • FREQ=WEEKLY;INTERVAL=2;BYDAY=TU,TH;BYMONTH=12 – Occurs every other week in December on Tuesday and Thursday
  • FREQ=MONTHLY;INTERVAL=2;BYDAY=1SU,-1SU – Occurs every other month on the first and last Sunday of the month

Advertisements

Leave a Comment