{
  "name": "Telegram URL to Google Sheets with Validation",
  "nodes": [
    {
      "parameters": {
        "authentication": "botToken",
        "updateType": "message",
        "botToken": "7515033748:AAEGV9_vq-qrGMRmvh5ndW_qRkTyp6vf8zM"
      },
      "id": "1",
      "name": "Telegram Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1,
      "position": [
        200,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json[\"message\"][\"entities\"] ? $json[\"message\"][\"entities\"][0][\"type\"] : \"none\" }}",
              "operation": "equal",
              "value2": "url"
            }
          ]
        }
      },
      "id": "2",
      "name": "Check if URL",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        420,
        300
      ]
    },
    {
      "parameters": {
        "url": "={{ $json[\"message\"][\"text\"] }}",
        "responseFormat": "string"
      },
      "id": "3",
      "name": "Get URL Content",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        640,
        200
      ]
    },
    {
      "parameters": {
        "html": "={{ $node[\"Get URL Content\"].json[\"body\"] }}",
        "extractValues": [
          {
            "key": "title",
            "cssSelector": "title"
          }
        ]
      },
      "id": "4",
      "name": "Extract Title",
      "type": "n8n-nodes-base.htmlExtract",
      "typeVersion": 1,
      "position": [
        860,
        200
      ]
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "sheetId": "1r-3i6Mh1Yfzpef9iiOeNdLXI3MKbKdOge_Gtus9Mgx0",
        "range": "Sheet1!A:C",
        "valueInputMode": "USER_ENTERED",
        "data": [
          {
            "values": [
              "={{ $json[\"message\"][\"text\"] }}",
              "={{ $node[\"Extract Title\"].json[\"title\"] }}",
              "={{ $now }}"
            ]
          }
        ]
      },
      "id": "5",
      "name": "Add to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 3,
      "position": [
        1080,
        200
      ],
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $json[\"message\"][\"chat\"][\"id\"] }}",
        "text": "\u2705 \u062a\u0645 \u0627\u0633\u062a\u062e\u0631\u0627\u062c \u0639\u0646\u0648\u0627\u0646 \u0627\u0644\u0631\u0627\u0628\u0637 \u0648\u0625\u0636\u0627\u0641\u062a\u0647 \u0625\u0644\u0649 Google Sheets \u0628\u0646\u062c\u0627\u062d!"
      },
      "id": "6",
      "name": "Send Telegram Reply",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [
        1300,
        200
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "chatId": "={{ $json[\"message\"][\"chat\"][\"id\"] }}",
        "text": "\u274c \u0644\u0645 \u064a\u062a\u0645 \u0627\u0643\u062a\u0634\u0627\u0641 \u0631\u0627\u0628\u0637 \u0635\u0627\u0644\u062d \u0641\u064a \u0631\u0633\u0627\u0644\u062a\u0643. \u0627\u0644\u0631\u062c\u0627\u0621 \u0625\u0631\u0633\u0627\u0644 \u0631\u0627\u0628\u0637 \u0641\u0642\u0637."
      },
      "id": "7",
      "name": "Send Error Message",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1,
      "position": [
        640,
        400
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Check if URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if URL": {
      "main": [
        [
          {
            "node": "Get URL Content",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Error Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get URL Content": {
      "main": [
        [
          {
            "node": "Extract Title",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Title": {
      "main": [
        [
          {
            "node": "Add to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Add to Google Sheets": {
      "main": [
        [
          {
            "node": "Send Telegram Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false
}