> ## Documentation Index
> Fetch the complete documentation index at: https://help.maestra.io/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Insert Recommendations Into an Email

Once you've built a recommendation algorithm in Maestra Platform, you can drop its output into any email template using the algorithm's templater parameter. The parameter returns a collection of product objects, which you iterate over to render names, prices, images, and links.

<Tip>
  If you use Maestra's drag-and-drop email builder, you can add a recommendation block visually — no template code required. The steps below cover the case where you're writing the template by hand.
</Tip>

## Find the templater parameter

<Steps>
  <Step title="Open the algorithm">
    Go to **Personalization → Product recommendations** and open the algorithm you want to use in the email.
  </Step>

  <Step title="Copy the templater parameter">
    On the algorithm page, find the **Templater parameter** field. This is the variable name you'll reference in the email template.
  </Step>

  <Step title="Open the email template">
    Open the email where you want the recommendations to appear and paste the parameter into the template where the recommendation block should render.
  </Step>
</Steps>

<Note>
  The recommendation parameter is a **collection**. You always access individual products through a `for ... endfor` loop — there's no direct way to address a single item without iterating.
</Note>

## Example: list eight recommended products

The simplest case — print the name and price of every recommended product in a vertical list. Replace `recommendations` with your algorithm's templater parameter.

```liquid theme={null}
{% for item in recommendations %}
  <p>{{ item.Name }} — {{ item.Price }}</p>
{% endfor %}
```

Inside the loop, each `item` exposes the product's fields — name, price, URL, image, and any custom fields included in the algorithm output.

## Example: lay out products in a grid (two per row)

To render the same eight products in a two-column table instead of a flat list, use the `tableRows()` helper to chunk the collection into rows.

```liquid theme={null}
<table>
  {% for row in recommendations | tableRows(2) %}
    <tr>
      {% for item in row %}
        <td>
          <img src="{{ item.PictureUrl }}" />
          <p>{{ item.Name }}</p>
          <p>{{ item.Price }}</p>
        </td>
      {% endfor %}
    </tr>
  {% endfor %}
</table>
```

`tableRows(2)` groups the products into rows of two. Change the number to control how many products appear per row.

## Check whether recommendations exist

For some customers — typically those without enough behavior history — an algorithm may return an empty collection. Use the `IsEmpty` function to detect this case and fall back to alternative content, such as a popular-products block.

```liquid theme={null}
{% if recommendations | IsEmpty %}
  {% for item in popularProducts %}
    <p>{{ item.Name }} — {{ item.Price }}</p>
  {% endfor %}
{% else %}
  {% for item in recommendations %}
    <p>{{ item.Name }} — {{ item.Price }}</p>
  {% endfor %}
{% endif %}
```

<Tip>
  The fallback pattern is the most reliable way to guarantee an email never goes out with an empty recommendation block. Pair a personalized algorithm (which can return empty) with a popular-products algorithm (which almost always returns results) and you're covered.
</Tip>
