CalendarApp lets you create events on your Google Calendar (or any calendar you own) directly from a script. You can set the title, date, time, duration, description, location, and more.
Creating a Simple Timed Event
functioncreateFollowUpCall(){var calendar =CalendarApp.getDefaultCalendar();var start =newDate("2024-03-25T10:00:00");var end =newDate("2024-03-25T10:30:00");var event = calendar.createEvent("Follow-up Call – Mark Chen (Enterprise Plan)", start, end
);Logger.log("Event created: "+ event.getTitle()+" | ID: "+ event.getId());}
Creating an Event with a Description and Location
functioncreateOnboardingSession(){var calendar =CalendarApp.getDefaultCalendar();var start =newDate("2024-03-26T14:00:00");var end =newDate("2024-03-26T15:00:00");var event = calendar.createEvent("Onboarding Session – Sarah Johnson", start, end,{description:"Pro Plan onboarding walkthrough.\nCustomer: Sarah Johnson ([email protected])\nAccount Manager: Alex Martinez",location:"Google Meet",sendInvites:true});Logger.log("Onboarding event created: "+ event.getTitle());}
Creating an All-Day Event
functioncreateContractSignedEvent(){var calendar =CalendarApp.getDefaultCalendar();var date =newDate("2024-03-15");var event = calendar.createAllDayEvent("Contract Signed – Sarah Johnson (Pro Plan)", date,{description:"Sarah Johnson signed the Pro Plan contract. Region: North. Rep: Alex Martinez."});Logger.log("All-day event created: "+ event.getTitle());}
Auto-Creating Follow-Up Events from Sheet Data
This example reads all In Progress deals from the Sales Tracker and creates a 30-minute follow-up call event scheduled 2 days from today for each: