Dynamic Google Slides Image Replacement API Endpoint - n8n Workflow

Use this powerful n8n workflow to dynamically replace images in Google Slides via API requests. Automate presentation updates using a custom n8n trigger and Google Slides API calls.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Marketing agencies automating pitch deck generation.
Developers needing an easy API layer for Google Workspace automation.
Anyone utilizing n8n templates for dynamic content creation.
Users seeking a reliable n8n node setup for complex Google Slides manipulation.

Overview

Managing vast numbers of presentations or updating recurring elements like client logos or campaign visuals manually can be extremely tedious. This specific n8n workflow solves this by exposing a simple, reliable API endpoint. It allows you to trigger an update from any external application, replacing specific images within a Google Slides presentation based on a unique key identifier (stored in the image's Alt Text).

This clever n8n node structure combines API requests and custom code logic to ensure precision. Instead of replacing all images, it specifically targets elements matching your defined key, making this n8n template highly flexible for scaled automation. This is a powerful demonstration of how the n8n trigger system can create custom services.

How it Works

This automation starts with a dedicated n8n trigger. The step-by-step process ensures data integrity and precise execution:


  1. Webhook Activation (n8n Trigger): The n8n workflow begins when an external system sends a POST request to the Webhook path /replace-image-in-slide. The request body must contain the presentationid, the unique imagekey (Alt Text), and the imageurl for the replacement.

  2. Input Validation: An 'If' n8n node immediately checks if all three mandatory parameters (presentationid, imagekey, imageurl) are present. If any are missing, the workflow terminates, returning a 500 error via the 'Error Missing Fields' node.

  3. Retrieve Slide Elements: If validation passes, an HTTP Request n8n node uses the Google Slides API to retrieve all elements and data from the specified presentation.

  4. Identify Target Images (Custom Code): The powerful 'Retrieve matching Images ObjectIds' n8n node (a Code node) filters the data received. It scans all slides for elements that are images and whose 'description' (Alt Text) matches the incoming imagekey. It extracts the Google Slides objectId for every matching image, preparing the data for the next step.

  5. Replace Images (Batch Update): The 'Replace Images' HTTP Request n8n node iterates over the list of objectIds. It uses the Google Slides batchUpdate API method to replace the existing image with the new imageurl using a CENTER_CROP method.

  6. Confirmation: Finally, the 'Respond to Webhook' n8n node sends a successful response back to the originating system, confirming the image replacement is complete. This completes the full execution of the n8n workflow.

Installation Guide

To deploy this custom n8n workflow, follow these steps:


  1. Import: Copy the provided JSON code and import it directly into your n8n instance via the 'Workflows' section using the 'New' button and selecting 'Import from JSON'.

  2. Credentials Setup: This workflow requires Google Slides API access. You must create and configure a Google Slides OAuth2 API credential within your n8n setup.

Find the HTTP Request nodes ('Replace Images' and 'Retrieve All Slide Elements').
Select the existing credential or click 'Create New' to link your Google account that has permission to access and edit the target Google Slides presentations.

  1. Activate Webhook: Ensure the workflow is active. The 'Webhook' n8n trigger will provide you with a unique URL (visible in the node settings when saved and activated).

  2. Prepare Slides: Before triggering the workflow, ensure the images you wish to replace in your Google Slides presentation have a unique identifier set in their Alt Text (Format Options > Alt Text). This ID must match the image_key sent in your POST request.

Node Details

Webhook (n8n Trigger):
Function: Serves as the initiation point, listening for external POST requests on the path /replace-image-in-slide.
Key Configuration: Configured to wait for a response node (responseMode: responseNode).
Check if all params are provided (If n8n node):
Function: Implements core flow control, ensuring the request body contains presentationid, imagekey, and imageurl before proceeding.
Key Configuration: Uses 'exists' operation checks on the input body fields.
Retrieve All Slide Elements (HTTP Request n8n node):
Function: Makes the initial API call to the Google Slides API using the provided presentation
id to fetch the complete JSON structure of the deck.
Key Configuration: Uses Google Slides OAuth2 authentication.
Retrieve matching Images ObjectIds (Code n8n node):
Function: This critical n8n node contains JavaScript logic to filter the returned slide data. It identifies elements that are images and whose Alt Text matches the imagekey from the n8n trigger input.
Key Configuration: Filters data using flatMap and returns an array of matching objectIds.
Replace Images (HTTP Request n8n node):
Function: Executes the Google Slides batchUpdate API call, iterating over the list of objectIds to replace the old image with the new URL.
Key Configuration: Sends a complex JSON body containing replaceImage and updatePageElementAltText requests, dynamically interpolating objectId and imageurl.
Respond to Webhook (n8n node):
* Function: Provides the final status confirmation back to the initiating client, confirming the n8n workflow execution was successful.

Related n8n Workflows

Free

Nodes: 6 Nodes
Updated: December 26 2025
View all
Created by

🎉 Do you want to master AI automation, so you can save time and build cool stuff? I’ve created a welcoming Skool community for non-technical yet resourceful learners.

Featured*