Replace placeholders
Function: Replace placeholders
This function helps you automatically fill in specific parts of a text with custom information. Imagine you have a standard message or document template, and you want to personalize it for different situations or people. This action finds special markers (like \{\{NAME\}\} or \{\{DATE\}\}) in your text and replaces them with the values you provide.
Input
- Text (STRING, required): The original piece of text or template that contains the placeholders you want to replace. For example, "Hello {{NAME}}, your appointment is on {{DATE}}."
- Placeholders (OBJECT, required): A collection of key-value pairs where each key matches a placeholder in your text (without the
\{\{ \}\}brackets), and its corresponding value is what you want to replace it with. For example, if your text has\{\{NAME\}\}, you would provide a placeholder with the keyNAMEand a value like "John Doe".
Output
- Result (STRING): The modified text, with all placeholders replaced, will be stored in a new variable. You can choose the name for this variable; if you don't specify one, it will be named
RESULTby default.
Execution Flow
Real-Life Examples
Example 1: Personalizing an Email Greeting
- Inputs:
- Text: "Dear {{CUSTOMER_NAME}},"
- Placeholders:
CUSTOMER_NAME: "Alice"
- Result: The
RESULTvariable will contain: "Dear Alice,"
Example 2: Generating a Custom Invoice Number
- Inputs:
- Text: "INV-{{YEAR}}-{{MONTH}}-{{SEQUENCE}}"
- Placeholders:
YEAR: "2023"MONTH: "10"SEQUENCE: "001"
- Result: The
RESULTvariable will contain: "INV-2023-10-001"
Example 3: Creating a Dynamic SMS Message
- Inputs:
- Text: "Hi {{USER}}, your order #{{ORDER_ID}} has shipped and will arrive by {{DELIVERY_DATE}}. Track it here: {{TRACKING_URL}}"
- Placeholders:
USER: "Bob"ORDER_ID: "XYZ789"DELIVERY_DATE: "November 15th"TRACKING_URL: "https://example.com/track/XYZ789"
- Result: The
RESULTvariable will contain: "Hi Bob, your order #XYZ789 has shipped and will arrive by November 15th. Track it here: https://example.com/track/XYZ789"