Advanced logic

Enabling Advanced logic allows you to write custom boolean expressions using MongoDB’s query and projection operators, giving you full flexibility over conditional rendering in your flow.

Instead of using a visual logic builder, you write logic directly in JSON format. Each answer variable maps to a field, and standard MongoDB query operators evaluate those fields.

Why JSON, not Drag-and-Drop?

While we may support a visual builder in the future, the JSON-based syntax is:

  • Powerful and expressive

  • Lightweight and easy to copy/paste

  • Flexible enough for most complex logic needs

Common patterns

Both conditions must be true$and

Enable an item only if both conditions are satisfied:

  • distance_to_office is less than or equal to 75

  • is_qualified is true

{
  "$and": [
    {
      "distance_to_office": {
        "$lte": 75
      }
    },
    {
      "is_qualified": true
    }
  ]
}

Read more about $and.

At least one condition is true - $or

Enable an item if either of the following is true:

  • is_parent is true

  • has_parent_consent is true

{
  "$or": [
    {
      "is_parent": true
    },
    {
      "has_parent_consent": true
    }
  ]
}

Read more about $or.

Answer is one of several values$in

Check if an answer matches any value from a list.

Enable if country is CA, MX, or US:

{
  "country": {
    "$in": [
      "CA",
      "MX",
      "US"
    ]
  }
}

Read more about $in.

Answer is not in a list of values — $nin

Check that an answer does not match any value from a list.

Enable if state is not NY or PA:

{
  "state": {
    "$nin": [
      "NY",
      "PA"
    ]
  }
}

Read more about $nin.

Answer is defined$exists

Enable if a variable has any value (even false):

{
  "income": {
    "$exists": true
  }
}

This mirrors the behavior of the Is defined simple logic operator.

Read more about $exists.

Last updated

Was this helpful?