{
  "id": "qI138Ghy6iEI1N6z",
  "name": "My workflow 4",
  "tags": [],
  "nodes": [
    {
      "id": "7fb97ccd-9572-4e0f-8504-907f6b3e7032",
      "name": "Main Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        740,
        -20
      ],
      "parameters": {
        "width": 520,
        "height": 540,
        "content": "# \ud83d\udcf1 Telegram Productivity Assistant\n\nThis workflow automatically processes different types of content sent via Telegram:\n- \ud83d\udcf8 **Images**: Uploaded to Notion with captions\n- \ud83d\udcdd **Text**: Added as headings in Notion\n- \ud83d\udcc1 **Files**: Stored in Google Drive with tracking"
      },
      "typeVersion": 1
    },
    {
      "id": "22ae4187-082c-4bc4-910b-f1f4fa4fc382",
      "name": "\ud83d\udcf1 Telegram Message Trigger",
      "type": "n8n-nodes-base.telegramTrigger",
      "position": [
        840,
        240
      ],
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "5baab503-9bdf-40b1-b9c1-c4af7fc41f3a",
      "name": "\ud83d\udd00 Content Type Router",
      "type": "n8n-nodes-base.switch",
      "position": [
        1080,
        240
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Image",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "d7a05336-69bc-44c2-8b65-d5dfe4392aec",
                    "operator": {
                      "type": "array",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.photo }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "=Text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "ad5f60f6-76a9-44b7-a02d-d5899894fb89",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "File",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "eeb67e61-4a67-4abe-8a5e-841d8e82969d",
                    "operator": {
                      "type": "object",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json.message.document }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "52202a7a-8425-4c78-9bc3-5a7b6d469f2e",
      "name": "Image Path Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1485,
        -200
      ],
      "parameters": {
        "color": 4,
        "width": 870,
        "height": 400,
        "content": "## \ud83d\udcf8 IMAGE PROCESSING PATH\nHandles photos sent via Telegram:\n1. Downloads image from Telegram\n2. Converts to base64\n3. Uploads to ImgBB for hosting\n4. Adds to Notion with caption"
      },
      "typeVersion": 1
    },
    {
      "id": "6a457799-2c91-4315-926a-e7ec700f9058",
      "name": "\ud83d\udce5 Download Telegram Image",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1900,
        -160
      ],
      "parameters": {
        "fileId": "={{ $json.message.photo[2].file_id }}",
        "resource": "file"
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "deb12631-3d35-43d9-aea7-75175346a4aa",
      "name": "\ud83d\udd04 Convert to Base64",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        2160,
        -160
      ],
      "parameters": {
        "options": {},
        "operation": "binaryToPropery"
      },
      "typeVersion": 1
    },
    {
      "id": "bd89c3f3-1dd9-474d-a759-422e0fda3193",
      "name": "\ud83c\udf10 Upload to ImgBB",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1900,
        40
      ],
      "parameters": {
        "url": "https://api.imgbb.com/1/upload",
        "method": "POST",
        "options": {
          "redirect": {
            "redirect": {}
          }
        },
        "sendBody": true,
        "sendQuery": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {
              "name": "image",
              "value": "={{ $json.data }}"
            }
          ]
        },
        "queryParameters": {
          "parameters": [
            {
              "name": "expiration",
              "value": "600"
            },
            {
              "name": "key",
              "value": "<api_key>"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2921fbd4-b279-4f98-8e83-2f3969d33a26",
      "name": "\ud83d\udcdd Add Image to Notion",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2160,
        40
      ],
      "parameters": {
        "url": "https://api.notion.com/v1/blocks/1fdb06aa7d2e80b384a6eb99788f67fb/children",
        "method": "PATCH",
        "options": {},
        "jsonBody": "={\n  \"children\": [\n    {\n      \"object\": \"block\",\n      \"type\": \"toggle\",\n      \"toggle\": {\n        \"rich_text\": [\n          {\n            \"type\": \"text\",\n            \"text\": {\n              \"content\": \"{{ $('\ud83d\udd00 Content Type Router').item.json.message.caption }} - {{ $('\ud83d\udcf1 Telegram Message Trigger').item.json.message.from.first_name }} {{ $('\ud83d\udcf1 Telegram Message Trigger').item.json.message.from.last_name }}\"\n            }\n          }\n        ],\n        \"children\": [\n          {\n            \"object\": \"block\",\n            \"type\": \"image\",\n            \"image\": {\n              \"type\": \"external\",\n              \"external\": {\n                \"url\": \"{{ $json.data.url }}\"\n              }\n            }\n          }\n        ]\n      }\n    }\n  ]\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Notion-Version",
              "value": "2022-06-28"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "04f89ce6-488e-451e-8301-d2a251102a64",
      "name": "Text Path Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1820,
        240
      ],
      "parameters": {
        "color": 5,
        "width": 350,
        "height": 100,
        "content": "## \ud83d\udcdd TEXT PROCESSING PATH\nHandles text messages sent via Telegram:\n- Adds text as heading in Notion page"
      },
      "typeVersion": 1
    },
    {
      "id": "c3387bd6-7b83-4a5b-8974-9478d95d7081",
      "name": "\ud83d\udcdd Add Text to Notion",
      "type": "n8n-nodes-base.notion",
      "position": [
        2200,
        240
      ],
      "parameters": {
        "blockId": {
          "__rl": true,
          "mode": "id",
          "value": "1fdb06aa7d2e80b384a6eb99788f67fb"
        },
        "blockUi": {
          "blockValues": [
            {
              "type": "heading_3",
              "textContent": "={{ $json.message.text }}"
            }
          ]
        },
        "resource": "block"
      },
      "credentials": {
        "notionApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "eea10444-64d2-4612-9900-5a8523e5f423",
      "name": "File Path Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1280,
        380
      ],
      "parameters": {
        "color": 6,
        "width": 770,
        "height": 500,
        "content": "## \ud83d\udcc1 FILE PROCESSING PATH\nHandles document files sent via Telegram:\n1. Downloads file from Telegram\n2. Uploads to Google Drive\n3. Records file details in Google Sheets\n4. Tracks: name, uploader, size, type, creation date"
      },
      "typeVersion": 1
    },
    {
      "id": "dead3577-529b-4a9c-9ab5-12e6ba6438fe",
      "name": "\ud83d\udce5 Download Telegram File",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1640,
        500
      ],
      "parameters": {
        "fileId": "={{ $json.message.document.file_id }}",
        "resource": "file"
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a3e77a99-a848-478c-a488-7245d3231a40",
      "name": "\u2601\ufe0f Upload to Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1640,
        720
      ],
      "parameters": {
        "name": "={{ $('\ud83d\udcf1 Telegram Message Trigger').item.json.message.document.file_name }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1Y9p3y0P7X39ZnMCH16iFpJbRofLnmR9u",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1Y9p3y0P7X39ZnMCH16iFpJbRofLnmR9u",
          "cachedResultName": "n8n"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "e33ca757-0ee8-45eb-9242-21b64814384d",
      "name": "\ud83d\udcca Record in Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1860,
        600
      ],
      "parameters": {
        "columns": {
          "value": {
            "File Size": "={{ ($json.size / (1024 * 1024)).toFixed(2) }} mb",
            "File Type": "={{ $json.fileExtension }}",
            "Created At": "={{ $json.createdTime.toDateTime().toFormat(\"dd-MM-yyyy HH:mm\") }}",
            "Drive Link": "={{ $json.webViewLink }}",
            "File Name ": "={{ $('\ud83d\udd00 Content Type Router').item.json.message.document.file_name }}",
            "Person Uploaded": "={{ $('\ud83d\udd00 Content Type Router').item.json.message.from.first_name }} {{ $('\ud83d\udd00 Content Type Router').item.json.message.from.last_name }}"
          },
          "schema": [
            {
              "id": "Person Uploaded",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Person Uploaded",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "File Name ",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "File Name ",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Created At",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Created At",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "File Type",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "File Type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "File Size",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "File Size",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Drive Link",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Drive Link",
              "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/1RZs7yzvmJZrlHMonYhHNrgmyNIBlYaZt3Lp5XY5fen0/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1RZs7yzvmJZrlHMonYhHNrgmyNIBlYaZt3Lp5XY5fen0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1RZs7yzvmJZrlHMonYhHNrgmyNIBlYaZt3Lp5XY5fen0/edit?usp=drivesdk",
          "cachedResultName": "File Storage"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "2687e751-f308-4d37-9583-c061cce1810a",
      "name": "Completion Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2520,
        80
      ],
      "parameters": {
        "color": 3,
        "width": 300,
        "height": 380,
        "content": "## \u2705 COMPLETION NOTIFICATION\nSends confirmation message back to Telegram user after successful processing"
      },
      "typeVersion": 1
    },
    {
      "id": "aad8ae8c-ac34-460f-bce3-dc9d644963d6",
      "name": "\u2705 Send Completion Message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        2620,
        240
      ],
      "parameters": {
        "text": "\u2705 Task Completed Successfully! Your content has been processed and saved.",
        "chatId": "={{ $('\ud83d\udcf1 Telegram Message Trigger').item.json.message.chat.id }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a22c5fab-cacd-426e-83be-39d017098d0d",
  "connections": {
    "\ud83c\udf10 Upload to ImgBB": {
      "main": [
        [
          {
            "node": "\ud83d\udcdd Add Image to Notion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udd04 Convert to Base64": {
      "main": [
        [
          {
            "node": "\ud83c\udf10 Upload to ImgBB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udcdd Add Text to Notion": {
      "main": [
        [
          {
            "node": "\u2705 Send Completion Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udcdd Add Image to Notion": {
      "main": [
        [
          {
            "node": "\u2705 Send Completion Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udd00 Content Type Router": {
      "main": [
        [
          {
            "node": "\ud83d\udce5 Download Telegram Image",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\ud83d\udcdd Add Text to Notion",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "\ud83d\udce5 Download Telegram File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udce5 Download Telegram File": {
      "main": [
        [
          {
            "node": "\u2601\ufe0f Upload to Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udcca Record in Google Sheets": {
      "main": [
        [
          {
            "node": "\u2705 Send Completion Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udce5 Download Telegram Image": {
      "main": [
        [
          {
            "node": "\ud83d\udd04 Convert to Base64",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\u2601\ufe0f Upload to Google Drive": {
      "main": [
        [
          {
            "node": "\ud83d\udcca Record in Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "\ud83d\udcf1 Telegram Message Trigger": {
      "main": [
        [
          {
            "node": "\ud83d\udd00 Content Type Router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}