Google Slides Replacer avatar

Google Slides Replacer

Try for free

No credit card required

View all Actors
Google Slides Replacer

Google Slides Replacer

kamil.stus/google-slides-replacer
Try for free

No credit card required

Automate the creation of Google Slides presentations from a template, with support for dynamic text replacement.

Google Slides Replacer Actor

What does the Google Slides Replacer Actor do?

The Google Slides Replacer Actor automates the process of creating a copy of a Google Slides presentation and replacing specified text within it. This Actor utilizes the Google Drive and Google Slides APIs to perform its tasks.

The Actor's workflow is as follows:

  • Authentication: Authenticates with Google using either service account or user authentication methods.
  • Template Copying: Creates a copy of a specified Google Slides template.
  • Text Replacement: Replaces specified text in the new presentation based on provided key-value pairs.
  • Output: Outputs the ID of the newly created presentation.

Usage instructions

  1. Set up Google API credentials:

    • Follow the instructions to obtain Google API credentials for either service account or user authentication.
    • Ensure the necessary APIs (Google Drive API and Google Slides API) are enabled in your Google Cloud project.
  2. Provide input parameters:

    • Fill in the required input parameters in the Apify Actor configuration.
  3. Run the Actor:

    • Execute the Actor. It will create a new presentation, make the specified text replacements, and output the new presentation's ID.

Input parameters

The Actor accepts the following input parameters:

ParameterTypeDescriptionRequired
authTypeStringThe type of authentication to use. Must be either "service_account" or "user". Default to "user".No
authTokenStringA JSON string containing the authentication token information.Yes
templateIdStringThe ID of the Google Slides template to copy.Yes
newFileNameStringThe name to give to the new copy of the presentation.Yes
replacementsStringA JSON string containing key-value pairs of text to replace in the presentation.Yes

Obtaining the Google auth token

Follow the official Google documentation about authentication and authorization.

  • Ensure that the provided authentication credentials have the necessary permissions to access and modify Google Drive and Google Slides.
  • When using service account authentication, make sure to share the template presentation with the service account email address.

Service account authentication

  1. Go to the Google Cloud Console.
  2. Create a new project or select an existing one.
  3. Enable the Google Drive API and Google Slides API for your project.
  4. Go to "APIs & Services" > "Credentials".
  5. Click "Create Credentials" and select "Service Account".
  6. Fill in the required information and create the service account.
  7. Once created, go to the service account details and add a new key (JSON type).
  8. Download the JSON key file.
  9. Set the authType input to "service_account".
  10. Use the contents of this JSON file as the authToken input for the Actor.

Official Google documentation about service account authentication.

User authentication

  1. Go to the Google Cloud Console.

  2. Create a new project or select an existing one.

  3. Enable the Google Drive API and Google Slides API for your project.

  4. Go to "APIs & Services" > "Credentials".

  5. Click "Create Credentials" and select "OAuth client ID".

  6. Choose "Desktop app" as the application type.

  7. Download the client configuration file.

  8. Use the gcloud CLI to obtain the refresh token:

    gcloud auth application-default login
  9. Create a JSON object with the client ID, client secret, and refresh token:

    1{
    2  "client_id": "YOUR_CLIENT_ID",
    3  "client_secret": "YOUR_CLIENT_SECRET",
    4  "refresh_token": "YOUR_REFRESH_TOKEN"
    5}
  10. Set the authType input to "user".

  11. Use this JSON object as the authToken input for the Actor.

Official Google documentation about user authentication.

Finding the template ID

To find the template ID of a Google Slides presentation:

  1. Open the Google Slides presentation in your web browser.

  2. Look at the URL in the address bar. It will look something like this:

    https://docs.google.com/presentation/d/1A2B3C4D5E6F7G8H9I0J/edit
  3. The template ID is the long string of characters between /d/ and /edit. In this example, the template ID is 1A2B3C4D5E6F7G8H9I0J.

Results

The Actor outputs the ID of the newly created presentation to the default key-value store with the key OUTPUT. Example:

1{
2  "OUTPUT": "1A2B3C4D5E6F7G8H9I0J"
3}

Error handling

The Actor includes error handling for:

  • Authentication failures
  • File copying issues
  • Text replacement problems

Any errors encountered during execution are logged for troubleshooting.

Developer
Maintained by Community

Actor Metrics

  • 1 monthly user

  • 0 No stars yet

  • >99% runs succeeded

  • Created in Jul 2024

  • Modified a month ago

Categories