A native feature that would warn an Bloomreach Engagement user about voucher codes running out in any voucher pool is currently not available. This guide will help you set-up a scenario which will deliver these notifications to you.
# This guide will help you understand
How to track count of available voucher codes
How to compare counts and thresholds for warnings and send an email
How to scale this across multiple voucher pools
# Why you should use a notification scenario for a low stock of vouchers
Using this will allow you to react more quickly to a risk of voucher codes running out and emails not being sent to your customers at the critical time you previously identified and set-up in different scenarios.
# How to create the low stock voucher count using Bloomreach Engagement
**Basic Bloomreach Engagement skills:** We will show you step-by-step how to create this scenario using an aggregate, scenario and custom event. We will assume that you can navigate and do basic operations in Bloomreach Engagement. **Data and tracking:** Voucher codes imported into one pool and used in a campaign
## Step by step guide
### 1. Creating a sample customer
In order to automatically display data in emails, the easiest option is to save the data into a custom event and to a specific customer. In this case, it would not make sense to save voucher data to all customers, so we will create a specific customer in Bloomreach Engagement, just for these purposes. A new customer can be created in `
Data & Assets` > `
Customers`. Customer, in this case, would only serve as a place, where we save custom events, so we only need to fill out one of the ID’s, to the filter for this customer.
### 2. Creating a monitoring event
After creating a customer for this purposes, we need to define a custom event to be used in the notification scenario. We can then save data to this event in a scenario. To create a new event, you should go into `
Data & Assets` > `
Data manager` and switch to the events tab. At the very bottom, there is an option to do so. These are the properties and event that we will be using. Feel free to rename them.
### 3. Creating a voucher pool check scenario
Once we set these up, we can start building a scenario. This scenario will check one voucher pool per branch, in our case once a day (early in the morning). After doing so, it will store the observed values into the custom event to our sample customer. Then it will wait a few minutes (to prevent any issues in case a small lag happens) before sending an email, in case the available count of codes is less than a given threshold. The threshold is also set in the event.
Note that the `
Voucher customer` filter simply filters all of the remaining actions to the sample customer that was created for this purpose
Also, the `Add event “voucher notification” - in the 4 fields visible, the first 2 use Jinja that you can copy & paste from the Personalization tab in the email builder - actions are count total codes and count available codes. The pool name should be manually set to the name of the voucher pool and is later used in the email notification to help you distinguish which vouchers are running out. The threshold can be set case by case - if the number of available codes falls below this threshold, the scenario will send an email.
After waiting for 2 minutes to prevent any data inconsistency issues, we then check in condition, whether the saved data should trigger the email. In order to look at a different attribute of the same event and not manual value, please use the button next to the form to switch to attributes.
### 4. Setting up aggregates
In the email, we will use two aggregates. First look for the voucher pool name and second for the actual number of vouchers left. Both these aggregates are looking at the last values of the custom event we set up and started to populate in the scenario. Then, we can use the personalization tab in the email builder to reference these aggregates.
After these aggregates are set-up, we can build up the email.
Last important thing to set is the recipient of the email - this can be done in Settings in the same email.
Please make sure policy is set for 0 hours and you use **General consent**, if you are using the Consent framework. This will ensure that you will receive the email under any circumstances.
# How to scale this for more recipients or more voucher codes?
## 1. Adding more recipients
To add more recipients, you simply need to duplicate the email, connect it to the same condition and change recipient manually in the email settings.
## 2. Adding more voucher
To add more voucher pools into the reporting, you can duplicate the whole tab and change relevant fields in the “Add event voucher_notification” part of the scenario - custom threshold and changing fields containing Jinja to look up relevant voucher pool.
Since the email is looking at the last occurrence of the event, it is necessstaary to trigger these a few minutes apart - the recommended time is 10 minutes apart.