> For the complete documentation index, see [llms.txt](https://docs.premsoft.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.premsoft.de/en/plugins/back-in-stock-notification/flow-builder-and-e-mail-templates.md).

# Flow Builder & E-Mail Templates

The Stock Reminder plugin fully integrates with the Shopware Flow Builder. This allows you to individually control the email delivery for notifications and confirmations and combine them with existing workflows.

### Available Events

The plugin provides three custom business events that can be used as triggers in the Flow Builder:

#### `prems_stock_reminder.double_opt_in`

This event is triggered when a visitor submits the notification form and the double opt-in feature is enabled. It contains the data needed for the confirmation email, including the confirmation link.

**Typical flow:** Send an email with the confirmation link to the subscriber.

| Variable      | Description                                                   |
| ------------- | ------------------------------------------------------------- |
| `productName` | Name of the subscribed product                                |
| `confirmUrl`  | Confirmation link for the double opt-in                       |
| `shopName`    | Name of the shop (from the sales channel's basic information) |
| `email`       | The subscriber's email address                                |

#### `prems_stock_reminder.back_in_stock`

This event is triggered when a product is back in stock and the notification email should be sent to the subscriber. It contains the product data and subscription information.

**Typical flow:** Send an email to the subscriber with the product information and a link to the product.

| Variable      | Description                                                   |
| ------------- | ------------------------------------------------------------- |
| `productName` | Name of the product that is back in stock                     |
| `productId`   | ID of the product, e.g. for a link to the product             |
| `quantity`    | Quantity desired by the subscriber                            |
| `shopName`    | Name of the shop (from the sales channel's basic information) |
| `email`       | The subscriber's email address                                |

> **Tip:** You can use the `productId` variable to build a link to the product in the email template, e.g. via `rawUrl('frontend.detail.page', {'productId': productId}, salesChannel.domains|first.url)`.

#### `prems_stock_reminder.subscription_created`

This event is triggered as soon as a customer newly subscribes to a stock notification for a product. This allows you, for example, to automatically inform the shop owner which product was subscribed to. The event is only triggered the first time an email address subscribes to a product – not when an existing subscription is submitted again.

Email delivery is controlled exclusively via the Flow Builder: the bundled flow **Stock Reminder - Subscription Notification** is initially **deactivated** after installation. To use this feature, activate the flow under **Settings > Flow Builder**. The default recipient is configured – this is the shop owner address from the sales channel's basic information (**Basic information > Email address**). You can change the recipient in the flow action at any time.

**Typical flow:** Send an email to the shop owner with the details of the new subscription.

| Variable        | Description                                                   |
| --------------- | ------------------------------------------------------------- |
| `productName`   | Name of the subscribed product                                |
| `productNumber` | Product number of the subscribed product                      |
| `productId`     | ID of the product, e.g. for a link to the product             |
| `quantity`      | Quantity desired by the subscriber                            |
| `shopName`      | Name of the shop (from the sales channel's basic information) |
| `email`         | The subscriber's email address                                |

In addition, the `salesChannel` object containing the data of the respective sales channel is available in the email templates for all events.

### Setting Up Email Templates

The email templates are automatically created during plugin installation and linked to the corresponding events in the Flow Builder. You can customize the templates at any time via **Settings > Email Templates**.

The plugin ships with the following templates and flows:

| Email template (type)                     | Flow                                        | Event                                       | Active after installation |
| ----------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------- |
| Stock Reminder - Double Opt-In            | Stock Reminder - Double Opt-In Confirmation | `prems_stock_reminder.double_opt_in`        | Yes                       |
| Stock Reminder - Back in Stock            | Stock Reminder - Back in Stock Notification | `prems_stock_reminder.back_in_stock`        | Yes                       |
| Stock Reminder - New Subscription (Admin) | Stock Reminder - Subscription Notification  | `prems_stock_reminder.subscription_created` | No                        |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.premsoft.de/en/plugins/back-in-stock-notification/flow-builder-and-e-mail-templates.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
