Using conditional text blocks in an automated email

Using variables in your emails allows you to personalize your messages. And using tags and filters on email templates allows you to create completely different emails for different groups. But sometimes you want something that's somewhere in between. Not just replacing one word, but also not sending a completely different email. That's where conditional text blocks come in handy.

Let's say you want to send pretty much the same 'before your first day' email to all new hires, but you want to include an additional paragraph when the person is joining the engineering team.

Now, you could have two separate email templates and use filters to send one to anyone who doesn't have the engineering tag and the other to everyone who does. But then when you need to make small changes to the text of the standard email, you've gotta remember to do it in two places.

Conditional text blocks allow you to include different text, without having to manage multiple templates for the same email.

What it looks like

They look like this:

{{#ifEqual officeLocationField "Spain"}}
¡Bienvenidos, {{ Preferred first name }}!
{{else}}
Welcome {{ Preferred first name }}!
{{/ifEqual}}

The components

It opens with a  line of logic

{{#ifEqual officeLocationField "Spain"}}

The first line is wrapped in curly brackets – {{ }} – and includes: a method, the employee data you're checking, and the text you're checking to see if the data does or doesn't match.

Conditional text blocks have three methods to choose from: ifEqual, ifNotEqual or ifIncludes

The ifEqual and ifNotEqual methods reference either a field or a survey response, using the format [camelCaseName]Field or [camelCaseName]SurveyResponse.

So if you're trying to reference a "Office Location" employee field it would be written "officeLocationField"

If you're trying to reference a "Remote employee" survey response it would be written "remoteEmployeeSurveyResponse".

And then the opening line finishes with the field value that you are looking for. So in the Office Location example the logic is looking for "Spain".

Note: You must surround the text values with double quotes (e.g. “Spain”) instead of single quotes (e.g. ‘Spain’)

With the ifIncludes method, you reference a field or survey response, like above, using the same camel case format, but then follow with multiple options for values that the field could have.

{{#ifIncludes officeLocationField "Spain" "England" "France"}}

So in this instance, the conditional text block would be included for any employee whose Office Location is Spain, England, or France.

Under that first line is the text you want to dynamically include for people who match the criteria, including any employee variables.

¡Bienvenidos, {{ Preferred first name }}!

Next you have the option of including alternative text for anyone who doesn't meet the logic criteria.

{{else}}
Welcome {{ Preferred first name }}!

And finally close the conditional text block method.

{{/ifEqual}}