AutomationFlowsData & Sheets › Generate AI Math Rpg Quests From Study Logs with Google Sheets and Openrouter

Generate AI Math Rpg Quests From Study Logs with Google Sheets and Openrouter

ByTAKUTO ISHIKAWA @onepiceace on n8n.io

This template is for educators, parents, or self-learners who want to gamify their study routines. It turns boring study logs into an interactive RPG math battle using AI.

Event trigger★★★★☆ complexityAI-powered11 nodesChain LlmOpenRouter ChatOutput Parser StructuredGoogle SheetsForm Trigger
Data & Sheets Trigger: Event Nodes: 11 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #14193 — we link there as the canonical source.

This workflow follows the Chainllm → Form Trigger recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "R32vXQpEtDbfq4MC",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Generate AI math RPG quests from study logs in Google Sheets",
  "tags": [],
  "nodes": [
    {
      "id": "e5b843bf-d297-4512-bcfc-e743e9a5a255",
      "name": "Basic LLM Chain",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        656,
        0
      ],
      "parameters": {
        "text": "==User '{{$json.user_id}}' is currently at Level {{$json.level}}.\nPlease generate ONE math problem (addition, subtraction, multiplication, or division) suitable for this level.\nAlso, generate a math-themed RPG monster name and a short descriptive text of its appearance.\n* Make sure the 'answer' field contains ONLY a numeric value.",
        "batching": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "38e267c5-0306-4dab-bf1a-97aeba73bab0",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        640,
        192
      ],
      "parameters": {
        "model": "openai/gpt-4o-mini",
        "options": {
          "maxTokens": 500
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b4891b16-69db-4ac5-858a-13df0d096088",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        800,
        208
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"story\": \"A slime shaped like a number emerged from the darkness!\",\n  \"enemy\": \"Calc Slime\",\n  \"question\": \"15 + 28 = ?\",\n  \"answer\": 43\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "27f457fc-3ed0-47f4-bbb3-ed09d86f2d38",
      "name": "Add to StudyLogs",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        208,
        0
      ],
      "parameters": {
        "columns": {
          "value": {
            "time": "={{ $json.time }}",
            "user_id": "={{ $json.user_id }}"
          },
          "schema": [
            {
              "id": "user_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "user_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "time",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "time",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "StudyLogs"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "ENTER_YOUR_SPREADSHEET_ID_HERE"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "58c29a2b-cc39-4e0f-a71b-c1fc9863a54a",
      "name": "Get User Status",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        416,
        0
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "Users"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "ENTER_YOUR_SPREADSHEET_ID_HERE"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "5a172134-7667-40b6-925e-f5de893a3df0",
      "name": "Save Quest",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1008,
        0
      ],
      "parameters": {
        "columns": {
          "value": {
            "enemy": "={{ $json.output.enemy }}",
            "answer": "={{ $json.output.answer }}",
            "status": "pending",
            "user_id": "={{ $('Study Log Input Form').item.json.user_id }}",
            "question": "={{ $json.output.question }}"
          },
          "schema": [
            {
              "id": "user_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "user_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "enemy",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "enemy",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "question",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "question",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "answer",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "answer",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "id",
          "value": "Quests"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "ENTER_YOUR_SPREADSHEET_ID_HERE"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "a5a4c697-93ef-4200-8fa0-03e7f40d36b3",
      "name": "Study Log Input Form",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "options": {},
        "formTitle": "AI Math RPG - Study Input",
        "formFields": {
          "values": [
            {
              "fieldLabel": "user_id",
              "requiredField": true
            },
            {
              "fieldType": "number",
              "fieldLabel": "time",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Enter your study time (in minutes) to summon a monster!"
      },
      "typeVersion": 2.3
    },
    {
      "id": "889919ec-5a76-4dde-ae93-c2f58a36e809",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -688,
        -496
      ],
      "parameters": {
        "width": 624,
        "height": 800,
        "content": "## Generate AI math RPG quests from study logs in Google Sheets\n\n## Who it's for\nThis template is for educators, parents, or self-learners who want to gamify their study routines. It turns boring study logs into an interactive RPG math battle using AI.\n\n## How it works\nThis system consists of two workflows (Part 1: Quest Generation, Part 2: Quiz Battle).\nIn this workflow, when a user submits their study time via an n8n Form, the system logs the data into Google Sheets, calculates total EXP, and retrieves the user's current level. Then, it uses a Basic LLM Chain to generate a math question tailored to that level, along with an RPG-style monster and flavor text. The generated quest is saved back to Google Sheets with a `pending` status, ready for the user to answer.\n\n## How to set up\n1. Create a Google Sheet with three tabs: `StudyLogs`, `Users`, and `Quests`.\n2. Connect your Google Sheets credential and select your spreadsheet in all Google Sheets nodes.\n3. Connect your OpenAI or OpenRouter credential.\n4. Run the \"Study Log Input Form\" to generate your first monster!\n\n## Requirements\n- A Google account (for Google Sheets)\n- An OpenAI or OpenRouter API key\n\n## How to customize the workflow\nYou can easily change the prompt in the \"Generate RPG Quest\" node to create language quizzes, history trivia, or any other subject instead of math!"
      },
      "typeVersion": 1
    },
    {
      "id": "31359346-370b-425b-bbfd-4b28293539de",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -64,
        -96
      ],
      "parameters": {
        "color": 7,
        "width": 608,
        "height": 320,
        "content": "Receive study time and calculate user level"
      },
      "typeVersion": 1
    },
    {
      "id": "939355a3-4236-4619-8326-f5f41c999a79",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        544,
        -96
      ],
      "parameters": {
        "color": 7,
        "width": 416,
        "height": 320,
        "content": "AI generates RPG quest"
      },
      "typeVersion": 1
    },
    {
      "id": "ab08fba4-f82d-4c3c-b6f9-e208764cad4d",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        960,
        -96
      ],
      "parameters": {
        "color": 7,
        "height": 320,
        "content": "Save quest to database"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "12ded1b3-a6a6-40d8-b1a4-1f27a27aae1f",
  "connections": {
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Save Quest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get User Status": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add to StudyLogs": {
      "main": [
        [
          {
            "node": "Get User Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Study Log Input Form": {
      "main": [
        [
          {
            "node": "Add to StudyLogs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This template is for educators, parents, or self-learners who want to gamify their study routines. It turns boring study logs into an interactive RPG math battle using AI.

Source: https://n8n.io/workflows/14193/ — original creator credit. Request a take-down →

More Data & Sheets workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Data & Sheets

This workflow demonstrates a simple way to run evals on a set of test cases stored in a Google Sheet.

Google Sheets, Output Parser Structured, Chain Llm +3
Data & Sheets

This workflow demonstrates a simple way to run evals on a set of test cases stored in a Google Sheet.

OpenRouter Chat, Google Drive, Google Sheets +2
Data & Sheets

This workflow is designed to automate the generation and updating of SEO meta titles and descriptions for WooCommerce products using n8n. It leverages Google Sheets for data input, a FREE language mod

Output Parser Structured, Google Sheets, WooCommerce +2
Data & Sheets

Splitout Code. Uses lmChatOpenRouter, outputParserStructured, httpRequest, stickyNote. Event-driven trigger; 11 nodes.

OpenRouter Chat, Output Parser Structured, HTTP Request +2
Data & Sheets

This workflow automates web scraping of Amazon search result pages by retrieving raw HTML, cleaning it to retain only the relevant product elements, and then using an LLM to extract structured product

OpenRouter Chat, Output Parser Structured, HTTP Request +2