Documentation
Automation

Expression Language

Use expressions in builder text blocks, variables, and message templates.

The expression language is used for substitutions, text transformations, and simple conditions in builder blocks and message templates.

Expressions are written inside {...}.

Where Expressions Are Used

Expressions are available in two places:

  • builder blocks;
  • message templates.

Basic Syntax

Use an expression inside a text string when you want to insert a value:

Hello, {client.name}!

If a whole field contains only one expression, the full field value is taken from that expression:

{funnel.order_total}

When an expression is embedded inside normal text, its result is inserted into the final string.

Embedded expressions must return a simple value:

  • string
  • number
  • boolean
  • null

Rendering behavior:

  • null becomes an empty string;
  • true and false become the strings true and false;
  • an object or array inside a normal text template causes an error.

Available Variables

Message Templates

Message templates can use:

  • client.*
  • chat.*
  • operator.*
  • message.*

The same values are also available through sys.*:

  • sys.client.*
  • sys.chat.*
  • sys.operator.*
  • sys.message.*

Builder Blocks

Builder blocks use system variables through sys.*:

  • sys.client.*
  • sys.chat.*
  • sys.operator.*
  • sys.message.*

Builder blocks can also use:

  • funnel.<key>
  • env.<KEY>

System Variables

Client

  • client.name
  • client.id
  • client.external_id
  • client.phone
  • client.comment

Chat

  • chat.id
  • chat.status
  • chat.channel

Operator

  • operator.id

Message

  • message.id
  • message.text
  • message.type
  • message.direction

Client Custom Fields

Client custom fields are available as:

client.customfield.<field_key>

In builder blocks, the common form is:

sys.client.customfield.<field_key>

Funnel Variables

Use funnel variables for values collected or calculated inside the funnel:

funnel.order_total
funnel.stage_code
funnel.is_repeat_client

Funnel variable keys must:

  • be lowercase;
  • start with a letter;
  • contain only letters, digits, and _.

Environment Variables

Use environment variables for configured values:

env.API_URL
env.COUNTRY_CODE

Environment variable names must:

  • be uppercase;
  • start with a letter;
  • contain only letters, digits, and _.

Functions

Lowercase

Signature: lowercase(value): string

Converts a string to lowercase.

lowercase(message.text)

Uppercase

Signature: uppercase(value): string

Converts a string to uppercase.

uppercase(client.name)

Length

Signature: length(value): number

Returns the string length.

length(message.text)

Replace

Signature: replace(value, search, replace): string

Replaces all occurrences of a string.

replace(message.text, "hello", "hi")

Regex Replace

Signature: regex_replace(value, pattern, replacement): string

Replaces text with a regular expression.

regex_replace(message.text, '#^/start\\s+#', '')

If the regular expression is invalid, the expression returns an error.

Base64

Signature: base64(value): string

Encodes a string as Base64.

base64(client.id)

Operators

Supported operators:

  • and
  • or
  • not
  • ==
  • !=
  • >
  • >=
  • <
  • <=
  • +
  • -
  • *
  • /
  • %
  • ~

Use ~ for string concatenation.

Conditions

Conditions can be used inside expressions to calculate the required value.

Supported comparisons and logical operators:

  • ==
  • !=
  • >
  • >=
  • <
  • <=
  • and
  • or
  • not

Examples:

sys.client.customfield.tariff == "premium" and sys.chat.channel == "telegram"
length(message.text) > 10
sys.chat.channel == "telegram" ? "TG client" : "Other client"

Conditions also support:

  • strings in single or double quotes;
  • numbers;
  • true, false, null;
  • arrays: [1, 2, 3];
  • in;
  • matches;
  • ternary expressions: condition ? a : b;
  • null coalescing: a ?? b.

On this page