{
  "name": "S3 Yandex dzen",
  "nodes": [
    {
      "parameters": {
        "updates": [
          "message"
        ],
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.telegramTrigger",
      "typeVersion": 1.2,
      "position": [
        -540,
        -40
      ],
      "id": "b58a5af1-083e-42e1-87a2-c6ca104a017b",
      "name": "Telegram Trigger",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "leftValue": "={{ $json.message.voice.file_id }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "id": "ceb72356-cefd-49ec-ae88-dc7ed4f3365d"
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Voice"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "8c844924-b2ed-48b0-935c-c66a8fd0c778",
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": "/",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Text"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "b2ce709f-3de7-4430-9163-8e2fb2c55baf",
                    "leftValue": "={{ $json.message.document.file_id }}",
                    "rightValue": "",
                    "operator": {
                      "type": "string",
                      "operation": "exists",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Document"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "45f2e6bf-466d-4aa9-a409-2646d003d2f8",
                    "leftValue": "={{ $json.message.text }}",
                    "rightValue": "/",
                    "operator": {
                      "type": "string",
                      "operation": "startsWith"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Commands"
            }
          ]
        },
        "options": {}
      },
      "id": "7671cc94-fa62-4c41-9dd4-35c970260c73",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        -360,
        -60
      ]
    },
    {
      "parameters": {
        "resource": "file",
        "fileId": "={{ $('Telegram Trigger').item.json.message.document.file_id }}"
      },
      "id": "728f316a-5f56-4ceb-a2d1-c88d774c6608",
      "name": "Download File",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        360,
        -20
      ],
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "upload",
        "bucketName": "={{ $('Bucket Name').item.json.bucket_name }}",
        "fileName": "=telegram/docs/{{$('Telegram Trigger').item.json.message.from.id}}/{{ $('Telegram Trigger').item.json.message.document.file_name }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.s3",
      "typeVersion": 1,
      "position": [
        500,
        -20
      ],
      "id": "f7935c46-58ec-4aa4-9458-e1402f43fa87",
      "name": "s3UploadFile",
      "credentials": {
        "s3": {
          "name": "<your credential>"
        }
      },
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "text": "={{ $if($json.success = true, \"\u0424\u0430\u0439\u043b \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\", \"\u041e\u0448\u0438\u0431\u043a\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0444\u0430\u0439\u043b\u0430\") }}",
        "additionalFields": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        500,
        200
      ],
      "id": "265819e9-3a65-4104-8634-ae6937890a73",
      "name": "Telegram",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "deleteMessage",
        "chatId": "={{ $('Telegram Trigger').item.json.message.chat.id }}",
        "messageId": "={{ $('Telegram Trigger').item.json.message.message_id }}"
      },
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        360,
        200
      ],
      "id": "91b0df43-a579-4993-894e-9d66bbb23b5f",
      "name": "DeleteMessage",
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "## \u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0444\u0430\u0439\u043b\u044b \u043d\u0430 S3 Yandex",
        "height": 500,
        "width": 1380
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -620,
        -120
      ],
      "id": "608aaf5a-81b4-46ea-b6b8-0cd49b7e322b",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "d42c12f4-9345-40b8-a1d6-01dbcf89b480",
              "name": "bucket_name",
              "value": "n8n-test-3b",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -120,
        -20
      ],
      "id": "c36036df-6bcd-4302-a4d1-f71b1ef32427",
      "name": "Bucket Name"
    },
    {
      "parameters": {
        "resource": "bucket",
        "operation": "search",
        "bucketName": "={{ $json.bucket_name }}",
        "returnAll": true,
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.s3",
      "typeVersion": 1,
      "position": [
        40,
        -20
      ],
      "id": "7e2190a8-717a-41ee-9bf8-37a23ca2a5a3",
      "name": "Search Bucket",
      "credentials": {
        "s3": {
          "name": "<your credential>"
        }
      },
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "resource": "bucket",
        "name": "={{ $('Bucket Name').item.json.bucket_name }}",
        "additionalFields": {}
      },
      "type": "n8n-nodes-base.s3",
      "typeVersion": 1,
      "position": [
        200,
        80
      ],
      "id": "d33d2575-8f74-4bad-935f-390841f2b169",
      "name": "Create Bucket",
      "credentials": {
        "s3": {
          "name": "<your credential>"
        }
      },
      "onError": "continueErrorOutput"
    }
  ],
  "connections": {
    "Telegram Trigger": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Switch": {
      "main": [
        [],
        [],
        [
          {
            "node": "Bucket Name",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "s3UploadFile",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "s3UploadFile": {
      "main": [
        [
          {
            "node": "DeleteMessage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "DeleteMessage": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Bucket Name": {
      "main": [
        [
          {
            "node": "Search Bucket",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Bucket": {
      "main": [
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create Bucket",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Bucket": {
      "main": [
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "bd6d47ed-ca5d-4fd5-86e3-09ae75ca4b6f",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "MKMEx7DU8VC88lwV",
  "tags": [
    {
      "createdAt": "2025-04-28T18:11:47.783Z",
      "updatedAt": "2025-04-28T18:11:47.783Z",
      "id": "tiKWOyaOMVCJB8GU",
      "name": "kgn-dev"
    },
    {
      "createdAt": "2025-05-08T09:33:44.143Z",
      "updatedAt": "2025-05-08T09:33:44.143Z",
      "id": "8px38elFJCmVPcP0",
      "name": "dzen"
    }
  ]
}