Adding dynamic data to your emails
When you create a workflow which sends an email to one of your team, you can include extra information in the email about what triggered the workflow.
For example, sending an email when a new product is created? Then it would be possible to add the Title of the product that has been created, or the Tags it has, or even show data for all the Variants of the product, even if we don't know before hand how many Variants the product might have.
We add this information using Dynamic data. When we add dynamic data, we are creating a space in the message that will be filled with the correct information when the workflow is triggered. So we can create one email, and have it filled with different information every time it runs.
Using the content section menu
Each content section you add contains a menu with all the Dynamic data available. In the below example, we are creating an Email to send when a new order is created. Once a Text content section has been added, we can select it to access the Dynamic data menu.
To add Dynamic data to the Content block, simply scroll down the list and select the data that is required. In the below example, we are adding the name of the customer who placed the order, so we scroll down until we find Customer and select the First Name and Last name. The space marked out in the email that will be filled with the Dynamic data when the workflow runs is shown with an example value.
Access via the shortcut key
It is possible to access Dynamic data values and insert them whilst typing without the need to use the context menu drop down. Let us repeat the above example, but this time we will access data via the shortcut key. At any point, type {
to open the Dynamic data context menu. Now you can either scroll through all the available options, or starting typing the value you require to begin filtering the available options.
Adding repeating dynamic data
Sometimes when dealing with dynamic data there are an unknown number of items in the event to consider. Take for an example a customers order, it will have at least one line item ( product ) in it. But it could have 2, or 5 or 15. This could be make building an email almost impossible; how would you know how many spaces to set aside to fill with specific values when the workflow runs?
There is a solution to this, which is to repeat a Row of the email template for each item in a chosen Data group. What do we mean by this? Let's look at a quick example using when a new order is created.
Here, we perform an additional step before adding a Content block to the Row. We choose a Data Group for the Row - in this case, the Line items for the Order. This does two things: it tells the Row to repeat itself for every Line item the order contains, and it also allows any Content blocks in the Row to use the Dynamic data from the Line item. Let's look at how we could use this to show the Title and Quantity for every Line item in the Order:
With the Data group set on the row, we can add a Content block as usual. But now we have an additional menu item *Line items in the Dynamic data menu. Using this we can add the Title and Quantity of the Line item.
Now when the workflow is triggered and the email sent, this Content block will repeat for every Line item in the order. So if the order contain three Line items, then the email would have three rows, and the specific Title and Quantity would be displayed for each row.
Try it for yourself
Often, the best way to get used to a tool is to play with it. Try creating a new workflow and seeing what information you can add to your emails.
For a more details guide, follow our Building your first workflow guide to get you started.