{
  "id": "1Y2tozu5S9ffW8mT",
  "name": "Enrich German vocabulary in Google Sheets with OpenThesaurus and AI",
  "tags": [],
  "nodes": [
    {
      "id": "fb634a3d-0a55-4f0f-82a1-7fc36e470c0d",
      "name": "OpenThesaurus",
      "type": "n8n-nodes-base.openThesaurus",
      "position": [
        -208,
        208
      ],
      "parameters": {
        "text": "={{ $json.vocabulary }}",
        "options": {}
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "4a8d1cfc-7c9f-4978-a776-909e1ea0ec53",
      "name": "Google Sheets Trigger",
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "position": [
        -432,
        208
      ],
      "parameters": {
        "event": "rowAdded",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1218836304,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fZf14pfCSRZV4wQKt0DAvixcDdqLHSonK2BjE8SCNCA/edit#gid=1218836304",
          "cachedResultName": "doitu"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fZf14pfCSRZV4wQKt0DAvixcDdqLHSonK2BjE8SCNCA",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fZf14pfCSRZV4wQKt0DAvixcDdqLHSonK2BjE8SCNCA/edit?usp=drivesdk",
          "cachedResultName": "n8n_\u9023\u643a\u30b7\u30fc\u30c8"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "85bf6ce2-3eec-43bc-b41f-a1aee9c96681",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        240,
        208
      ],
      "parameters": {
        "text": "={{ $('Google Sheets Trigger').item.json.vocabulary }}",
        "options": {
          "systemMessage": "=\u5143\u306e\u5358\u8a9e\u306f\u300c{{ $('OpenThesaurus').item.json.terms[0].term }}\u300d\u3067\u3059\u3002\n\u3053\u306e\u5358\u8a9e\u306e\u985e\u7fa9\u8a9e\u306f\u300c{{ $('OpenThesaurus').item.json.terms[1].term }}\u300d\u3067\u3059\u3002\n\n\u3053\u306e\u985e\u7fa9\u8a9e\u3092\u4f7f\u7528\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u60c5\u5831\u3092\u53b3\u5bc6\u306aJSON\u5f62\u5f0f\u3067\u751f\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u65e5\u672c\u8a9e\u8a33\u3084\u4f59\u8a08\u306a\u89e3\u8aac\u306fJSON\u306e\u5916\u306b\u542b\u3081\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002\n\n{\n  \"natural_sentence\": \"\u3053\u3053\u306b\u81ea\u7136\u306a\u30c9\u30a4\u30c4\u8a9e\u306e\u4f8b\u6587\",\n  \"part_of_speech\": \"\u3053\u3053\u306b\u5358\u8a9e\u306e\u54c1\u8a5e (Noun, Verb, Adjective\u306a\u3069)\",\n  \"translation_ja\": \"\u3053\u3053\u306b\u4f8b\u6587\u306e\u65e5\u672c\u8a9e\u8a33\",\n  \"level\": \"\u3053\u3053\u306b\u4f8b\u6587\u306e\u96e3\u6613\u5ea6\u3092\u30e8\u30fc\u30ed\u30c3\u30d1\u8a00\u8a9e\u5171\u901a\u53c2\u7167\u67a0(A1, A2, B1, B2, C1, C2)\u3067\u5224\u5b9a\u3057\u305f\u3082\u306e\"\n}"
        },
        "promptType": "define"
      },
      "typeVersion": 3
    },
    {
      "id": "3b4431fa-623b-4239-ad27-0272dbe6d240",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        320,
        432
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "da8c668b-a9ea-44fb-a83c-e3e3ef772e60",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -304,
        384
      ],
      "parameters": {
        "width": 288,
        "height": 144,
        "content": "## OpenThesaurus\nLooks up the German word received in vocabulary using the OpenThesaurus API. It returns a terms array containing the headword and available synonyms."
      },
      "typeVersion": 1
    },
    {
      "id": "c5ec4e3f-6969-47f5-8d15-02a790365dbf",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -64,
        -32
      ],
      "parameters": {
        "width": 272,
        "height": 208,
        "content": "## If\nChecks whether the OpenThesaurus response contains any entries. If entries exist, it routes to the AI branch; if not, it routes to the fallback that writes a \u201cnot found\u201d message to the sheet."
      },
      "typeVersion": 1
    },
    {
      "id": "9606d512-3dcf-4488-98ba-52eff095b0a0",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        -32
      ],
      "parameters": {
        "width": 304,
        "height": 208,
        "content": "## AI Agent\nUses the headword and a synonym from the OpenThesaurus result to generate a strict JSON object with: natural_sentence, part_of_speech, translation_ja, and level. The prompt instructs the model to output JSON only."
      },
      "typeVersion": 1
    },
    {
      "id": "de309d4b-fa4c-4569-9184-72def71db127",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        128
      ],
      "parameters": {
        "color": 5,
        "width": 384,
        "height": 240,
        "content": "## Template Overview \nThis workflow turns a newly added German word in a Google Sheet into useful learning material\u2014automatically. When a new row appears (column vocabulary), it queries OpenThesaurus for synonyms, then asks an AI Agent to produce a structured JSON with a natural example sentence, part of speech, Japanese translation, and CEFR-level estimate. The results are written back to the same row, so your sheet stays the single source of truth."
      },
      "typeVersion": 1
    },
    {
      "id": "2fae4ac4-4fc0-41e0-ab16-f7f34841a697",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        16,
        208
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "c70a4435-26dc-41b9-bd10-b1b7ea38f6cd",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $('OpenThesaurus').item.json.terms.length }}",
              "rightValue": 0
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "4bb21d08-e7b0-42cc-bb1d-d9e72d5d833f",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        592,
        208
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d4ffaeeb-a575-4d94-bf2b-41c6017b5f58",
              "name": "vocabulary",
              "type": "string",
              "value": "={{ $('Google Sheets Trigger').item.json.vocabulary }}"
            },
            {
              "id": "a20c646d-0fe7-4f01-b9db-b811457ffaa6",
              "name": "natural_sentence",
              "type": "string",
              "value": "={{ JSON.parse($('AI Agent').item.json.output).natural_sentence }}"
            },
            {
              "id": "2007f7fd-6fee-41e0-9f43-49540dac0fb1",
              "name": "part_of_speech",
              "type": "string",
              "value": "={{ JSON.parse($('AI Agent').item.json.output).part_of_speech }}"
            },
            {
              "id": "8c02db83-78f0-4aa1-92bb-e0c2c6a9bd2b",
              "name": "translation_ja",
              "type": "string",
              "value": "={{ JSON.parse($('AI Agent').item.json.output).translation_ja }}"
            },
            {
              "id": "a1b3f865-3fe9-413b-92a4-d747b516681e",
              "name": "level",
              "type": "string",
              "value": "={{ JSON.parse($('AI Agent').item.json.output).level }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "ffb40b71-63ca-42a0-9f13-4e693ac37048",
      "name": "Write AI Results to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        816,
        208
      ],
      "parameters": {
        "columns": {
          "value": {
            "level": "={{ $json.level }}",
            "vocabulary": "={{ $json.vocabulary }}",
            "part_of_speech": "={{ $json.part_of_speech }}",
            "translation_ja": "={{ $json.translation_ja }}",
            "Similar Examples sentence": "={{ $json.natural_sentence }}"
          },
          "schema": [
            {
              "id": "vocabulary",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "vocabulary",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Similar Examples sentence",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Similar Examples sentence",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "part_of_speech",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "part_of_speech",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "translation_ja",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "translation_ja",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "level",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "level",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "vocabulary"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1218836304,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fZf14pfCSRZV4wQKt0DAvixcDdqLHSonK2BjE8SCNCA/edit#gid=1218836304",
          "cachedResultName": "doitu"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fZf14pfCSRZV4wQKt0DAvixcDdqLHSonK2BjE8SCNCA",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fZf14pfCSRZV4wQKt0DAvixcDdqLHSonK2BjE8SCNCA/edit?usp=drivesdk",
          "cachedResultName": "n8n_\u9023\u643a\u30b7\u30fc\u30c8"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "356267e7-cd79-472b-aa9b-5cef85e7772a",
      "name": "Write 'Not Found' to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        304,
        592
      ],
      "parameters": {
        "columns": {
          "value": {
            "vocabulary": "={{ $('Google Sheets Trigger').item.json.vocabulary }}",
            "Similar Examples sentence": "\u985e\u7fa9\u8a9e\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002"
          },
          "schema": [
            {
              "id": "vocabulary",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "vocabulary",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Similar Examples sentence",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Similar Examples sentence",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "part_of_speech",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "part_of_speech",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "translation_ja",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "translation_ja",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "level",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "level",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "vocabulary"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 1218836304,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fZf14pfCSRZV4wQKt0DAvixcDdqLHSonK2BjE8SCNCA/edit#gid=1218836304",
          "cachedResultName": "doitu"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1fZf14pfCSRZV4wQKt0DAvixcDdqLHSonK2BjE8SCNCA",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1fZf14pfCSRZV4wQKt0DAvixcDdqLHSonK2BjE8SCNCA/edit?usp=drivesdk",
          "cachedResultName": "n8n_\u9023\u643a\u30b7\u30fc\u30c8"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "49e81c46-d38a-431b-b966-50afefb78dfd",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        496,
        384
      ],
      "parameters": {
        "width": 304,
        "content": "## Edit Fields\nParses the AI Agent\u2019s JSON output and maps each field to well-named properties that match your Google Sheet columns, preparing a clean record for update."
      },
      "typeVersion": 1
    },
    {
      "id": "0aa802d1-6ea5-4347-a039-c576b6a5b826",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        768
      ],
      "parameters": {
        "width": 320,
        "content": "## Write 'Not Found' to Sheet\nWhen no synonyms are returned, this node updates the same row with a fixed notice like \u201cNo synonyms were found.\u201d in the example-sentence column."
      },
      "typeVersion": 1
    },
    {
      "id": "c2a24d1e-b4f5-4fd6-bac2-02a650ed4755",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -512,
        -32
      ],
      "parameters": {
        "width": 304,
        "height": 208,
        "content": "## Google Sheets Trigger\nWatches the specified sheet/tab and fires whenever a new row is appended. It forwards the row data\u2014especially the vocabulary column value\u2014as the payload for downstream nodes."
      },
      "typeVersion": 1
    },
    {
      "id": "dec2df56-e87a-4041-96bf-2878541798e7",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        736,
        -32
      ],
      "parameters": {
        "width": 320,
        "height": 208,
        "content": "## Write AI Results to Sheet\nUpdates the newly added row by matching on the vocabulary column. It writes the example sentence, part of speech, Japanese translation, and CEFR level into their respective columns."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1bc1423f-e5a8-40b2-a790-4a47771ce9e7",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Write 'Not Found' to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Write AI Results to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenThesaurus": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets Trigger": {
      "main": [
        [
          {
            "node": "OpenThesaurus",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}