Data sources for substitution variables

Courier allows you to use variables to insert values from two sources into your Notifications.

1. The data object:

  • An object included in the send command to provide any data you want to pass into a message template via variables.

2. The User Profile:

  • Profile data can be provided in the profile object of the Send API request OR

  • The User Profile associated with the recipient ID created via the Profiles API.

Note: If there is a conflict, data in the profile object of the Send API call wins over the value in the data object.

Using variables in Notifications

Variables can be used to insert recipient data throughout the content of your Courier Notifications:

  • All Notification types

  • Content Blocks (Text, Action, Markdown, Quote, Template, List)

  • Handlebars code (Template blocks / Email templates / Brands)

  • Email subject line and email addresses (From, To, CC, BCC)

How to insert data object values into Content Blocks with variables

To insert values from the data object, simply encase the variable name inside of single curly brackets: {variable_name}. Correctly formatted variables inside of Text, Markdown, Quote and List Blocks will be highlighted in green.

Inserting profile object values into Content Blocks using variables

To insert values from the profile object or data from the User Profile created with the Profiles API, you will need to use a full JSONPath expression such as profile.variable. For example, if you wanted to insert the user's first name into an Action Block, you could use the expression profile.name.first.

Note: variables used in Action Block Friendly Text and Hyperlink URL will not be highlighted in Green even if they are valid.

Inserting variables into Handlebars code

To insert data into Handlebars, use double curlies {{ }} around the variable using the same paths as you would in Content Blocks, however you need to include the Handlebars variable helper: To insert a variable from your JSON event, you need the variable handlebars helper: var

  • Data object: {{var "variable_name"}}

  • Profile data: {{var "profile.variable_name"}}.

You will see Handlebars code in the Template Content Block type, Brand Templates, and the Handlebars override within Email Notifications.

How to use variables in Email Notifications

In addition to the Handlebars Template override, variables are supported in the Subject line, From address, Reply-To, CC, and BCC in Email Channel Notifications.

Did this answer your question?