Skip to main content

Command Palette

Search for a command to run...

Stop Forgetting: Automate Your Study Schedule with Google Apps Script

Updated
3 min read

We’ve all been there: you spend hours learning a new concept, only to forget 70% of it three days later. Science tells us that the best way to fight this "forgetting curve" is Spaced Repetition—reviewing material at specific intervals.

But manually scheduling 5 review sessions every time you learn something new is a chore. So, I built a tool that does it for you.

In this guide, I’ll show you how to turn a simple Google Sheet into a powerful automation hub that schedules review sessions in your Google Calendar and emails you a study plan automatically.


🛠️ The Workflow

  1. Type a Topic into your Google Sheet.
  2. The script calculates intervals for 1, 3, 7, 21, and 45 days.
  3. Five Calendar events are created at 9:00 AM on those dates.
  4. You receive a summary email with your complete study plan.

🚀 Step 1: Prepare the Google Sheet

  1. Create a new Google Sheet.
  2. Label Cell A1 as Topic and Cell B1 as Status.
  3. Give your sheet a name (e.g., "My Study Tracker").

💻 Step 2: Adding the Code

  1. Go to Extensions > Apps Script.
  2. Delete any code in the editor and paste the following script:
/**
 * THE MAIN TRIGGER FUNCTION
 * This will run automatically once the "Installable Trigger" is set up.
 */
function createSpacedRepetition(e) {
  const range = e.range;
  const sheet = range.getSheet();
  const column = range.getColumn();
  const row = range.getRow();
  const topic = e.value;
  const statusCell = sheet.getRange(row, 2);

  // Only run if in Column A, Row 2+, and cell is not empty
  if (column === 1 && row > 1 && topic) {

    // Check if already processed to avoid duplicates
    if (statusCell.getValue() === "✅ Events & Email Sent!") return;

    statusCell.setValue("⏳ Scheduling...");

    try {
      // 1. Calculate Intervals and Create Calendar Events
      const intervals = [1, 3, 7, 21, 45]; 
      let scheduleDetails = [];

      intervals.forEach((days, index) => {
        const sessionDate = new Date();
        sessionDate.setDate(sessionDate.getDate() + days);
        sessionDate.setHours(9, 0, 0, 0); // Scheduled for 9 AM

        const title = `Review ${index + 1}: ${topic}`;
        const endTime = new Date(sessionDate.getTime() + (30 * 60 * 1000)); // 30 min duration

        const calendar = CalendarApp.getDefaultCalendar();
        calendar.createEvent(title, sessionDate, endTime, {
          description: "Spaced Repetition Session for " + topic
        });

        scheduleDetails.push({ step: index + 1, date: sessionDate.toDateString() });
      });

      // 2. Send the Summary Email
      sendSummaryEmail(topic, scheduleDetails);

      // 3. Update Sheet
      statusCell.setValue("✅ Events & Email Sent!");

    } catch (err) {
      statusCell.setValue("❌ Error: " + err.toString());
    }
  }
}

/**
 * Helper function to send a formatted email
 */
function sendSummaryEmail(topic, schedule) {
  const myEmail = Session.getEffectiveUser().getEmail();
  const subject = "📚 New Study Plan: " + topic;

  const htmlBody = `
    <div style="font-family: sans-serif;">
      <h3>Plan for: ${topic}</h3>
      <p>I've added 5 sessions to your calendar:</p>
      <ul>
        ${schedule.map(s => `<li><b>Session ${s.step}:</b> ${s.date}</li>`).join("")}
      </ul>
      <p>Happy learning!</p>
    </div>
  `;

  GmailApp.sendEmail(myEmail, subject, "", { htmlBody: htmlBody });
}

⚙️ Step 3: The "Secret Sauce" (Installable Triggers)

This is the most important part. A normal script isn't allowed to touch your Calendar or Email for security reasons. We have to "install" the trigger manually to give it permission.

  1. In the Apps Script sidebar, click the Alarm Clock icon (Triggers).
  2. Click + Add Trigger (bottom right).
  3. Select createSpacedRepetition as the function to run.
  4. Set the event source to From spreadsheet.
  5. Set the event type to On edit.
  6. Click Save and accept the permissions popup (click Advanced and Allow).

🎯 The Result

Now, whenever you finish a tutorial or read a great technical article, just type the name into your spreadsheet.

Within seconds, your calendar will look like a roadmap to mastery, and you'll have an email waiting for you with the details. This system ensures you're reviewing concepts right when your brain is about to forget them.