{
  "id": "RsBtAMu8K66veIXY",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Auto-Translate Google Slides Presentation",
  "tags": [],
  "nodes": [
    {
      "id": "ebcadd07-05d8-4697-a3f7-e26c4bd45209",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -624,
        -80
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "2b24ed35-54ec-4bbe-9679-727a7628c0ac",
      "name": "Get slides from a presentation",
      "type": "n8n-nodes-base.googleSlides",
      "position": [
        80,
        -80
      ],
      "parameters": {
        "operation": "getSlides",
        "presentationId": "={{ $json.id }}"
      },
      "credentials": {
        "googleSlidesOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "a1ccda01-d0b1-4434-a1dd-ca17c2a1179e",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        400,
        384
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9185e2de-fd63-47a6-b2b9-79d251a85140",
      "name": "Translate Google Slides",
      "type": "n8n-nodes-base.googleSlidesTool",
      "position": [
        752,
        416
      ],
      "parameters": {
        "textUi": {
          "textValues": [
            {
              "text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('textValues0_Search_For', ``, 'string') }}",
              "matchCase": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('textValues0_Match_Case', ``, 'boolean') }}",
              "replaceText": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('textValues0_Replace_With', ``, 'string') }}",
              "pageObjectIds": "={{ $('When Executed by Another Workflow').item.json.objectId }}"
            }
          ]
        },
        "options": {},
        "operation": "replaceText",
        "presentationId": "={{ $('When Executed by Another Workflow').item.json.presentationId }}"
      },
      "credentials": {
        "googleSlidesOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "5ee73a74-b554-489b-8ca2-861ae5afaea9",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        816,
        -64
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "extractTexts"
      },
      "typeVersion": 1
    },
    {
      "id": "b2c99a24-48af-45e2-9420-a76a147e0f61",
      "name": "Execute Workflow",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        1008,
        -64
      ],
      "parameters": {
        "options": {},
        "workflowId": {
          "__rl": true,
          "mode": "id",
          "value": "RsBtAMu8K66veIXY"
        },
        "workflowInputs": {
          "value": {
            "lang": "={{ $('Set Language').item.json.lang }}",
            "objectId": "={{ $('Extract Text').item.json.objectId }}",
            "extractTexts": "={{ $json.extractTexts }}",
            "presentationId": "={{ $('Duplicate presentation').item.json.id }}"
          },
          "schema": [
            {
              "id": "objectId",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "objectId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "lang",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "lang",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "presentationId",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "presentationId",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "extractTexts",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "extractTexts",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": true,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a9682dde-b5d5-46de-92b3-861a459d9e16",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        16,
        208
      ],
      "parameters": {
        "inputSource": "jsonExample",
        "jsonExample": "{\n  \"objectId\": \"a string\",\n  \"lang\": \"a string\",\n  \"presentationId\": \"a string\",\n  \"extractTexts\": \"a string\" \n}\n\n"
      },
      "typeVersion": 1.1
    },
    {
      "id": "bd0f34c0-414f-43ac-b30c-751e21bd7f92",
      "name": "Duplicate presentation",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -176,
        -80
      ],
      "parameters": {
        "name": "=Presentation_{{ $json.lang }}_{{$now.format('yyyyLLddHHii')}}",
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "=XXXXXXX"
        },
        "options": {},
        "operation": "copy"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "4d75421a-ee3a-4d80-9e8d-d42de564d879",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        352,
        -80
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "bb40c6fc-7f6e-401d-b8f1-e2240890b936",
      "name": "Extract Text",
      "type": "n8n-nodes-base.code",
      "position": [
        608,
        -64
      ],
      "parameters": {
        "jsCode": "// Estrai i testi e restituisci anche l'objectId della slide\nconst results = [];\n\nfor (const item of $input.all()) {\n  const objectId = item.json.objectId;\n  const texts = [];\n\n  const pageElements = item.json.pageElements || [];\n\n  for (const element of pageElements) {\n    const textElements = element?.shape?.text?.textElements || [];\n\n    for (const textElement of textElements) {\n      if (textElement.textRun?.content) {\n        texts.push(textElement.textRun.content);\n      }\n    }\n  }\n\n  results.push({\n    json: {\n      objectId,\n      extractTexts: texts\n    }\n  });\n}\n\nreturn results;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "475c9fef-ceb0-4cf6-a50f-568dd9fa8f56",
      "name": "Wait 10 sec",
      "type": "n8n-nodes-base.wait",
      "position": [
        1184,
        -64
      ],
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "09f07da1-e3e0-4193-8444-26d08d36687b",
      "name": "Wait 3 sec",
      "type": "n8n-nodes-base.wait",
      "position": [
        832,
        208
      ],
      "parameters": {
        "amount": 3
      },
      "typeVersion": 1.1
    },
    {
      "id": "07a95504-11c9-4aeb-b033-e97ea6b1959e",
      "name": "Translation expert",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        432,
        208
      ],
      "parameters": {
        "text": "=Text to translate:\n{{ $json.extractTexts }}",
        "options": {
          "systemMessage": "=You are an expert Google Slides translator. Your primary function is to translate slides sent to you to {{ $json.lang }} (Code ISO-639) using the tool \"Translate language\" for better performs and then use the \"Translate Google Slide\" tool.\n\n## Translation Guidelines:\n\n**TRANSLATE:**\n- All text content in slides\n\n**DO NOT TRANSLATE:**\n- Email addresses (e.g., info@company.com)\n- Website URLs and links (e.g., www.example.it)\n- Physical addresses and locations\n- Phone numbers\n- Company names and brand names\n- Proper nouns (names of people, places, organizations)\n- Any other information that should remain in the original language\n\n## Process:\n1. Receive the Google Slides document\n2. Identify all text elements that require translation\n3. Use the \"Translate Google Slide\" tool to perform the translation from Italian to English\n4. Ensure proper context and professional tone in the English translation\n5. Maintain the original formatting and structure of the slides\n\n## Quality Standards:\n- Provide accurate, contextually appropriate translations\n- Maintain professional terminology and tone\n- Preserve the original meaning and intent\n- Ensure readability and flow in English"
        },
        "promptType": "define"
      },
      "typeVersion": 2.1
    },
    {
      "id": "56236111-f91a-457b-a209-6ddd561fce2d",
      "name": "Set Language",
      "type": "n8n-nodes-base.set",
      "position": [
        -416,
        -80
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "534bdd67-f789-4064-9da5-f958a73c9f89",
              "name": "lang",
              "type": "string",
              "value": "zh-CN"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "c4b91198-16a8-4f74-a014-77ace950442c",
      "name": "Translate language",
      "type": "n8n-nodes-base.googleTranslateTool",
      "position": [
        592,
        416
      ],
      "parameters": {
        "text": "={{ $json.extractTexts }}",
        "translateTo": "={{ $json.lang }}"
      },
      "credentials": {
        "googleTranslateOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "26e239f5-2035-4baa-a934-991f12ae82d2",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -688
      ],
      "parameters": {
        "color": 3,
        "width": 784,
        "height": 240,
        "content": "## AI-Powered Auto-Translate Google Slides Presentation to any language\n\nThis workflow automates the **translation of Google Slides presentations** from **any languages**, while preserving the original formatting and slide structure. It leverages **Google APIs**, **AI translation (Gemini/PaLM)**, and modular execution for high flexibility and accuracy.\n\n**DISCLAIMER**: texts are split by Google Slides APIs into small blocks, so the translation will not always be contextualized."
      },
      "typeVersion": 1
    },
    {
      "id": "d7fccf24-7d3a-45d8-b7cc-d33f63ec0219",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -416
      ],
      "parameters": {
        "width": 784,
        "height": 112,
        "content": "## STEP 1\nIMPORTANT: Set the \"Set Language\" node with the language you want to translate the presentation into, with the format [ISO-639](https://cloud.google.com/translate/docs/languages)"
      },
      "typeVersion": 1
    },
    {
      "id": "263322f3-2059-41cd-88ec-4ccd5003c03c",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -640,
        -272
      ],
      "parameters": {
        "width": 784,
        "height": 112,
        "content": "## STEP 2\nIn the node \"Duplicate presentation\" set up the presentation you want to translate"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "3b5ab2a4-83cc-4cd2-b0f3-e67088417c8e",
  "connections": {
    "Split Out": {
      "main": [
        [
          {
            "node": "Execute Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 3 sec": {
      "main": [
        []
      ]
    },
    "Wait 10 sec": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Language": {
      "main": [
        [
          {
            "node": "Duplicate presentation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Extract Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Workflow": {
      "main": [
        [
          {
            "node": "Wait 10 sec",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Translate language": {
      "ai_tool": [
        [
          {
            "node": "Translation expert",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Translation expert": {
      "main": [
        [
          {
            "node": "Wait 3 sec",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Duplicate presentation": {
      "main": [
        [
          {
            "node": "Get slides from a presentation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Translate Google Slides": {
      "ai_tool": [
        [
          {
            "node": "Translation expert",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Translation expert",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Get slides from a presentation": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Translation expert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Set Language",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}