{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "1e8f49ce-b57f-4919-b04b-58254fc28938",
      "name": "AI Agent1",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -464,
        1840
      ],
      "parameters": {
        "text": "={{ $json.message.text }}",
        "options": {
          "systemMessage": "# Role\nYou are a helpful translation agent that will help users to create flashcard for language learning.\n\n# Context\nYou will receive a word or sentence in English. Generate a translation (in English) with simple 2 sentences to illustrate the sense of the word. \n\n# Notes\n- it's ok to output multiple translations in new lines\n- multiple example sentences should be in new line\n- use <br> tag for the new lines\n- Generate the output in JSON format following the example below:\n{\"word\": \"Example word\",\n\"translation\": \"1. Meaning1<br>2. Meaning2\", \"sentences\": \"Sentences go here\"}\n\n- Be very diligent in thinking about the task being asked from you.\n- Generate concise sentences as they need to fit in flash cards.\n"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "notesInFlow": true,
      "typeVersion": 1.7
    },
    {
      "id": "13255d55-2be5-4b12-9779-c9c717981b70",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -464,
        2016
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "01e26beb-bb63-4249-8b05-2e8ea076cdc7",
      "name": "Structured Output Parser1",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -272,
        2016
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"word\": \"\",\n  \"translation\": \"\",\n  \"sentences\": \"\"\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "81da4387-1414-4fc8-9dd0-7f0ec3dc1541",
      "name": "Append row in sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        0,
        1840
      ],
      "parameters": {
        "columns": {
          "value": {
            "answer": "={{ $json.output.translation }}<br/><br/>{{ $json.output.sentences }}",
            "question": "={{ $json.output.word }}"
          },
          "schema": [
            {
              "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": "tags",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "tags",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bYTzZrU0Zb_lO4idwN-_yoyD7ig7Iug9Fv-BHk4cAV0/edit#gid=0",
          "cachedResultName": "TomekPersonalDeck"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1bYTzZrU0Zb_lO4idwN-_yoyD7ig7Iug9Fv-BHk4cAV0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bYTzZrU0Zb_lO4idwN-_yoyD7ig7Iug9Fv-BHk4cAV0/edit?usp=drivesdk",
          "cachedResultName": "TomekAnkiPersonalDeck"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "a423d57b-3885-487f-93b0-97872335aa8b",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        -816,
        1840
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {
          "download": true
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "d007c592-220e-4f89-b1c3-1c9cb91676ba",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        256,
        1840
      ],
      "parameters": {
        "text": "={{ $json.question }}\n\n{{ $json.answer }}",
        "chatId": "={{ $json.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "1da56d7e-b386-42cd-862d-718c046f6da9",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -944,
        1760
      ],
      "parameters": {
        "width": 352,
        "height": 432,
        "content": "### Input flashcard 'front'\nTelegram or manual"
      },
      "typeVersion": 1
    },
    {
      "id": "e15c418d-d6d4-4074-8a72-fc7f6fa242f5",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        1760
      ],
      "parameters": {
        "width": 448,
        "height": 432,
        "content": "### Generate flashcard 'back'"
      },
      "typeVersion": 1
    },
    {
      "id": "fc102059-6911-44ba-a5c9-1fbdd0f77018",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -896,
        2032
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "831acc6b-6816-4559-8ead-3a3b3ed7fb8a",
      "name": "Flashcard 'front'",
      "type": "n8n-nodes-base.set",
      "position": [
        -736,
        2032
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "4bd2a197-eff6-4ece-adbd-4997b37d190e",
              "name": "=message.text",
              "type": "string",
              "value": "comprehensive"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "06ea1fee-247f-471d-b33b-a76be9eba5db",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        1760
      ],
      "parameters": {
        "height": 432,
        "content": "### Store flashcard in Sheet\n"
      },
      "typeVersion": 1
    },
    {
      "id": "896e95af-d017-4c1e-bccc-5f991bb46d54",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        1760
      ],
      "parameters": {
        "height": 432,
        "content": "### Confirm"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Flashcard 'front'": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser1": {
      "ai_outputParser": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Flashcard 'front'",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}