appscript.dev
Automation Intermediate Docs Drive

Generate personalized study guides from notes

Reformat raw notes into structured study guides — for Northwind's internal training programme.

Published Feb 8, 2026

Northwind runs an internal training programme, and trainers keep their material as a single Doc of rough notes — one topic per H2 heading, with a few paragraphs underneath each. That is fine for the trainer, but it is not a study guide. New starters need something they can revise from: a short summary per topic and a couple of questions to test themselves against.

This script reads a notes Doc, splits it on the H2 headings, and produces a fresh study guide. For each topic it writes a one-line summary section drawn from the first few paragraphs, then two review questions built from the topic title. It is a deliberately simple transformation — no AI, just structure — which makes it fast, free, and predictable.

What you’ll need

  • A source Google Doc of notes, with each topic as a HEADING2 paragraph and its content as plain paragraphs underneath.
  • Nothing else — the script creates the study guide Doc itself.

The script

// How many of each topic's opening paragraphs to fold into the summary.
const SUMMARY_PARAGRAPHS = 3;

/**
 * Reads a notes Doc, splits it on H2 headings into topic sections,
 * and writes a structured study guide Doc. Returns the guide's URL.
 */
function buildStudyGuide(notesDocId) {
  const source = DocumentApp.openById(notesDocId).getBody();

  // 1. Walk every element in the source, grouping paragraphs under
  //    the most recent H2 heading into a "section".
  const sections = [];
  let current = null;

  for (let i = 0; i < source.getNumChildren(); i++) {
    const c = source.getChild(i);
    if (c.getType() !== DocumentApp.ElementType.PARAGRAPH) continue;

    const p = c.asParagraph();
    if (p.getHeading() === DocumentApp.ParagraphHeading.HEADING2) {
      // A new H2 starts a new topic section.
      current = { title: p.getText(), body: [] };
      sections.push(current);
    } else if (current) {
      // Plain text belongs to the topic we are currently inside.
      current.body.push(p.getText());
    }
  }

  // 2. Bail out if the notes had no H2 headings to work with.
  if (sections.length === 0) {
    throw new Error('No H2 headings found — nothing to turn into a guide.');
  }

  // 3. Create the guide Doc, dated so each run is distinct.
  const guide = DocumentApp.create(
    `Study guide — ${new Date().toISOString().slice(0, 10)}`);
  const out = guide.getBody();

  // 4. For each topic, write a summary section and two review questions.
  for (const s of sections) {
    out.appendParagraph(s.title)
      .setHeading(DocumentApp.ParagraphHeading.HEADING1);

    out.appendParagraph('Summary')
      .setHeading(DocumentApp.ParagraphHeading.HEADING3);
    out.appendParagraph(s.body.slice(0, SUMMARY_PARAGRAPHS).join(' '));

    out.appendParagraph('Review questions')
      .setHeading(DocumentApp.ParagraphHeading.HEADING3);
    out.appendListItem(`In your own words, explain "${s.title}".`);
    out.appendListItem(
      `What's one practical use of "${s.title}" at Northwind?`);
  }

  // 5. Save and return the URL.
  guide.saveAndClose();
  Logger.log(`Built study guide with ${sections.length} topic(s).`);
  return guide.getUrl();
}

How it works

  1. buildStudyGuide opens the notes Doc and walks its body element by element. Every time it hits a HEADING2 paragraph it starts a new section; every plain paragraph after that is appended to the current section’s body.
  2. If the loop finds no H2 headings, there is nothing to structure, so it throws a clear error rather than producing an empty guide.
  3. It creates a new Doc named with today’s date, so successive runs do not collide.
  4. For each section it writes a HEADING1 topic title, a “Summary” subsection that joins the first SUMMARY_PARAGRAPHS paragraphs into one line, and a “Review questions” subsection with two questions generated from the title.
  5. It saves the Doc and returns its URL.

Example run

Say the notes Doc contains:

Rate limiting (H2) Rate limiting caps how many requests a client can make in a window. Northwind uses a token bucket of 100 requests per minute. Exceeding it returns a 429 response.

Idempotency keys (H2) An idempotency key lets a client retry a request safely…

The generated study guide holds, per topic:

SectionContent
Rate limiting (H1)
Summary (H3)Rate limiting caps how many requests a client can make in a window. Northwind uses a token bucket of 100 requests per minute. Exceeding it returns a 429 response.
Review questions (H3)• In your own words, explain “Rate limiting”.
• What’s one practical use of “Rate limiting” at Northwind?

Each H2 in the source becomes one of these blocks, so a notes Doc with six topics yields a six-topic study guide.

Run it

This is an on-demand job — run it whenever the notes change:

  1. In the Apps Script editor, run a function that calls buildStudyGuide with the notes Doc ID, for example buildStudyGuide('1abcNotesDocId').
  2. Approve the authorisation prompt the first time.
  3. Open the URL it logs to read the finished guide.

Watch out for

  • Only HEADING2 paragraphs start a section. Notes that use Heading 1 or bold text for topics will be read as one long body — set the headings properly first.
  • The summary is the first three paragraphs joined together, not a true abstract. If trainers put a one-line intro under each H2, that intro becomes the summary; if they dive straight into detail, so does the guide.
  • Tables, images, and list items in the source are skipped — the loop only collects PARAGRAPH elements. Notes built mostly from bullet lists will come through nearly empty.
  • The guide Doc is named by date only. Run it twice in one day and you get two Docs with the same name; rename one or include the source topic in the title.
  • This is a structural reformat, not a rewrite. For genuinely condensed summaries or harder questions, swap the summary line for a call to a language model — but then you take on an API key and its secure storage.

Related