{
  "name": "Redokun: translate files from a Google Drive folder",
  "nodes": [
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "cfg-source-language",
              "name": "sourceLanguage",
              "type": "string",
              "value": "en"
            },
            {
              "id": "cfg-target-languages",
              "name": "targetLanguages",
              "type": "string",
              "value": "it, de"
            },
            {
              "id": "cfg-ai-vendor",
              "name": "aiVendor",
              "type": "string",
              "value": "DEEPL"
            },
            {
              "id": "cfg-min-percent",
              "name": "minPreTranslatedPercent",
              "type": "number",
              "value": 100
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "id": "9c897b52-ffd2-44d6-9a6f-7bf04ef3f7aa",
      "name": "Config",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        224,
        400
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "rs-source-language",
              "name": "sourceLanguage",
              "type": "string",
              "value": "={{ String($json.sourceLanguage || '').trim() }}"
            },
            {
              "id": "rs-target-list",
              "name": "targetLanguageList",
              "type": "array",
              "value": "={{ String($json.targetLanguages || '').split(',').map(s => s.trim()).filter(Boolean) }}"
            },
            {
              "id": "rs-output-folder-id",
              "name": "outputFolderId",
              "type": "string",
              "value": "={{ (String($('Save translated file').params.folderId.value || '').match(/[-\\w]{15,}/) || [''])[0] }}"
            },
            {
              "id": "rs-watched-folder-id",
              "name": "watchedFolderId",
              "type": "string",
              "value": "={{ (String($('New file in Drive folder').params.folderToWatch.value || '').match(/[-\\w]{15,}/) || [''])[0] }}"
            },
            {
              "id": "rs-ai-vendor",
              "name": "aiVendor",
              "type": "string",
              "value": "={{ String($json.aiVendor || 'DEEPL').trim() }}"
            },
            {
              "id": "rs-min-percent",
              "name": "minPreTranslatedPercent",
              "type": "number",
              "value": "={{ $json.minPreTranslatedPercent }}"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "id": "28427813-ee8b-4bf4-abb5-fc13c04e4d66",
      "name": "Read settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        448,
        400
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "if-settings",
              "leftValue": "={{ !!$json.sourceLanguage && $json.targetLanguageList.length > 0 && !!$json.outputFolderId }}",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "rightValue": ""
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "37c35a5f-38cf-4683-bccf-80f6c54d7525",
      "name": "Settings complete?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        656,
        400
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "id": "e9b5adbe-181c-4928-a448-427e4599651e",
      "name": "Loop over files",
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        880,
        400
      ]
    },
    {
      "parameters": {
        "errorMessage": "Setup is incomplete: set the source language and at least one target language in Config, and choose the output folder in the step Save translated file."
      },
      "id": "e6c911c4-8c03-4a63-a94e-c11901f911b2",
      "name": "Fail: setup incomplete",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        880,
        640
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "if-folders",
              "leftValue": "={{ $json.outputFolderId !== $json.watchedFolderId && !($json.parents || []).includes($json.outputFolderId) }}",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "rightValue": ""
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "0d89ed21-ccb9-466d-9dce-db8e599fc6a7",
      "name": "Output folder differs?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        1104,
        400
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "if-supported",
              "leftValue": "={{ ['application/vnd.google-apps.document', 'application/vnd.google-apps.spreadsheet', 'application/vnd.google-apps.presentation'].includes($json.mimeType) || /\\.(idml|docx|pptx|xlsx|html|srt|txt|xml|json|xliff|xlf|pdf)$/i.test($json.name) }}",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "rightValue": ""
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "8bbe10be-939c-41d5-b6f0-245a6e4ed4a9",
      "name": "Supported file?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        1328,
        400
      ]
    },
    {
      "parameters": {
        "errorMessage": "The output folder is the folder this workflow watches. Choose a different folder in the step Save translated file, otherwise translated files would be translated again."
      },
      "id": "8443b24b-12e2-4722-b503-a30adb6fcc12",
      "name": "Fail: same folder",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        1328,
        640
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.redokun.com/v1/documents",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "file",
              "inputDataFieldName": "data"
            },
            {
              "name": "sourceLanguage",
              "value": "={{ $('Read settings').first().json.sourceLanguage }}"
            },
            {
              "name": "targetLanguages",
              "value": "={{ JSON.stringify($('Read settings').first().json.targetLanguageList.map(code => ({ code }))) }}"
            }
          ]
        },
        "options": {}
      },
      "id": "f6bbf9d6-1a6e-4b89-94af-c5e48a26643c",
      "name": "Upload document",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2208,
        400
      ]
    },
    {
      "parameters": {},
      "id": "ce5b531e-d037-4f09-9dad-afa64fb69489",
      "name": "Wait indexing",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        2416,
        400
      ],
      "webhookId": "6e7a688b-2d8a-4c9c-9f7b-3e3ffa331538"
    },
    {
      "parameters": {
        "url": "={{ $('Upload document').first().json.links.find(l => l.rel === 'self').href }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "options": {}
      },
      "id": "3eaad180-79d9-47a1-a13b-be80d2a56755",
      "name": "Get document",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2640,
        400
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "if-indexed",
              "leftValue": "={{ $json.status }}",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "rightValue": "INDEXED"
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "3ad1890e-d88f-4112-848d-f4cd503d9c5d",
      "name": "Indexed?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        2864,
        400
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ ($json.links.find(l => l.rel === 'translations') || {}).href || ($json.links.find(l => l.rel === 'self').href + '/translations') }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ languages: $('Read settings').first().json.targetLanguageList.map(code => ({ code, translationMemory: true, machineTranslation: true, machineTranslationVendor: $('Read settings').first().json.aiVendor })) }) }}",
        "options": {}
      },
      "id": "d44072c9-1b5b-459e-a3ce-a208be416103",
      "name": "Launch pre-translation",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3088,
        400
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "if-indexing-error",
              "leftValue": "={{ $json.status }}",
              "operator": {
                "type": "string",
                "operation": "equals"
              },
              "rightValue": "INDEXING_ERROR"
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "aa17e956-d79e-4f4a-90f4-dc14688bb115",
      "name": "Indexing error?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        3088,
        640
      ]
    },
    {
      "parameters": {
        "errorMessage": "={{ 'Redokun could not read the file: ' + $json.indexingError }}"
      },
      "id": "0c6e1676-7757-424d-bbbe-12f027b70980",
      "name": "Fail: indexing",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        3296,
        560
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "if-indexing-time",
              "leftValue": "={{ $now.toMillis() - DateTime.fromISO($('Upload document').first().json.createdAt).toMillis() < 300000 }}",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "rightValue": ""
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "76a18d15-368f-43b4-85e7-98af9f846734",
      "name": "Indexing in time?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        3296,
        768
      ]
    },
    {
      "parameters": {
        "errorMessage": "Timeout: Redokun is still reading the file after 5 minutes."
      },
      "id": "81dfe07c-f39e-49ae-a023-362014e118d7",
      "name": "Fail: indexing timeout",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        3520,
        864
      ]
    },
    {
      "parameters": {
        "amount": 10
      },
      "id": "4db449ff-bf5a-479a-9a27-28bf78940308",
      "name": "Wait pre-translation",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        3296,
        400
      ],
      "webhookId": "4f6a0cb9-f7a6-4a12-a6d7-c23864657aef"
    },
    {
      "parameters": {
        "url": "={{ $('Launch pre-translation').first().json.links.find(l => l.rel === 'self').href }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "options": {}
      },
      "id": "93a372ab-288e-4eb3-a87e-4ec045a69fc2",
      "name": "Get translations",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3520,
        400
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "if-pre-done",
              "leftValue": "={{ $json.translations.length > 0 && $json.translations.every(t => t.status === 'CREATED') }}",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "rightValue": ""
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "9242a256-0339-432f-ae81-98136e10fcbb",
      "name": "Pre-translation done?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        3744,
        400
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "if-enough",
              "leftValue": "={{ $json.translations.every(t => t.progress.completedPercentage >= $('Read settings').first().json.minPreTranslatedPercent) }}",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "rightValue": ""
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "61b59fcb-80b1-452a-bca3-24e6c012bd4c",
      "name": "Enough pre-translated?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        3968,
        400
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "if-still-pre",
              "leftValue": "={{ $json.translations.some(t => t.status === 'PRE_TRANSLATING') }}",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "rightValue": ""
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "c6834888-8b2c-4f87-8964-3e31585dfb9d",
      "name": "Still pre-translating?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        3968,
        640
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "if-pre-time",
              "leftValue": "={{ $now.toMillis() - DateTime.fromISO($('Upload document').first().json.createdAt).toMillis() < 1800000 }}",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "rightValue": ""
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "7d1d1694-0c16-42d7-923b-8d2e81b8af85",
      "name": "Pre-translation in time?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        4176,
        560
      ]
    },
    {
      "parameters": {
        "errorMessage": "={{ 'Unexpected status during pre-translation: ' + JSON.stringify($json.translations.map(t => t.language.code + '=' + t.status)) }}"
      },
      "id": "c6e4f4f8-2a1a-4ec7-87b0-c827aaa70a31",
      "name": "Fail: pre-translation status",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        4176,
        864
      ]
    },
    {
      "parameters": {
        "errorMessage": "Timeout: the pre-translation is still running after 30 minutes."
      },
      "id": "f6a3490b-428a-4b94-8e33-715f13b93978",
      "name": "Fail: pre-translation timeout",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        4400,
        656
      ]
    },
    {
      "parameters": {
        "fieldToSplitOut": "translations",
        "options": {}
      },
      "id": "d5125c17-486e-4db7-b5d8-571e475f828f",
      "name": "Split languages",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1.1,
      "position": [
        4176,
        400
      ]
    },
    {
      "parameters": {
        "errorMessage": "={{ 'The pre-translation is below the minimum set in Config: ' + JSON.stringify($json.translations.map(t => t.language.code + '=' + t.progress.completedPercentage + '%')) }}"
      },
      "id": "e5b9cf5a-9760-4284-9df9-a3d18de3af80",
      "name": "Fail: pre-translation incomplete",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        4176,
        256
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ ($json.links.find(l => l.rel === 'generate') || {}).href || ($json.links.find(l => l.rel === 'self').href + '/generate') }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "confirm",
              "value": "true"
            },
            {
              "name": "confirmDrafts",
              "value": "true"
            }
          ]
        },
        "options": {}
      },
      "id": "774d0cf0-04a2-4603-926a-5643b6ddd5fe",
      "name": "Confirm and generate",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        4400,
        400
      ]
    },
    {
      "parameters": {
        "amount": 10
      },
      "id": "b5d168f0-29d7-4416-ab99-f159bbb2cf73",
      "name": "Wait generation",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        4624,
        400
      ],
      "webhookId": "c065f701-72a1-4054-911b-95b8f571952d"
    },
    {
      "parameters": {
        "url": "={{ $('Launch pre-translation').first().json.links.find(l => l.rel === 'self').href }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "options": {}
      },
      "id": "936532b8-4254-4212-b344-0194bbc93670",
      "name": "Check generation",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        4848,
        400
      ],
      "executeOnce": true
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "if-all-generated",
              "leftValue": "={{ $json.translations.length > 0 && $json.translations.every(t => t.status === 'GENERATED') }}",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "rightValue": ""
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "dbe29676-d1e4-4279-b7f5-37a4cfaca99e",
      "name": "All generated?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        5056,
        400
      ]
    },
    {
      "parameters": {
        "fieldToSplitOut": "translations",
        "options": {}
      },
      "id": "9db5f96b-7eba-4e6d-9c84-6f5a37664e25",
      "name": "Split generated languages",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1.1,
      "position": [
        5280,
        400
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "if-still-gen",
              "leftValue": "={{ $json.translations.every(t => t.status === 'GENERATING' || t.status === 'GENERATED') }}",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "rightValue": ""
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "44bb1d49-058f-4131-91a2-1e8649278bbf",
      "name": "Still generating?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        5280,
        640
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 1
          },
          "conditions": [
            {
              "id": "if-gen-time",
              "leftValue": "={{ $now.toMillis() - DateTime.fromISO($('Upload document').first().json.createdAt).toMillis() < 3600000 }}",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "rightValue": ""
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "efe59e0a-3761-459e-9ffd-ce790cb601b8",
      "name": "Generation in time?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        5504,
        560
      ]
    },
    {
      "parameters": {
        "errorMessage": "={{ 'Unexpected status during generation: ' + JSON.stringify($json.translations.map(t => t.language.code + '=' + t.status)) }}"
      },
      "id": "c936942e-b5a8-43c5-a349-8fd5f2693e80",
      "name": "Fail: generation status",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        5504,
        864
      ]
    },
    {
      "parameters": {
        "errorMessage": "Timeout: the translated files are still being generated after 60 minutes."
      },
      "id": "594e63b0-b41a-451b-8c03-bca77400ced9",
      "name": "Fail: generation timeout",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        5728,
        656
      ]
    },
    {
      "parameters": {
        "url": "={{ ($json.links.find(l => l.rel === 'download') || {}).href || ($json.links.find(l => l.rel === 'self').href + '/download') }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "options": {}
      },
      "id": "ec4bbc99-8223-4348-b4b0-39760e5a5a3f",
      "name": "Get download URL",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        5504,
        400
      ],
      "retryOnFail": true,
      "maxTries": 5,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "file"
            }
          }
        }
      },
      "id": "235bef24-b358-405e-ba52-b5505a7e793c",
      "name": "Download translated file",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        5728,
        400
      ]
    },
    {
      "parameters": {
        "content": "## Start here\n1. In **New file in Drive folder**, choose the folder to watch.\n2. In **Save translated file**, choose the folder for the translated files. It must be a different folder.\n3. In **Config**, set the languages.",
        "height": 416,
        "width": 400,
        "color": 4
      },
      "id": "1f567326-78c3-49bd-a29d-4f302cfbe119",
      "name": "Sticky Note 944fe8b1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -48,
        176
      ]
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "event": "fileCreated",
        "options": {}
      },
      "id": "87818a91-167f-4cc9-8bfd-11a758c8841f",
      "name": "New file in Drive folder",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        0,
        400
      ]
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {
          "binaryPropertyName": "data",
          "googleFileConversion": {
            "conversion": {
              "docsToFormat": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
              "sheetsToFormat": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
            }
          },
          "fileName": "={{ $json.name + ($json.mimeType === 'application/vnd.google-apps.document' ? '.docx' : $json.mimeType === 'application/vnd.google-apps.spreadsheet' ? '.xlsx' : $json.mimeType === 'application/vnd.google-apps.presentation' ? '.pptx' : '') }}"
        }
      },
      "id": "ff9da033-ce19-4571-bb3b-2e6959aeda8d",
      "name": "Download source file",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        1760,
        400
      ]
    },
    {
      "parameters": {
        "name": "={{ $('Get download URL').item.json.filename }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "options": {}
      },
      "id": "6a84918c-6471-4459-aae2-1c7c361ab5b1",
      "name": "Save translated file",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        5936,
        400
      ]
    }
  ],
  "connections": {
    "Config": {
      "main": [
        [
          {
            "node": "Read settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read settings": {
      "main": [
        [
          {
            "node": "Settings complete?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings complete?": {
      "main": [
        [
          {
            "node": "Loop over files",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fail: setup incomplete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Output folder differs?": {
      "main": [
        [
          {
            "node": "Supported file?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fail: same folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supported file?": {
      "main": [
        [
          {
            "node": "Download source file",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Loop over files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload document": {
      "main": [
        [
          {
            "node": "Wait indexing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait indexing": {
      "main": [
        [
          {
            "node": "Get document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get document": {
      "main": [
        [
          {
            "node": "Indexed?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Indexed?": {
      "main": [
        [
          {
            "node": "Launch pre-translation",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Indexing error?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Launch pre-translation": {
      "main": [
        [
          {
            "node": "Wait pre-translation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Indexing error?": {
      "main": [
        [
          {
            "node": "Fail: indexing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Indexing in time?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Indexing in time?": {
      "main": [
        [
          {
            "node": "Wait indexing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fail: indexing timeout",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait pre-translation": {
      "main": [
        [
          {
            "node": "Get translations",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get translations": {
      "main": [
        [
          {
            "node": "Pre-translation done?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pre-translation done?": {
      "main": [
        [
          {
            "node": "Enough pre-translated?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Still pre-translating?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Enough pre-translated?": {
      "main": [
        [
          {
            "node": "Split languages",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fail: pre-translation incomplete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Still pre-translating?": {
      "main": [
        [
          {
            "node": "Pre-translation in time?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fail: pre-translation status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pre-translation in time?": {
      "main": [
        [
          {
            "node": "Wait pre-translation",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fail: pre-translation timeout",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split languages": {
      "main": [
        [
          {
            "node": "Confirm and generate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Confirm and generate": {
      "main": [
        [
          {
            "node": "Wait generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait generation": {
      "main": [
        [
          {
            "node": "Check generation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check generation": {
      "main": [
        [
          {
            "node": "All generated?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "All generated?": {
      "main": [
        [
          {
            "node": "Split generated languages",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Still generating?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split generated languages": {
      "main": [
        [
          {
            "node": "Get download URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Still generating?": {
      "main": [
        [
          {
            "node": "Generation in time?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fail: generation status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generation in time?": {
      "main": [
        [
          {
            "node": "Wait generation",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fail: generation timeout",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get download URL": {
      "main": [
        [
          {
            "node": "Download translated file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New file in Drive folder": {
      "main": [
        [
          {
            "node": "Config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download source file": {
      "main": [
        [
          {
            "node": "Upload document",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download translated file": {
      "main": [
        [
          {
            "node": "Save translated file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save translated file": {
      "main": [
        [
          {
            "node": "Loop over files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop over files": {
      "main": [
        null,
        [
          {
            "node": "Output folder differs?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate"
  }
}
