{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "76cdbf3e-e25b-4998-bf56-6cd13140e166",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        0,
        80
      ],
      "parameters": {
        "options": {
          "buttonLabel": "Backup & Delete",
          "appendAttribution": false
        },
        "formTitle": "\ud83e\uddfe Backup & Delete Workflow",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Paste the full workflow URL below.",
              "placeholder": " https://n8n-miinstancia.com/workflow/abc123",
              "requiredField": true
            }
          ]
        },
        "formDescription": "This tool backs up the full JSON file of a workflow to a Google Drive folder before safely deleting it from your n8n instance."
      },
      "typeVersion": 2.2
    },
    {
      "id": "10ef7ab2-86ca-4e62-b94f-77a6e18f920d",
      "name": "Send a text message",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1936,
        80
      ],
      "parameters": {
        "text": "=\u2705 Workflow Backup Successful\n\nThe workflow titled: {{ $json.name }} \nwith ID: {{ $json.id }} \nhas been successfully backed up to your selected Google Drive Folder.\n\n\ud83d\udcc4 You can view the backup at the following link:\n(USE YOUR GOOGLE DRIVE FOLDER LINK HERE)\n\n\ud83d\udcc5 Backup Date: {{ $now }}\n",
        "chatId": "123456789",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b038653e-afd6-4c59-b291-7caddf8cca7a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -768,
        -560
      ],
      "parameters": {
        "width": 624,
        "height": 1360,
        "content": "## \ud83d\udd0d Description:\nEffortlessly delete unused or inactive workflows from your n8n instance while automatically backing them up as .json files into your Google Drive. Keep your instance clean, fast, and organized \u2014 no more clutter slowing you down. This workflow is ideal for users managing large self-hosted n8n setups, or anyone who wants to maintain optimal performance while preserving full workflow backups.\n\n## \u2705 What it does:\n* Accepts a full n8n Workflow URL via a form\n* Retrieves workflow info automatically\n* Converts the workflow\u2019s full JSON definition into a file\n* Uploads that file to Google Drive\n* Deletes the workflow safely using the official n8n API\n* Sends a Telegram notification confirming backup and deletion\n\n## \u2699\ufe0f How it works:\n\ud83d\udcdd Form \u2013 Collects the full workflow URL from the user\n\ud83d\udd0d n8n Node (Get Workflow) \u2013 Uses the URL to fetch workflow details\n\ud83d\udce6 Code Node (\"JSON to File\") \u2013 Converts the workflow JSON into a properly formatted .json file with UTF-8 encoding, ready to be uploaded to Google Drive.\n\u2601\ufe0f Google Drive Upload \u2013 Uploads the .json backup file to your selected Drive folder\n\ud83d\uddd1\ufe0f n8n Node (Delete Workflow) \u2013 Deletes the workflow from your instance using its ID\n\ud83d\udcec Telegram Notification \u2013 Notifies you that the workflow was backed up and deleted, showing title, ID, and date\n\n## \ud83d\udccb Requirements:\n* Google Drive connected to your n8n account\n* Telegram Bot connected to n8n\n* An n8n instance with API access (self-hosted or Cloud)\n* Your n8n API Key (Create one in the settings)\n\n## \ud83d\udee0\ufe0f How to Set Up:\n\u2705 Add your Google Drive credentials\n\u2705 Add your Telegram Bot credentials\n\n\ud83e\uddfe In the \u201cJSON to File\u201d Code node, no additional setup is required \u2014 it automatically converts the workflow JSON into a downloadable .json file using the correct encoding and filename format.\n\n\u2601\ufe0f In the Google Drive node:\nBinary Property: data\nFolder ID: your target folder in Google Drive\n\n\ud83d\udd11 Create a new credential for the n8n node using:\nAPI Key: your personal n8n API key\nBase URL: your full n8n instance API path (e.g. https://your-n8n-instance.com/api/v1)\n\u2699\ufe0f Use this credential in both the Get Workflow and Delete Workflow n8n nodes\n\n\ud83d\udcec In the Telegram node, use this message template:\n\ud83d\uddd1\ufe0f Workflow \"{{ $json.name }}\" (ID: {{ $json.id }}) was backed up to Google Drive and deleted from n8n.\n\ud83d\udcc5 {{ $now }}\n\n\ud83d\udd12 Important: This workflow backs up the entire workflow data to Google Drive. Please be careful with the permissions of your Google Drive folder and avoid sharing it publicly, as the backups may contain sensitive information. Ensuring proper security and access control is essential to protect your data.\n\n\ud83d\ude80 Activate the workflow and you're ready to safely back up and remove workflows from your n8n instance\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "9da23a3f-d899-4eab-a12e-17ff8fa3c816",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 1360,
        "content": "## \ud83d\udcdd 1. Form Node: \"Get Workflow URL\"\n\n* Instruction: Ask the user to paste the full workflow URL they want to delete. This URL will be passed to the next node for processing.\n\n* Example input: https://your-n8n-instance/workflow/abcd1234\n\n* [See the Form Submission node documentation.](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.formtrigger/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.formTrigger)\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "2ed52c3b-1898-4c06-adc2-d81708ae3679",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 1360,
        "content": "## \ud83d\udd0d 2. n8n Node: \"Get Workflow\"\n\n* Instruction: Use the official n8n node with API Key authentication to fetch full workflow details using the ID extracted from the URL.\n\n* Requirement: API Key Auth credentials configured with your API Key and Base URL (e.g., https://your-n8n-instance/api/v1).\n\n* [See the n8n node documentation.](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.n8n/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.n8n)"
      },
      "typeVersion": 1
    },
    {
      "id": "775f86f7-2daf-45ae-9ab6-0bf6a1ab56ef",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1040,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 1360,
        "content": "## \ud83d\udcc1 Google Drive Node: \"Upload Workflow Backup\"\n\nInstruction: Upload the binary file containing the workflow JSON backup to a specified folder in Google Drive. Configure folder ID and file name dynamically if needed.\n\n* [See the Google Drive node documentation.](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.googledrive/file-operations/#upload-a-file)"
      },
      "typeVersion": 1
    },
    {
      "id": "fc18f562-569a-48fa-9faa-14b0dc6349db",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1424,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 1360,
        "content": "## \ud83d\uddd1\ufe0f 5. n8n Node: \"Delete Workflow\"\n\n* Instruction: Delete the workflow from your instance using its ID. Use the same API Key Auth credentials as in step 2.\n\n* [See the n8n node documentation.](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.n8n/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.n8n)"
      },
      "typeVersion": 1
    },
    {
      "id": "e19ae6be-61e2-414b-af70-2069dc3925a5",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1808,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 1360,
        "content": "## \ud83d\udcec 6. Telegram Node: \"Send Notification\"\n\n* Instruction: Send a Telegram message confirming the workflow was backed up and deleted successfully. Include the workflow name, ID, date, and a link to the backup in Google Sheets.\n\n* [See the Telegram node documentation.](https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.telegram/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.telegram)"
      },
      "typeVersion": 1
    },
    {
      "id": "cbef6523-6186-4a83-b70c-5b3c4a619615",
      "name": "Upload Workflow",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1168,
        80
      ],
      "parameters": {
        "name": "={{ $('Get a Workflow').item.json.name }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1Wv8HI8jUu-XbpC4mRJH78WNMAD_xM8f8",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1Wv8HI8jUu-XbpC4mRJH78WNMAD_xM8f8",
          "cachedResultName": "N8N - Deleted Workflows Backup"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "e31a574e-a952-43f0-89cc-e385e46f6075",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        656,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 1360,
        "content": "## \ud83d\udce6 5. Code Node: \"Generate .json File\"\n\nInstruction: This node converts the workflow JSON into a properly formatted binary file (.json) to upload to Google Drive. It uses the workflow name for the filename and sets the correct MIME type.\n\n* [See the Code node documentation.](https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.code/?utm_source=n8n_app&utm_medium=node_settings_modal-credential_link&utm_campaign=n8n-nodes-base.code)"
      },
      "typeVersion": 1
    },
    {
      "id": "1b9ef445-9385-4b2c-a0c0-391bb5799887",
      "name": "Delete a Workflow",
      "type": "n8n-nodes-base.n8n",
      "position": [
        1568,
        80
      ],
      "parameters": {
        "operation": "delete",
        "workflowId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Get a Workflow').item.json.id }}"
        },
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5d540bb7-99f0-4202-8eb7-d37200468163",
      "name": "Get a Workflow",
      "type": "n8n-nodes-base.n8n",
      "position": [
        400,
        80
      ],
      "parameters": {
        "operation": "get",
        "workflowId": {
          "__rl": true,
          "mode": "url",
          "value": "={{ $json['Paste the full workflow URL below.'] }}"
        },
        "requestOptions": {}
      },
      "credentials": {
        "n8nApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2da4e84a-20f3-4d3c-905e-eb884218e3b1",
      "name": "JSON to File",
      "type": "n8n-nodes-base.code",
      "position": [
        784,
        80
      ],
      "parameters": {
        "jsCode": "const fileName = `${$json.name.replace(/[^a-z0-9_-]/gi, \"_\") || \"workflow\"}.json`;\nconst jsonContent = JSON.stringify($json, null, 2);\n\nreturn [\n  {\n    binary: {\n      data: await this.helpers.prepareBinaryData(Buffer.from(jsonContent), fileName, 'application/json'),\n    },\n    json: {\n      fileName,\n    },\n  },\n];\n"
      },
      "typeVersion": 2
    }
  ],
  "connections": {
    "JSON to File": {
      "main": [
        [
          {
            "node": "Upload Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get a Workflow": {
      "main": [
        [
          {
            "node": "JSON to File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Workflow": {
      "main": [
        [
          {
            "node": "Delete a Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Delete a Workflow": {
      "main": [
        [
          {
            "node": "Send a text message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Get a Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}