i used AI but it's something like this:
add the Calendar service
function addRoomWithoutNotification() {
var calendarId = 'me@google-workspace.com';
var locationsToMatch = ['room.com', 'same-room.com', 'same.com/room'];
var roomEmail = 'c_1234567890@resource.calendar.google.com'; // Actual room email
var now = new Date();
var future = new Date(now.getTime() + 14 * 24 * 60 * 60 * 1000);
var events = Calendar.Events.list(calendarId, {
timeMin: now.toISOString(),
timeMax: future.toISOString(),
singleEvents: true
});
if (!events.items) return;
events.items.forEach(function(event) {
if (locationsToMatch.some(location => event.location?.includes(location))) {
var attendees = event.attendees || [];
var hasRoom = attendees.some(function(a) {
return (a.email === roomEmail);
});
if (!hasRoom) {
attendees.push({email: roomEmail});
Calendar.Events.patch(
{attendees: attendees},
calendarId,
event.id,
{sendUpdates: 'none'}
);
}
}
});
}