🚀 Apps Script + Gemini Mastery — Issue #20
AI Calendar Assistant (Google Calendar + Apps Script)
https://github.com/lsvekis/Apps-Script-Code-Snippets
Automatically schedule meetings, suggest times, and generate event details using Google Apps Script + Gemini.
⭐ What You Will Build
In this issue, you’ll build an AI Calendar Assistant that can:
📅 Create events from plain English
🧠 Generate titles + descriptions
⏰ Suggest meeting times
👥 Add attendees
📍 Auto-fill event details
🧠 Why This Project Matters
Scheduling meetings is one of the most repetitive tasks.
Instead of:
• checking availability
• writing descriptions
• adding details manually
You can just say:
“Schedule a 30-minute meeting with the marketing team next Tuesday”
And let AI handle the rest.
🧩 Architecture
User prompt
↓
Apps Script parses request
↓
Gemini structures event
↓
Apps Script creates Calendar event
🧱 Step 1 — Menu
Code.gs
function onOpen() {SpreadsheetApp.getUi()
.createMenu("AI Tools")
.addItem("AI Calendar Assistant", "showCalendarSidebar")
.addToUi()}function showCalendarSidebar(){SpreadsheetApp.getUi().showSidebar(
HtmlService.createHtmlOutputFromFile("Sidebar")
.setTitle("AI Calendar Assistant")
)}
🧱 Step 2 — Sidebar UI
Sidebar.html
<div style="font-family:Arial;padding:14px;"><h2>AI Calendar Assistant</h2><label><b>Describe the meeting</b></label><textarea id="prompt"
style="width:100%;height:80px;">
Example: Schedule a 30-minute meeting with the marketing team next Tuesday
</textarea><button onclick="create()">Create Event</button><pre id="output"
style="white-space:pre-wrap;margin-top:12px;"></pre><script>function create(){document.getElementById("output").textContent="Creating event..."google.script.run
.withSuccessHandler(res=>{
document.getElementById("output").textContent=res
})
.createEventFromPrompt(
document.getElementById("prompt").value
)}</script></div>
🧱 Step 3 — Generate Event Details with Gemini
EventGenerator.gs
function createEventFromPrompt(userPrompt){if(!userPrompt) return "Enter a request."const prompt = `
You are a calendar assistant.Convert the request into structured event data.Return JSON:{
"title": "event title",
"description": "event description",
"start": "YYYY-MM-DDTHH:MM",
"end": "YYYY-MM-DDTHH:MM"
}Request:
${userPrompt}
`let resulttry{
result = callGemini(prompt,"")
}catch(e){
return "Gemini error: "+e
}result = result.replace(/```json/g,"").replace(/```/g,"")let eventtry{
event = JSON.parse(result)
}catch(e){
return "Error parsing event."
}return createCalendarEvent_(event)}
🧱 Step 4 — Create Calendar Event
CalendarCreator.gs
function createCalendarEvent_(event){const calendar = CalendarApp.getDefaultCalendar()const start = new Date(event.start)
const end = new Date(event.end)calendar.createEvent(
event.title,
start,
end,
{description: event.description}
)return "Event created in Google Calendar."}
🧱 Step 5 — Gemini Helper
Reuse:
const GEMINI_API_KEY = "YOUR_API_KEY"
const GEMINI_MODEL = "gemini-2.5-flash"
🧪 Example Prompts
Users can say:
Schedule a 30-minute meeting with the marketing team next Tuesday at 2pm
Create a 1-hour project planning session tomorrow morning
Set up a weekly check-in every Monday at 10am
Schedule a call with a client next Friday afternoon
🔥 Advanced Exercises
Readers can extend this by adding:
✅ attendee email detection
✅ availability checking
✅ recurring events
✅ meeting links (Google Meet)
✅ timezone handling