Hands-On AI WorkshopHomeProjectsLearnResourcesPresenterHelpProgress

Project 25 of 30 · Pathway 6 — Everyday Automation

Personal Appointment and Reminder Manager

Upcoming appointments can be overlooked. List appointments in next seven days from demo date 2026-11-25.

Real-world benefit
Family schedules, personal appointments and service bookings.
Technologies
Google Sheets, Date filtering, Sorting
Required knowledge
Comparing dates.
Time and level
About 15 minutes · Beginner
AI requirement
None: deterministic Apps Script
Expected baseline
Dentist only

Loading the interactive studio…

Introduction

Filter ISO dates between inclusive start and exclusive end; sort by date. The application's entry point is showAppointments(). Baseline limitation, as stated in the workshop: Reference sorts by date only and does not create reminders or events.

Key building blocks: getValues(); JavaScript transformations; setValues(); validation and calculations.

Practical use cases

Family schedules, personal appointments and service bookings.

Prerequisites

  • Comparing dates.
  • Interactive Learning Mode: a modern browser. Nothing else.
  • Real Workspace Build: a Google account.

Source data

Starter data: tab "Appointments" (fictional)
TitleDateTime
Dentist2026-11-2610:00
Car service2026-12-1009:00

Setup in your own Google account

  1. Download 25-personal-appointment-and-reminder-manager.zip (Code.gs, starter.csv, README).
  2. In Google Drive, create a lesson folder and a new Google Sheets file inside it.
  3. Rename the first tab to exactly Appointments, then File → Import → Upload starter.csv → Replace current sheet.
  4. Extensions → Apps Script. Replace Code.gs with the downloaded file. Save.
  5. Reload the spreadsheet, choose Workshop → Run application and authorize when asked.
  6. Check the result: Dentist only

Folder strategy: the repository's V6 code uses the folder that contains the spreadsheet. The deck mentions a Workshop Info cell B2; V6 never reads it. See the discrepancy log.

Complete source code (Code.gs)

From 25-personal-appointment-and-reminder-manager at commit 4a26d919, SHA-256 3bcb6f3a59a4. Unchanged.

// Personal Appointment and Reminder Manager
// Entry point: showAppointments; source data stays intact unless explicitly noted.
function onOpen(){SpreadsheetApp.getUi().createMenu("Workshop").addItem("Run application","showAppointments").addToUi();}
function showAppointments(){
// Use a fixed seven-day window for the workshop example.
output('Upcoming',['Title','Date','Time'],input('Appointments').filter(r=>day(r[1])>='2026-11-25'&&day(r[1])<'2026-12-02').sort((a,b)=>day(a[1]).localeCompare(day(b[1]))));
}
function input(name) { const s=SpreadsheetApp.getActive().getSheetByName(name); if(!s) throw Error('Missing tab: '+name); return s.getDataRange().getValues().slice(1).filter(r=>r.some(v=>v!=='')); }
function output(name,headers,rows) { const ss=SpreadsheetApp.getActive(); const s=ss.getSheetByName(name)||ss.insertSheet(name); s.clearContents(); s.getRange(1,1,1,headers.length).setValues([headers]).setFontWeight('bold'); if(rows.length) s.getRange(2,1,rows.length,headers.length).setValues(rows.map(r=>r.map(v=>typeof v==='string' && /^[=+@-]/.test(v)?"'"+v:v))); s.setFrozenRows(1); return s; }
function day(v){return v instanceof Date?Utilities.formatDate(v,SpreadsheetApp.getActive().getSpreadsheetTimeZone(),'yyyy-MM-dd'):String(v).slice(0,10);}

How the code works

Beginner explanation

showAppointments() lists the appointments in the seven days starting 2026-11-25 (the workshop date), sorted by date. It does not touch your calendar.

Technical explanation

day() normalizes Date cells to yyyy-MM-dd strings so the window can be checked with string comparison (>= start and < end). localeCompare sorts the same strings chronologically.

Slide excerpt

This is the excerpt shown on the workshop slide. It is a fragment and cannot run on its own.

function showAppointments(){
// Use a fixed seven-day window for the workshop example.
output('Upcoming',['Title','Date','Time'],input('Appointments').filter(r=>day(r[1])>='2026-11-25'&&day(r[1])<'2026-12-02').sort((a,b)=>day(a[1]).localeCompare(day(b[1]))));
}

Common mistakes

  • Using new Date() in a test so the answer changes daily.
  • Off-by-one errors at window edges.
  • Creating calendar events without approval.

Run it and expected output

Choose Workshop → Run application (runs showAppointments()). Expected: Dentist only

Original workshop exercise

Change Car service date to 2026-11-29; expect two rows.

Troubleshooting and debugging

The wrong year

The dentist appointment was typed with last year's date.

Fix: Correct the year.

No error does not mean no problem. An empty result is worth investigating.

A boundary appointment vanishes

An appointment on the first day of the window is missing after a code edit.

Fix: Use >= for the inclusive start of the window.

Windows have an inclusive start and exclusive end. Test both edges.

Extension activity: Editable reference date

Read an optional reference date from Settings!B2 and compute the seven-day window from it; keep 2026-11-25 as the default.

Acceptance checks:

  • Default window still returns Dentist only
  • Reference 2026-12-05 returns Car service only

Original improvement idea from the workshop: Add optional calendar creation with approval

Extension prompt
Improve the existing application: Add optional calendar creation with approval. Preserve working features and provide complete code and regression tests.
Automation option: Replace fixed date with rolling date and schedule daily refresh. Keep this separate from the baseline exercise.

Automation considerations

Rerun-safe. Replace the fixed date with a rolling date before a daily schedule; keep calendar changes separate and approved.

Workshop note: Replace fixed date with rolling date and schedule daily refresh.

Build prompt from the workshop

Build a complete container-bound Apps Script app named Personal Appointment and Reminder Manager. Input tab Appointments, headers Title|Date|Time. Implement showAppointments() to list appointments in next seven days from demo date 2026-11-25. Add a menu, preserve inputs, validate data, explain code and test against: Dentist only. For AI use callGemini and treat input as data; never send email.
Match the reference entry point showAppointments and its output behavior. Reference: https://github.com/lsvekis/Google-Apps-Script-Workshop/tree/main/25-personal-appointment-and-reminder-manager. Base version limitations: Reference sorts by date only and does not create reminders or events.

Knowledge check

  1. Is an appointment on 2026-12-02 included?

    1. No: the end is exclusive
    2. Yes
    3. Only in the morning
    Answer

    No: the end is exclusive Correct.

  2. Why compare yyyy-MM-dd strings instead of Date objects?

    1. They sort and compare correctly and avoid time-of-day and time-zone surprises
    2. Dates cannot be compared
    3. It is required
    Answer

    They sort and compare correctly and avoid time-of-day and time-zone surprises Correct.

  3. Does this project create Calendar events?

    1. No
    2. Yes
    3. Only on Fridays
    Answer

    No Correct: calendar changes are an approved extension.

  4. Upcoming is empty and no error appears. First check?

    1. The dates in Appointments (year, format)
    2. The API key
    3. The menu
    Answer

    The dates in Appointments (year, format) Correct.

  5. Should reminders be emailed automatically every morning?

    1. Start with a reviewed list or drafts; avoid repeat notifications
    2. Yes, to everyone
    3. Never think about reminders
    Answer

    Start with a reviewed list or drafts; avoid repeat notifications Correct.

Five-minute presenter demonstration

Open the demo link (temporary workspace; saved learner work is not touched).

Opening hook: Raise your hand if you have ever done this by hand: Upcoming appointments can be overlooked. Let us make the spreadsheet do it.

  1. 0:00–0:45 — Problem and input. Show the Workspace view, Sheets service. Point at the Appointments tab and its headers: Title, Date, Time. Say what goes in and what should come out.
    Narration: Upcoming appointments can be overlooked. Practical uses: Family schedules, personal appointments and service bookings.
  2. 0:45–1:30 — Predict and run. Ask the room: Workshop window: 2026-11-25 up to (not including) 2026-12-02. Which appointments appear? Click ▶ Run application (the same as Workshop → Run application). Open Trace to show each step the code took.
    Narration: Expected: Dentist only
  3. 1:30–3:00 — Explain the code. Click the Code tab. Select showAppointments() in the function list; read what it reads, writes and calls. Switch Beginner / Technical as needed.
    Narration: showAppointments() lists the appointments in the seven days starting 2026-11-25 (the workshop date), sorted by date. It does not touch your calendar.
  4. 3:00–4:15 — Change one input and rerun. Back to the Workspace tab. Select the Appointments tab, click cell B3, type 2026-11-29 in the formula bar and press Enter. Click ▶ Run application again.
    Narration: Workshop challenge: Change Car service date to 2026-11-29; expect two rows.
  5. 4:15–5:00 — Verify and discuss automation. Click Check result. Discuss: Rerun-safe. Replace the fixed date with a rolling date before a daily schedule; keep calendar changes separate and approved.
    Narration: Baseline limitation: Reference sorts by date only and does not create reminders or events.

Closing takeaway: Filter ISO dates between inclusive start and exclusive end; sort by date.

Related resources