Skip to content

Conditionals

Conditionals let you show different content to different people based on their data. Whether you want to greet VIP members differently, show content based on a user's location, or check if a field exists -- conditionals make it possible.


Basic If/Else

The simplest conditional shows one thing when a condition is true, and optionally something else when it's not:

Example: Basic if/else

Template:

{if the user's Plan is premium}
Welcome, VIP member!
{else}
Upgrade to premium for exclusive benefits.
{end if}

Output:

Welcome, VIP member!

The structure is always:

{if condition}
Content shown when true
{else}
Content shown when false
{end if}

The {else} part is optional -- you can use just {if} and {end if} if you only want to show content when the condition is true.


Else-If Chains

When you need to check multiple conditions in order, use {else if}:

Example: Else-if chain

Template:

{if the user's Plan is enterprise}
Enterprise dashboard access enabled.
{else if the user's Plan is premium}
Premium features unlocked.
{else if the user's Plan is growth}
Growth plan active.
{else}
Free tier - upgrade anytime!
{end if}

Output:

Premium features unlocked.

The engine checks each condition from top to bottom and shows the content for the first one that matches. If none match, the {else} content is shown (if provided).


Comparison Operators

NLT supports 20 comparison operators, all written in plain English. Here they are grouped by category.

Equality

OperatorExample
is{if the user's Status is active}
is equal to{if the user's Status is equal to active}
is exactly{if the user's Code is exactly ABC123}
is not{if the user's Status is not inactive}

Example: Equality check

Template:

{if the user's Status is active}Account is active!{end if}

Output:

Account is active!

Tip

Equality checks are case-insensitive, so is active matches "Active", "ACTIVE", and "active" equally.

Numeric Comparisons

OperatorExample
is more than{if the user's Score is more than 80}
is greater than{if the user's Age is greater than 18}
is less than{if the user's Risk is less than 5}
is at least{if the user's Score is at least 80}
is at most{if the user's Attempts is at most 3}
is greater than or equal to{if the user's Balance is greater than or equal to 100}
is less than or equal to{if the user's Risk is less than or equal to 3}
is between X and Y{if the user's Score is between 50 and 100}

Example: Numeric comparison

Template:

{if the user's Score is more than 80}High achiever!{end if}

Output:

High achiever!

Example: Between range check

Template:

{if the user's Score is between 50 and 100}In range!{end if}

Output:

In range!

Tip

Dollar signs and commas are automatically stripped in numeric comparisons. So {if the user's Total is more than $1,000} works perfectly -- no need to remove the formatting yourself.

Existence Checks

OperatorExample
is set{if the user's Email is set}
is not set{if the user's Phone is not set}

Example: Existence check

Template:

{if the user's Email is set}We'll send updates to your email.{end if}

Output:

We'll send updates to your email.

Example: Missing field check

Template:

{if the user's Phone is not set}Please add your phone number.{end if}

Output:

Please add your phone number.

Containment

OperatorExample
contains{if the user's Tags contains "vip"}
does not contain{if the user's Tags does not contain "spam"}

Example: Array containment

Template:

{if the user's Tags contains "vip"}VIP member!{end if}

Output:

VIP member!

Example: String containment

Template:

{if the user's Email contains "@company.com"}Internal user{end if}

Output:

Internal user

Note

contains works on both arrays (checks if the item is in the list) and strings (checks for a substring). It's case-insensitive in both cases.

Date Comparisons

OperatorExample
is today{if the user's Birthday is today}
is this week{if the user's Appointment is this week}
is this month{if the user's Trial End is this month}
is within the last N days{if the user's Last Purchase is within the last 30 days}
is within the last N weeks{if the user's Signup is within the last 2 weeks}
is within the last N months{if the user's Activity is within the last 3 months}
is before{if the user's Expiry is before 2026-12-31}
is after{if the user's Start Date is after 2026-01-01}

Example: Date: is today

Template:

{if the user's Birthday is today}Happy Birthday!{end if}

Output:

Happy Birthday!

Example: Date: within the last N days

Template:

{if the user's Last Purchase is within the last 30 days}Recent customer{end if}

Output:

Recent customer

Example: Date: before a specific date

Template:

{if the user's Expiry is before 2026-12-31}Expiring soon{end if}

Output:

Expiring soon

Tip

Both singular and plural time units work: within the last 1 day and within the last 30 days are both valid.


Combining Conditions

AND (all must be true)

Use and to require multiple conditions:

Example: AND: both conditions must be true

Template:

{if the user's Plan is premium and the user's Score is more than 80}
Elite VIP status!
{end if}

Output:

Elite VIP status!

OR (at least one must be true)

Use or to match any of several conditions:

Example: OR: either condition can be true

Template:

{if the user's Country is US or the user's Country is UK}
English content
{end if}

Output:

English content

NOT (negate a condition)

Use not to flip a condition:

Example: NOT: negate a condition

Template:

{if not the user's Email is set}
Please add your email address.
{end if}

Output:

Please add your email address.

Combining AND and OR

You can mix and and or in a single condition. AND has higher priority than OR (just like in math, where multiplication happens before addition):

{if the user's Plan is premium or the user's Score is more than 90 and the user's VIP is yes}

This evaluates as: Plan is premium OR (Score > 90 AND VIP is yes).

Warning

Since AND binds more tightly than OR, be careful with complex conditions. If you need a different grouping, consider breaking it into nested {if} blocks instead.