Skip to main content

Replace Text

Replaces all occurrences of specific text in a Google Slides presentation.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • Presentation Id - The ID of the Google Slides presentation where text will be replaced.
  • Text to Replace - The text content that will be searched for and replaced.
  • Replacement - The new text that will replace the matching text.

Options

  • Search case sensitivity - If enabled, the text search is case-sensitive; otherwise, it's case-insensitive.
  • Page Object Ids - An array of page IDs to limit the replacement operation to specific slides. If empty, all slides in the presentation are searched.

How It Works

The Replace Text node finds all occurrences of the specified text and replaces them with new text throughout a Google Slides presentation. When executed, the node:

  1. Validates the provided inputs (Presentation Id, Text to Replace, Replacement)
  2. Connects to the specified Google Slides presentation
  3. Searches for all occurrences of the specified text across the presentation or specified pages
  4. Replaces each matching text instance with the replacement text

Requirements

  • A valid Google Slides presentation ID
  • Valid Google Slides API credentials
  • Text content to search for and replace
  • Proper permissions to modify the presentation

Error Handling

The node will return specific errors in the following cases:

  • Empty or invalid Presentation Id
  • Empty or invalid Text to Replace
  • Empty or invalid Replacement text
  • Google Slides API authentication errors
  • Insufficient permissions to modify the presentation
  • Invalid presentation ID
  • No text found matching the search criteria
  • Google Slides service errors

Usage Notes

  • The Presentation Id can be found in the URL of the Google Slides presentation
  • The Text to Replace is searched throughout the entire presentation content
  • When Page Object Ids is specified, only those slides are searched for matching text
  • The Search case sensitivity option allows for precise matching requirements
  • This node is particularly useful for:
    • Updating template presentations with specific content
    • Replacing placeholders with actual values
    • Making bulk text updates across multiple slides
  • If no matching text is found, the node returns an error
  • The replacement preserves the original text formatting
  • All instances of the matching text are replaced in a single operation

Examples

Example 1: Replace Simple Placeholder

Replace a single placeholder with actual data:

Presentation Id: "1ABC..."
Text to Replace: "{{CLIENT_NAME}}"
Replacement: "Acme Corporation"
Search case sensitivity: false

Replaces all instances of {{CLIENT_NAME}} with "Acme Corporation" throughout the presentation.

Example 2: Replace with Case Sensitivity

Replace text with exact case matching:

Presentation Id: "1ABC..."
Text to Replace: "DRAFT"
Replacement: "FINAL VERSION"
Search case sensitivity: true

Only replaces "DRAFT" in uppercase, leaving "Draft" or "draft" unchanged.

Example 3: Replace on Specific Slides

Replace text only on designated slides:

Presentation Id: "1ABC..."
Text to Replace: "{{DATE}}"
Replacement: "2024-12-23"
Page Object Ids: ["p1", "p3", "p5"]

Replaces the date placeholder only on slides with IDs p1, p3, and p5.

Example 4: Multiple Sequential Replacements

Replace multiple placeholders in sequence:

// In a workflow
const replacements = [
{ find: "{{NAME}}", replace: "John Doe" },
{ find: "{{TITLE}}", replace: "Senior Manager" },
{ find: "{{COMPANY}}", replace: "Tech Corp" },
{ find: "{{DATE}}", replace: new Date().toLocaleDateString() }
];

for (const item of replacements) {
msg.textToReplace = item.find;
msg.replacement = item.replace;
// Replace Text node here
}

Tips for Effective Use

  1. Placeholder Convention: Use distinctive markers like {{PLACEHOLDER}} or [[VAR]] to avoid accidental replacements
  2. Case Sensitivity: Use case-insensitive search for user-generated content, case-sensitive for code or specific terms
  3. Order Matters: If replacements overlap, do them in the right order to avoid conflicts
  4. Validate Data: Ensure replacement text doesn't contain formatting that might break the presentation
  5. Batch by Slide: Use Page Object Ids to limit scope and improve performance when working with large presentations
  6. Test First: Test replacements on a copy before modifying important presentations

Common Use Cases

Use Case 1: Personalized Presentation Generation

Create personalized presentations for multiple recipients:

// Load client data
const clients = [
{ name: "Acme Corp", contact: "Jane Smith", revenue: "$1.2M" },
{ name: "Tech Start", contact: "Bob Johnson", revenue: "$850K" }
];

for (const client of clients) {
// Copy template
msg.presentationId = msg.newPresentationId; // From Copy Presentation

// Replace placeholders
const replacements = [
{ find: "{{CLIENT_NAME}}", replace: client.name },
{ find: "{{CONTACT_NAME}}", replace: client.contact },
{ find: "{{REVENUE}}", replace: client.revenue }
];

// Execute replacements
}

Use Case 2: Automated Report Updates

Update weekly reports with current data:

// Generate current metrics
const today = new Date();
msg.weekNum = `Week ${Math.ceil((today - new Date(today.getFullYear(), 0, 1)) / 604800000)}`;
msg.reportDate = today.toLocaleDateString();
msg.salesTotal = "$" + calculateWeeklySales().toLocaleString();
msg.customerCount = getCustomerCount().toString();

// Use multiple Replace Text nodes to update:
// {{WEEK_NUMBER}} -> msg.weekNum
// {{REPORT_DATE}} -> msg.reportDate
// {{SALES_TOTAL}} -> msg.salesTotal
// {{CUSTOMER_COUNT}} -> msg.customerCount

Use Case 3: Template Localization

Replace text for different languages:

const translations = {
en: { greeting: "Hello", title: "Annual Report" },
es: { greeting: "Hola", title: "Informe Anual" },
fr: { greeting: "Bonjour", title: "Rapport Annuel" }
};

const lang = msg.targetLanguage; // e.g., "es"

msg.greetingText = translations[lang].greeting;
msg.titleText = translations[lang].title;

// Replace {{GREETING}} and {{TITLE}} placeholders

Use Case 4: Dynamic Data Injection

Replace placeholders with data from external sources:

// Fetch data from API, database, or spreadsheet
const data = await fetchProjectData(msg.projectId);

// Prepare replacements
msg.projectName = data.name;
msg.projectStatus = data.status;
msg.completionDate = data.completionDate;
msg.budgetUsed = data.budget.used;
msg.budgetTotal = data.budget.total;

// Execute Replace Text for each placeholder

Advanced Techniques

Conditional Replacements

Replace different text based on conditions:

// In a JS node
const status = msg.projectStatus;
let statusDisplay;

if (status === "completed") {
statusDisplay = "✓ Completed on Schedule";
} else if (status === "delayed") {
statusDisplay = "⚠ Delayed - Action Required";
} else {
statusDisplay = "○ In Progress";
}

msg.statusReplacement = statusDisplay;
// Then use Replace Text to update {{STATUS}}

Formatted Number Replacements

Replace placeholders with properly formatted numbers:

// Format numbers for presentation
msg.revenue = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
}).format(1234567.89); // "$1,234,567.89"

msg.percentage = (0.1234 * 100).toFixed(2) + "%"; // "12.34%"

Common Errors and Solutions

ErrorCauseSolution
"Presentation ID cannot be empty"No ID provided or ID is "_"Ensure valid Presentation Id is provided
"Text to replace cannot be empty"Empty search textProvide valid text to search for
"Replacement cannot be empty"Empty replacement stringProvide replacement text (can be empty string if intentional)
"No matching text found"Text doesn't exist in presentationVerify the text exists; check case sensitivity setting
Invalid Page Object IdSpecified slide ID doesn't existGet presentation metadata first to find valid slide IDs
Replacement affects formattingSpecial characters in replacementTest with plain text first, add formatting manually if needed

Best Practices

  1. Unique Placeholders: Use unique, distinctive placeholder text that won't appear naturally in content
  2. Documentation: Maintain a list of all placeholders used in templates
  3. Validation: Verify all placeholders are replaced by checking for remaining placeholder patterns
  4. Error Handling: Use try-catch to handle cases where placeholders might not exist
  5. Incremental Updates: Replace one type of placeholder at a time for easier debugging
  6. Template Testing: Test templates thoroughly with various data to ensure all replacements work correctly
  7. Preserve Formatting: Keep replacement text similar in length to placeholders to maintain layout