n8n API nutzen und Formular-Trigger verwenden, um Workflows zu Google Drive zu sichern und zu löschen

Fortgeschritten

Dies ist ein DevOps-Bereich Automatisierungsworkflow mit 13 Nodes. Hauptsächlich werden N8n, Code, Telegram, FormTrigger, GoogleDrive und andere Nodes verwendet. Sichern und lösche Workflows mit n8n API und Formulartriggern in Google Drive

Voraussetzungen
  • Telegram Bot Token
  • Google Drive API-Anmeldedaten

Kategorie

Workflow-Vorschau
Visualisierung der Node-Verbindungen, mit Zoom und Pan
Workflow exportieren
Kopieren Sie die folgende JSON-Konfiguration und importieren Sie sie in n8n
{
  "meta": {
    "instanceId": "0a82a9d5784b67ad963ceff89283b2e40cb771be10fe58ba2682f3598a37c6e1",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "76cdbf3e-e25b-4998-bf56-6cd13140e166",
      "name": "Bei Formularübermittlung",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        0,
        80
      ],
      "webhookId": "350d8518-e91c-4fd0-af83-b6649e7965bd",
      "parameters": {
        "options": {
          "buttonLabel": "Backup & Delete",
          "appendAttribution": false
        },
        "formTitle": "🧾 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": "Textnachricht senden",
      "type": "n8n-nodes-base.telegram",
      "position": [
        1936,
        80
      ],
      "webhookId": "192a1c25-6efc-465a-b77d-c250fee9a57b",
      "parameters": {
        "text": "=✅ 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📄 You can view the backup at the following link:\n(USE YOUR GOOGLE DRIVE FOLDER LINK HERE)\n\n📅 Backup Date: {{ $now }}\n",
        "chatId": "8019473661",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "id": "BjU1NgO9AIM86N5W",
          "name": "EMPTY"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b038653e-afd6-4c59-b291-7caddf8cca7a",
      "name": "Notiz",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -768,
        -560
      ],
      "parameters": {
        "width": 624,
        "height": 1360,
        "content": "## 🔍 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 — 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## ✅ What it does:\n* Accepts a full n8n Workflow URL via a form\n* Retrieves workflow info automatically\n* Converts the workflow’s 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## ⚙️ How it works:\n📝 Form – Collects the full workflow URL from the user\n🔍 n8n Node (Get Workflow) – Uses the URL to fetch workflow details\n📦 Code Node (\"JSON to File\") – Converts the workflow JSON into a properly formatted .json file with UTF-8 encoding, ready to be uploaded to Google Drive.\n☁️ Google Drive Upload – Uploads the .json backup file to your selected Drive folder\n🗑️ n8n Node (Delete Workflow) – Deletes the workflow from your instance using its ID\n📬 Telegram Notification – Notifies you that the workflow was backed up and deleted, showing title, ID, and date\n\n## 📋 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## 🛠️ How to Set Up:\n✅ Add your Google Drive credentials\n✅ Add your Telegram Bot credentials\n\n🧾 In the “JSON to File” Code node, no additional setup is required — it automatically converts the workflow JSON into a downloadable .json file using the correct encoding and filename format.\n\n☁️ In the Google Drive node:\nBinary Property: data\nFolder ID: your target folder in Google Drive\n\n🔑 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⚙️ Use this credential in both the Get Workflow and Delete Workflow n8n nodes\n\n📬 In the Telegram node, use this message template:\n🗑️ Workflow \"{{ $json.name }}\" (ID: {{ $json.id }}) was backed up to Google Drive and deleted from n8n.\n📅 {{ $now }}\n\n🔒 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🚀 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": "Notiz1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 1360,
        "content": "## 📝 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": "Notiz2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 1360,
        "content": "## 🔍 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": "Notiz4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1040,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 1360,
        "content": "## 📁 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": "Notiz5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1424,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 1360,
        "content": "## 🗑️ 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": "Notiz6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1808,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 1360,
        "content": "## 📬 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": "Workflow hochladen",
      "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": {
          "id": "Ru2YSsIPYQIOlnvD",
          "name": "EMPTY"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "e31a574e-a952-43f0-89cc-e385e46f6075",
      "name": "Notiz7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        656,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 1360,
        "content": "## 📦 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": "Workflow löschen",
      "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": {
          "id": "VSxAuLMW3kDlXjYA",
          "name": "EMPTY"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "5d540bb7-99f0-4202-8eb7-d37200468163",
      "name": "Workflow abrufen",
      "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": {
          "id": "VSxAuLMW3kDlXjYA",
          "name": "EMPTY"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2da4e84a-20f3-4d3c-905e-eb884218e3b1",
      "name": "JSON zu Datei",
      "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
    }
  ],
  "pinData": {},
  "connections": {
    "2da4e84a-20f3-4d3c-905e-eb884218e3b1": {
      "main": [
        [
          {
            "node": "cbef6523-6186-4a83-b70c-5b3c4a619615",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "5d540bb7-99f0-4202-8eb7-d37200468163": {
      "main": [
        [
          {
            "node": "2da4e84a-20f3-4d3c-905e-eb884218e3b1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "cbef6523-6186-4a83-b70c-5b3c4a619615": {
      "main": [
        [
          {
            "node": "1b9ef445-9385-4b2c-a0c0-391bb5799887",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "1b9ef445-9385-4b2c-a0c0-391bb5799887": {
      "main": [
        [
          {
            "node": "10ef7ab2-86ca-4e62-b94f-77a6e18f920d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "76cdbf3e-e25b-4998-bf56-6cd13140e166": {
      "main": [
        [
          {
            "node": "5d540bb7-99f0-4202-8eb7-d37200468163",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Häufig gestellte Fragen

Wie verwende ich diesen Workflow?

Kopieren Sie den obigen JSON-Code, erstellen Sie einen neuen Workflow in Ihrer n8n-Instanz und wählen Sie "Aus JSON importieren". Fügen Sie die Konfiguration ein und passen Sie die Anmeldedaten nach Bedarf an.

Für welche Szenarien ist dieser Workflow geeignet?

Fortgeschritten - DevOps

Ist es kostenpflichtig?

Dieser Workflow ist völlig kostenlos. Beachten Sie jedoch, dass Drittanbieterdienste (wie OpenAI API), die im Workflow verwendet werden, möglicherweise kostenpflichtig sind.

Workflow-Informationen
Schwierigkeitsgrad
Fortgeschritten
Anzahl der Nodes13
Kategorie1
Node-Typen6
Schwierigkeitsbeschreibung

Für erfahrene Benutzer, mittelkomplexe Workflows mit 6-15 Nodes

Autor
Arlin Perez

Arlin Perez

@arlindeveloper

👋 Hi! I'm Arlin - a QA Engineer with 2 years of experience and a background in Dart & Flutter for mobile app development. ⚙️ I'm passionate about automation and love building efficient workflows using n8n. 📬 Reach out for any help with custom workflows

Externe Links
Auf n8n.io ansehen

Diesen Workflow teilen

Kategorien

Kategorien: 34