Lookup Tables

Lookup Tables in Bird store and centralize data references, which can be looked up when creating email templates using Liquid templating language in HTML.

For example, every country's flags, abbreviations, or currency can be stored and updated centrally as a lookup table. Every time it is used in building an email, it can be referenced from this lookup table.

Create a Lookup Table

Go to Content > Lookup Tables and click on Create.

  • Enter a display name

  • Enter a slug with no spaces

Note that this slug is used in referencing the email template

  • Click on Save

JSON Editor

  • Once you have saved, you will see a JSON editor. You can select either the Text or UI editor based on your preference.

  • Update the lookup table using a JSON structure.

Adding an item

To add an item in a JSON for organization, click on +Add Item on the left pane.

  • Type a name on the top

  • Click on Add Item button

  • Once created, you can see the item created on the left pane.

Write the JSON

Use the JSON format to define any object structure and key-value pairs below:

For example, a JSON which gives countryname and local currency based on country abbreviation

{

"NL": {

"countryname": "Netherlands",

"local_currency": "EUR"

},

"US": {

"countryname": "United States",

"local_currency": "USD"

}

}

You can also use the UI editor to define the JSON structure.

The same example as above can be defined as:

Use Lookup Table in Email Template

To use a lookup table in an email template, you can add the following liquid syntax to your HTML template or to an HTML element used in a drag-and-drop builder:

{% assign variable_name = "lookup-table-slug" | lookup: "item-name", "object-value" %}

{{variable_name.key_name}}

Here,

  • variable_name is any name you can define

  • lookup-table-slug is the slug you have given when creating the lookup table

  • item-name is the name of the item you have created

  • object-value is the value you have given for the JSON item

  • key_name is the name of the key in the key-value pair defined under item-value

For example,

To render the local currency of a defined country, we can use the below syntax

  • variable_name here is defined as currency (any name that the user can define)

  • lookup-table-slug here is country-flags as defined when the lookup table was created

  • item-name is the country as created earlier and shown in the left pane

  • object-value is AD, which is the value defined in the JSON. Note that this can also be a variable

  • key_name is the local_currency, which is defined in the JSON

{% assign currency = "country-flags" | lookup: "country", "AD" %}

{{currency.local_currency}}

When used in the email template builder in an HTML block, the above syntax will render the value of the local_currency as stored under the AD object under the country item in the lookup table country-flags

You can switch to the preview section to see the output value displayed dynamically in the email template. Below, it is showing EUR as the value fetched from the look-up table.

Last updated