Add Google Meet links to Calendar Events using the Calendar API and Google Apps Script

Step 1: Sample Google Sheet

  1. Name of the Event
  2. Start date/time of the Event
  3. End date/time of the Event
  4. Description of the Event
  5. Attendees for the Event
var start_time = "7/1/2021 12:00 AM";  var end_time = "7/20/2021 11:59 PM";  var events = cal.getEvents(new Date(start_time), new Date(end_time));

Step 2: Add the Google Calendar API

  1. To add the Google Calendar API, follow these steps:
    Open the Script Editor. To open the Script Editor, follow these steps :

    (1) Click on the Tools button next to the Add-ons button.

Step 3: Write the Automation Script

function createNewEventWithMeet() {1.  var ss = SpreadsheetApp.getActiveSpreadsheet();2.  var sheet = ss.getSheetByName("Calendar_Events");3.  var last_row = sheet.getLastRow();4.  var data = sheet.getRange("A2:E" + last_row).getValues();5. var cal = CalendarApp.getCalendarById("aryanirani123@gmail.com");
  1. Get the Active Spreadsheet
  2. Get the sheet by name
  3. Get the Last row of the sheet
  4. Get the range followed by getting the values for the range
for(var i = 0;i< data.length;i++){      1. var event_name = data[i][0];   
2. var start_time = data[i][1];
3. var end_time = data[i][2];
4. var event_description = data[i][3];
5. var attendees_event = data[i][4];
  1. Name of the Event
  2. Start time of the Event
  3. End time of the Event
  4. Description of the Event
  5. Attendees for the Event
const gmt = "+05:30";  
const calendarId = "aryanirani123@gmail.com";
const resource = {   
start: { dateTime: start_time+gmt },
end: { dateTime: end_time+gmt },
attendees: [{ email: attendees_event }],
conferenceData: {
createRequest: {
requestId: "sample123",
conferenceSolutionKey: { type: "hangoutsMeet" },
},
},
summary: event_name,
description: event_description,
};
const res = Calendar.Events.insert(resource, calendarId, { conferenceDataVersion: 1, });

Step 4: Check the Output

Summary

  1. Added all the events into the sheet [Title, Start Time, End Time, description of the event, Attendees of the event]
  2. Accessed the sheet by name
  3. Got the last row
  4. Got the range and the values
  5. Created a for loop to go through each event in the sheet
  6. Declared the GMT followed by the Calendar ID
  7. Next, we specified the start date, end date followed by the attendees for the event
  8. Next, we added the required snippet of code to create meet links
  9. In the end, we passed all the variables into the Calendar function using the insert command.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aryan Irani

Aryan Irani

Currently pursuing B Tech at MPSTME. Technical Blogger, interested in Google Workspace. Hope to remain a life long student.