Source: https://gitlab-test-org.docs.pageloop.ai/template-dynamic-content

# Dynamic Content

Dynamic content lets you personalize your notifications with data that changes for each recipient. The left panel of the template editor has four sources of dynamic content.

| Source                                | Use it to                                                                                                 |
| ------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| [Placeholders](#placeholders)         | Insert values from the `data` payload you send when you trigger a notification.                           |
| [Handlebars](#handlebars)             | Transform values and add logic, such as conditions, loops, and date or number formatting.                 |
| [System Variables](#system-variables) | Insert values Fyno already has, such as digest data, user properties, subscription links and Verify OTPs. |
| [Components](#components)             | Reuse building blocks, such as headers, footers and PDF attachments, across templates.                    |

## Placeholders

Placeholders are replaced with the dynamic data sent in the `data` payload. Placeholders are denoted by `{{ }}`.

![](assets/dyncontent-v-2-placeholders-panel.png)

1. **Open the placeholder editor**

   Click **+** or **Add** next to **Placeholders** in the left panel. The **Template Placeholders** pop-up opens.
2. **Add keys and sample values**

   In the **Form** tab, enter a **Key** and a **Sample value** for each placeholder. Click **Add Key** for more rows, or use the delete icon to remove one. Use **Search Key** to find a placeholder.

   ![](assets/dyncontent-v-2-placeholders-form.png)

   You can also switch to the **JSON** tab and enter all the keys and sample values as JSON.

   ![](assets/dyncontent-v-2-placeholders-json.png)
3. **Save**

   Click **Done** to save, **Cancel** to discard your changes, or **Reset** to start over. Sample values are only used for the preview and for test sends.
4. **Use the placeholder in your content**

   Type the key inside double curly braces wherever you need it, for example `Hi {{name}}`.

> [!TIP]
>
> **Placeholders are detected automatically**
>
> When you add a placeholder in your content using `{{ }}` and open the placeholder editor, Fyno shows **New placeholders detected. Add them here?** Click **Yes** to add them automatically.

> [!INFO]
>
> To shorten and track URLs in your placeholders, click **Configure** on the **Shorten and track URLs with Fyno Shorty** banner. See [Fyno Shorty](./url-shortener).

## Handlebars

Handlebars is a JavaScript library for creating dynamic templates. Handlebars in Fyno support conditional operations, loops, date and time formatting, partial searches and custom helpers.

![](assets/dyncontent-v-2-handlebars-categories.png)

See [Handlebars](./templates-handlebars) for the helpers, with examples.

### Build Your Own

Under **Build Your Own**, you can create dynamic logic with custom conditions and loops in two ways:

- **Generate with Fyno AI:** Click **Generate** and describe what you need. See [Generate Handlebars with Fyno AI](./templates-handlebars#generate-handlebars-with-fyno-ai).
- **Handlebars Builder:** Click **Handlebars Builder** to build the logic visually with blocks. See [Handlebars Builder](./templates-handlebars#handlebars-builder).

![](assets/hbcreate-v-2-build-your-own.png)

## System Variables

System Variables are pre-defined values in Fyno, so you don't need to send them in your payload. There are four groups.

![](assets/dyncontent-v-2-system-variables.png)

#### Digest

If you use the **Digest** action in your workflow, three variables are available:

| Variable  | What it gives you                          |
| --------- | ------------------------------------------ |
| **head**  | The top 5 payloads in the digest.          |
| **tail**  | The bottom 5 payloads in the digest.       |
| **count** | The total count of payloads in the digest. |

Learn more in [Creating a workflow with Digest](./creating-a-workflow-with-digest).

#### User Properties

If you use Fyno's user profiles, all the user properties linked to a user profile are listed here. Learn how to create user properties in [Adding a new user property](./adding-new-user-property).

To use a user property, add it in this format:

| Property type     | Format                  | Example                  |
| ----------------- | ----------------------- | ------------------------ |
| Built-in property | `{{$user.$<property>}}` | `{{$user.$name}}`        |
| Custom property   | `{{$user.<property>}}`  | `{{$user.loyalty_tier}}` |

#### Subscription

Use these variables to let users opt in, opt out or unsubscribe from your notifications.

| Variable           | Use it to                                                                                                      |
| ------------------ | -------------------------------------------------------------------------------------------------------------- |
| **Opt-in/Opt-out** | Add to the button payload in WhatsApp templates, so users can opt in to or out of your WhatsApp notifications. |
| **Unsubscribe**    | Add a clickable unsubscribe link to your notification, usually in the footer of email templates.               |

#### Verify

[Fyno Verify](./fyno-verify-otp-link) is a fully managed API for multichannel user verification by OTP or link. To set it up, click **Configure** under **Verify**.

![](assets/dyncontent-v-2-verify-panel.png)

| Variable | Use it to                                              |
| -------- | ------------------------------------------------------ |
| **OTP**  | Generate and verify an OTP.                            |
| **Link** | Verify an email address or mobile number using a link. |

## Components

Components are modular, reusable elements, such as headers, footers and PDF attachments. Create them once, then add them to any template. Click **+** next to **Components** to create one, or select an existing one to insert it.

![](assets/dyncontent-v-2-components.png)

> [!INFO]
>
> Components are currently available only for email templates.

Learn more in [Components](./components).
