{
  "name": "telegram to sheets",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.4,
      "position": [
        -400,
        -32
      ],
      "id": "YOUR TELEGRAM ID",
      "name": "Telegram Trigger",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Extract the following fields from this message and return ONLY a valid JSON object \u2014 no explanation, no markdown, no code blocks (no ```json), no extra text before or after.\n\nRequired JSON structure:\n{\n  \"name\": \"value\",\n  \"phone\": \"value\",\n  \"roll\": \"value\",\n  \"date_of_birth\": \"value\",\n  \"skills\": \"value\"\n}\n\nRules:\n- Extract exact values from the message below.\n- If a field is missing in the message, use \"\" (empty string).\n- Do not add, rename, or remove any keys.\n- Do not wrap the JSON inside another object or array.\n\nMessage:\n{{$json.message.text}}",
        "hasOutputParser": true,
        "batching": {}
      },
      "type": "YOU WANT ADD SOME TYPES",
      "typeVersion": 1.9,
      "position": [
        -192,
        -32
      ],
      "id": "YOUR TELEGRAM ID",
      "name": "CHOOSE LLM"
    },
    {
      "parameters": {
        "operation": "SELECT operation",
        "documentId": {
          "__rl": true,
          "value": "SET THE VALUES",
          "mode": "list",
          "cachedResultName": "ADD YOUR GOOGLE SHEETS NAME",
          "cachedResultUrl": "YOUR DRIVE LINK"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "]"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "PHONE NUMBER": "={{$json.phone}}",
            "ROLL NUMBER": "=\n{{$json.roll}}",
            "SKILLS": "={{$json.skills}}",
            "NAME ": "={{$json.name}}",
            "DATE OF BIRTH": "={{$json.date_of_birth}}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "NAME ",
              "displayName": "NAME ",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "ROLL NUMBER",
              "displayName": "ROLL NUMBER",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "PHONE NUMBER",
              "displayName": "PHONE NUMBER",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "DATE OF BIRTH",
              "displayName": "DATE OF BIRTH",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "SKILLS",
              "displayName": "SKILLS",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        304,
        -32
      ],
      "id": "",
      "name": "Append row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n  \"name\": \"Barani\",\n  \"phone\": \"8489843167\",\n  \"roll\": \"22ECE001\",\n  \"date_of_birth\": \"14/02/2004\",\n  \"skills\": \"Java, Python\"\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        -48,
        240
      ],
      "id": "",
      "name": "Structured Output Parser"
    },
    {
      "parameters": {
        "jsCode": "return items.map(item => {\n  const data = item.json.output;\n  return {\n    json: {\n      name: data.name || \"\",\n      phone: data.phone || \"\",\n      roll: data.roll || \"\",\n      date_of_birth: data.date_of_birth || \"\",\n      skills: data.skills || \"\"\n    }\n  };\n});"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        112,
        -32
      ],
      "id": "",
      "name": "Code in JavaScript"
    },
    {
      "parameters": {
        "modelName": "",
        "options": {}
      },
      "type": "",
      "typeVersion": 1.1,
      "position": [
        -192,
        160
      ],
      "id": "",
      "name": "",
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "",
            "type": "",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "CHOOSE LLM",
            "type": "CHHOSE TYPE",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "YOUR ID",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodeGroups": [],
  "id": "YOUR TELEGRAM ID",
  "tags": []
}