{
  "id": "NR1zfq0MjPtVHGoM",
  "meta": {
    "builderVariant": "mcp",
    "aiBuilderAssisted": true
  },
  "name": "Turn any PDF into flashcards and a study plan with Gemini and Google Sheets",
  "tags": [],
  "nodes": [
    {
      "id": "583f5921-e094-49bf-9700-9441b2cb7b19",
      "name": "Study Material Form",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        48,
        48
      ],
      "parameters": {
        "options": {
          "buttonLabel": "Make my flashcards",
          "respondWithOptions": {
            "values": {
              "formSubmittedText": "Thanks! Your flashcards are being generated and the study plan will arrive by email."
            }
          }
        },
        "formTitle": "PDF to flashcards",
        "formFields": {
          "values": [
            {
              "fieldType": "email",
              "fieldLabel": "Your email",
              "requiredField": true
            },
            {
              "fieldLabel": "Subject",
              "placeholder": "e.g. Cell biology",
              "requiredField": true
            },
            {
              "fieldType": "number",
              "fieldLabel": "Cards",
              "placeholder": "20",
              "requiredField": true
            },
            {
              "fieldType": "file",
              "fieldLabel": "Material",
              "multipleFiles": false,
              "requiredField": true,
              "acceptFileTypes": ".pdf"
            }
          ]
        },
        "formDescription": "Upload lecture notes, a textbook chapter or any PDF and get flashcards, a quiz and a study plan."
      },
      "typeVersion": 2.6
    },
    {
      "id": "9747043c-5edd-4399-89ca-d9463ce28007",
      "name": "Extract Study Text",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        224,
        48
      ],
      "parameters": {
        "options": {},
        "operation": "pdf",
        "binaryPropertyName": "Material"
      },
      "typeVersion": 1.1
    },
    {
      "id": "3fdc4318-7a85-42ac-91a2-cb06329262d3",
      "name": "Has Enough Text",
      "type": "n8n-nodes-base.if",
      "position": [
        416,
        48
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 1,
            "leftValue": "",
            "caseSensitive": false,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ ($json.text || \"\").length }}",
              "rightValue": 200
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "aabb3df2-946e-4d62-92c6-0899bc76d12c",
      "name": "Generate Flashcards with Gemini",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "onError": "continueErrorOutput",
      "position": [
        928,
        32
      ],
      "parameters": {
        "text": "=You are a study coach. Turn the material below into a study pack for the subject \"{{ $('Study Material Form').item.json.Subject }}\". Produce about {{ $('Study Material Form').item.json.Cards }} flashcards that test real understanding rather than trivia, a short multiple-choice quiz with the correct answer marked, the key topics covered, and a realistic day-by-day study plan. Keep each flashcard front under 20 words.\n\nMaterial:\n{{ $json.text }}",
        "batching": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.9
    },
    {
      "id": "40b18f3b-8cd4-43a6-8dc1-86e66579532e",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        880,
        240
      ],
      "parameters": {
        "options": {
          "temperature": 0.3,
          "maxOutputTokens": 4096
        },
        "modelName": "models/gemini-3.1-flash-lite"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "2ace328a-72e7-4216-9f2f-12d0043be666",
      "name": "Study Pack Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1136,
        240
      ],
      "parameters": {
        "jsonSchemaExample": "{\"flashcards\":[{\"front\":\"What do mitochondria do?\",\"back\":\"Produce ATP for the cell\"}],\"quiz\":[{\"question\":\"Which organelle produces ATP?\",\"options\":[\"Nucleus\",\"Mitochondria\",\"Ribosome\"],\"answer\":\"Mitochondria\"}],\"key_topics\":[\"Cell organelles\"],\"study_plan\":\"Day 1: review organelles...\"}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "866e12ea-31a7-4978-afb9-e50fa225c5c8",
      "name": "Parse Study Pack",
      "type": "n8n-nodes-base.code",
      "position": [
        1504,
        16
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const src = $json.output || $json;\nconst f = $('Study Material Form').item.json;\nconst list = function (x) { return Array.isArray(x) ? x : []; };\nconst cards = list(src.flashcards).map(function (c) { return { front: c.front || '', back: c.back || '' }; });\nconst quiz = list(src.quiz).map(function (q) { return { question: q.question || '', options: list(q.options).join(' | '), answer: q.answer || '' }; });\nreturn {\n  email: f['Your email'] || '',\n  subject: f.Subject || '',\n  cardCount: cards.length,\n  quizCount: quiz.length,\n  keyTopics: list(src.key_topics).join('; '),\n  studyPlan: src.study_plan || '',\n  flashcards: cards,\n  quiz: quiz\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "f2236a46-e6fe-43d5-a99b-7432a9fcf525",
      "name": "Email Study Plan",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1792,
        16
      ],
      "parameters": {
        "sendTo": "={{ $(\"Parse Study Pack\").item.json.email }}",
        "message": "={{ \"Your study pack is ready.\\n\\nFlashcards created: \" + $(\"Parse Study Pack\").item.json.cardCount + \"\\nQuiz questions: \" + $(\"Parse Study Pack\").item.json.quizCount + \"\\n\\nKey topics:\\n\" + $(\"Parse Study Pack\").item.json.keyTopics + \"\\n\\nStudy plan:\\n\" + $(\"Parse Study Pack\").item.json.studyPlan + \"\\n\\nThe cards and quiz are in your Google Sheet, ready to import into Anki.\" }}",
        "options": {},
        "subject": "={{ \"Your study pack - \" + $(\"Parse Study Pack\").item.json.subject }}",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "c62728de-a077-4fd0-8062-c452f84d6487",
      "name": "Split Flashcards",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        2032,
        16
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "flashcards"
      },
      "typeVersion": 1
    },
    {
      "id": "263ecf7a-b18d-4abc-ba95-f628cd43d34f",
      "name": "Save Flashcards",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2240,
        16
      ],
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "Flashcards"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "Select your spreadsheet"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "bdc3cadb-e2c5-4e95-9ff8-e25783566fe9",
      "name": "Email Unreadable PDF",
      "type": "n8n-nodes-base.gmail",
      "position": [
        592,
        192
      ],
      "parameters": {
        "sendTo": "={{ $(\"Study Material Form\").item.json[\"Your email\"] }}",
        "message": "Your PDF did not contain enough selectable text. It is probably a scan - please upload a text-based PDF and try again.",
        "options": {},
        "subject": "We could not read your PDF",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "622d25dd-8e0a-454e-ab72-c19b3da1a05a",
      "name": "Split Quiz Questions",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        2000,
        304
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "quiz"
      },
      "typeVersion": 1
    },
    {
      "id": "1a2a4b08-f354-4c73-bb0a-24878938ec2d",
      "name": "Save Quiz Questions",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2240,
        304
      ],
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "Quiz"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "Select your spreadsheet"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "fbe3def4-7857-45dc-b52a-476b611f7538",
      "name": "Email Generation Failure",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1296,
        176
      ],
      "parameters": {
        "sendTo": "={{ $(\"Study Material Form\").item.json[\"Your email\"] }}",
        "message": "Something went wrong while generating your study pack. Please try again with a shorter document.",
        "options": {},
        "subject": "We could not generate your flashcards",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "be6fad06-46ad-4212-8c78-28cfbc5dc0ac",
      "name": "Overview Sticky",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -624,
        -288
      ],
      "parameters": {
        "width": 600,
        "height": 644,
        "content": "## Turn any PDF into flashcards and a study plan with Gemini and Google Sheets\n\n### How it works\nMaking flashcards is the part of studying everyone skips. Upload lecture notes, a textbook chapter or any PDF through the built-in n8n form and a Basic LLM Chain with Google Gemini turns it into flashcards that test understanding rather than trivia, a multiple-choice quiz with answers, the key topics, and a realistic day-by-day study plan. Scanned PDFs with no selectable text are rejected up front with a helpful email. The cards and quiz questions are each split into one row per item in Google Sheets - the Front/Back layout imports straight into Anki - and the study plan is emailed to you.\n\n### Setup\n1. Connect Google Gemini (PaLM) API, Google Sheets and Gmail.\n2. Point the two Sheets nodes at your spreadsheet (tabs: Flashcards, Quiz).\n3. Open the form URL and upload a text-based PDF.\n\n### Customization tips\nChange the card count, ask for cloze-deletion cards, or add a scheduled quiz email."
      },
      "typeVersion": 1
    },
    {
      "id": "80ff5649-cd28-4b39-ba80-2df26c5f0b03",
      "name": "S1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -288
      ],
      "parameters": {
        "color": 7,
        "width": 768,
        "height": 900,
        "content": "## 1. Upload & validate\nThe built-in n8n form takes the subject, card count and PDF. Scanned PDFs without selectable text are rejected with an email instead of failing silently."
      },
      "typeVersion": 1
    },
    {
      "id": "46097d05-b527-463b-adc6-e95c47adb0f6",
      "name": "S2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        800,
        -288
      ],
      "parameters": {
        "color": 7,
        "width": 628,
        "height": 900,
        "content": "## 2. Generate the pack (Basic LLM Chain)\nGemini returns flashcards, a quiz with answers, key topics and a day-by-day plan as structured JSON."
      },
      "typeVersion": 1
    },
    {
      "id": "7fdc1871-f57f-4957-9a60-63e8477d222c",
      "name": "S3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        -288
      ],
      "parameters": {
        "color": 7,
        "width": 516,
        "height": 900,
        "content": "## 3. Parse & email the plan\nFlatten the pack and email the study plan and topic list to the learner."
      },
      "typeVersion": 1
    },
    {
      "id": "d0312f9f-a198-46f7-a0c2-d48fcdd7081c",
      "name": "S4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1968,
        -288
      ],
      "parameters": {
        "color": 7,
        "width": 500,
        "height": 900,
        "content": "## 4. Fan out to Sheets\nFlashcards and quiz questions are split into one row each. The Front/Back columns import directly into Anki."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": true,
    "executionOrder": "v1"
  },
  "versionId": "0a437f5a-0c61-4a71-b19d-e641676f1bf8",
  "nodeGroups": [],
  "connections": {
    "Has Enough Text": {
      "main": [
        [
          {
            "node": "Generate Flashcards with Gemini",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Email Unreadable PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Email Study Plan": {
      "main": [
        [
          {
            "node": "Split Flashcards",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Study Pack": {
      "main": [
        [
          {
            "node": "Email Study Plan",
            "type": "main",
            "index": 0
          },
          {
            "node": "Split Quiz Questions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Flashcards": {
      "main": [
        [
          {
            "node": "Save Flashcards",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Study Pack Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Generate Flashcards with Gemini",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Extract Study Text": {
      "main": [
        [
          {
            "node": "Has Enough Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Study Material Form": {
      "main": [
        [
          {
            "node": "Extract Study Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Quiz Questions": {
      "main": [
        [
          {
            "node": "Save Quiz Questions",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Flashcards with Gemini",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Generate Flashcards with Gemini": {
      "main": [
        [
          {
            "node": "Parse Study Pack",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Email Generation Failure",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}