Nothing found

Message variables

A variable is a placeholder in the text of a message. Each recipient gets their own value in its place — a name, a company name, an order number. That way you send one text to thousands of people and each of them reads a message written for them. Variables are written the same way in a campaign and in the API.

How to write a variable

A variable is a name in angle brackets, for example <first_name>. When the message is sent, it is replaced with the value you have for that recipient:

message text what the recipient gets
Hi <first_name>, your order is on its way. Hi Peter, your order is on its way.
  • The name has to match exactly. Letter case and spaces matter — neither <First_Name> nor < first_name > is replaced with the first_name value.
  • An empty value is the same as none. Empty text or nothing but spaces counts as a missing value — what happens then is described in When the value is missing.
Warning

Anything written as <something:something>, <something=number> or <something|filter> is always taken as a variable, even if you have no such variable, and it changes in the message that is sent. Writing it as &lt; does not help either. A lone < or <b> stays as it is.

When the value is missing

When you have no value for a recipient, the variable stays in the message literally — the recipient gets Hi <first_name>, …. You prevent that with a default value written after a colon:

notation what a recipient without a value gets
<first_name> literally <first_name>
<first_name:there> the fallback text there
<first_name:> nothing — the variable is left out

A recipient you do have a value for gets their own value in all three cases.

Tip

Only use a variable without a default value where you have data for every recipient. Otherwise add a fallback text, or let it be left out.

Filters

A filter adjusts the value that is filled in — it turns it into capital letters, trims spaces, makes a form of address out of a name or keeps an eye on its length. You write it after a vertical bar right after the variable name: <first_name|upper>. You can write several filters in a row and they are applied from left to right: <city|trim|capitalize> — more in Chaining filters.

Letter case

notation what the filter does example
<last_name|upper> turns the whole value into capital letters John Smith → JOHN SMITH
<last_name|lower> turns the whole value into small letters John Smith → john smith
<last_name|first_upper> capitalizes the first letter and leaves the rest unchanged john smith → John smith
<last_name|capitalize> starts each word with a capital letter, all other letters are small jOHN sMITH → John Smith

Text adjustments

notation what the filter does example
<last_name|trim> removes spaces at the start and at the end " John Smith " → "John Smith"
<last_name|ascii> removes diacritics Šťastný → Stastny
<city|webalize> turns the value into a form for a web address — without diacritics, in small letters, words joined with a hyphen Ústí nad Labem → usti-nad-labem
<company_name|word:1> picks one word by its position; when the value does not have that many words, nothing is filled in Kytary Novák → Kytary
<company_name|initial> initials — the first letter of each word, capitalized and followed by a full stop Kytary Novák → K. N.

Name and form of address

Two filters work with Czech names: vocative creates the form of address in the Czech vocative case, and gender picks a text for a man or for a woman based on the name. They follow the same rules as the <first_name_vokativ> and <last_name_vokativ> variables — how the vocative is created is described in Czech vocative.

notation what the filter does example
<first_name|vocative> turns each word of the value into the vocative Petr Novák → Petře Nováku
<first_name|gender:Milý,Milá> fills in the first text for a male name and the second for a female name — the value itself is not filled in Jana → Milá
  • Vocative from any variable. Unlike <first_name_vokativ>, the vocative filter can be used on any variable — for example on a full name kept in one field, or on a value you send in the API.
  • Gender and kind of name are recognised by the vocative filter itself from the ending. When it gets them wrong, you set them with parameters: the first is man or woman, the second first (first name) or last (last name), for example <last_name|vocative:woman,last>. The default value of both parameters, auto, leaves the decision to the filter.
  • Letter case. Each word in the vocative starts with a capital letter and the other letters are small: NOVÁK → Nováku.
  • The default value is declined too, so you write it in the nominative: a recipient without a name gets Zákazníku from <first_name:zákazník|vocative>.
  • The gender text replaces the value, so write the variable into the text twice: <first_name|gender:Milý,Milá> <first_name|vocative> gives Milý Petře or Milá Jano. The text can also be just the end of a word: Vážen<first_name|gender:ý pane,á paní> gives Vážený pane or Vážená paní. Both texts are required but may be empty; they must not contain <, >, | or a comma.
  • Without a name, the gender is decided from the default value — <first_name:zákazníku|gender:Milý,Milá> gives Milý to a recipient without a name. An empty default value always gives the text for a man.
Warning

Both filters follow the rules of Czech, no matter where the name comes from. The English name John gets the form Johne. Use them only in messages for Czech recipients, and check the result for unusual names with a test message.

Length limit

Filters with a number keep an eye on the maximum number of characters the value may have. They come in handy for long values such as a company name or an address, which would otherwise stretch the message into another SMS part. The filter decides what happens to a longer value:

notation what happens to a longer value “Kytary Novák” with a limit of 8
<company_name|cut:8> cut to the limit — at whole words where possible Kytary
<company_name|truncate:8> cut and completed with ..., fitting within the limit together Kytar...
<company_name|ellipsis:8> replaced with (...) (...)
<company_name|empty:8> left out nothing
<company_name:your company|fallback:8> replaced with the default value of the variable; when it has none, left out your company

A value that fits within the limit is inserted in full.

With truncate, ellipsis and fallback you can write your own text after a comma, which is used instead of the default one:

notation “Kytary Novák” with a limit of 8
<company_name|truncate:8,…> Kytary…
<company_name|ellipsis:8,your company> your company
<company_name|fallback:8,your company> your company

Your own text must not contain <, >, | or a comma. Empty text (truncate:8,) cuts the value without a suffix.

Chaining filters

You can combine filters freely — just write them one after another, each after its own vertical bar. They are applied in turn from left to right, and each filter gets the result of the one before it. That way you can combine a length limit with a change of letter case and with trimming spaces.

notation contact value what the recipient gets
<last_name|lower|first_upper> SMITH Smith
<city|trim|capitalize> " new york " New York
<company_name|trim|truncate:8,…|upper> " Kytary Novák " KYTARY…
<first_name|word:1|vocative> Petr Pavel Petře

In the third example, trim first removes the spaces, truncate:8,… cuts the value down to Kytary… and upper finally turns it into capital letters.

  • Order matters. The same filters in a different order give a different result. For the value " Ústí nad Labem ", <city|trim|cut:4> gives Ústí, whereas <city|cut:4|trim> first cuts the value down to the leading spaces and then trims them — nothing is left.
  • The default value goes before the filters, and the whole chain adjusts it too: a recipient without a first name gets THERE from <first_name:there|trim|upper>.
  • Each occurrence of a variable has its own filters. You can use one variable several times in the text, each time differently: from Hi <first_name|first_upper>, <first_name|upper> a recipient with the value john gets Hi John, JOHN.
  • In the campaign editor the chain follows the order of the filters in the variable dialog, and you change it by dragging. Each filter can be used there once.
Tip

Put trim before the filters that limit length. Otherwise the leading spaces count towards the limit too: from the value " Kytary Novák ", <company_name|cut:8> makes just " Kytary", whereas <company_name|trim|cut:8> gives Kytary.

What to watch out for

Write the filter name in small letters and without spaces, and the number in digits only.

Important

Neither a filter nor a limit stops a variable without a value from staying in the text. A recipient you have no value for gets <company_name> literally from <company_name|cut:8>. If you want a fallback text, write it after a colon before the filters: <company_name:your company|cut:8>.

Warning

A typo in a filter breaks the variable. An unknown filter or a missing number — <first_name|bold>, <first_name|cut> — means the notation stops being a variable and stays in the text literally, even for recipients who do have a first name. When the variable has a default value, the faulty filter becomes part of the fallback text: <first_name:there|Upper> fills in the first name, or there|Upper.

Deprecated notation with an equals sign

Length used to be limited with a shortcut: the limit was written after an equals sign, followed by a letter that set what happens to a longer value. This notation is deprecated — use filters in new messages. Messages that contain it keep working, and the campaign editor rewrites it to a filter.

deprecated notation replace with the filter
<company_name=8> or <company_name=8c> <company_name|cut:8>
<company_name=8t> <company_name|truncate:8>
<company_name=8s> <company_name|ellipsis:8>
<company_name=8e> <company_name|empty:8>
<company_name:your company=8d> <company_name:your company|fallback:8>

The shortcut is applied as the first filter, even when more filters follow it: <company_name=8|upper> is the same as <company_name|cut:8|upper>.

Variables in a campaign

A campaign takes the values from the contacts you add to it — from the address book, from a file import and from numbers entered by hand.

  1. Add the recipients first. The variable menu only shows fields that at least one recipient of the campaign has filled in. Without recipients it is empty.
  2. In the text editor, click the Add variable icon, or just type @. Typing a name narrows the menu down.
  3. Pick the variable. For each one you can see what percentage of recipients have data for it.

The variable shows up in the text as a tag with the field name, and its colour tells you how you are doing with the data:

  • no highlight — every recipient has the data, or a default value is set,
  • warning — 30 to 99 % of recipients have the data,
  • error — fewer than 30 % of recipients have the data, or no such field exists.

Click the tag to see a summary of the variable, including its active filters in the order they are applied, and edit it from there:

  • When the value is missing — add a fallback text, let the variable be left out, or keep it in the text.
  • Filters — add them one by one from a menu divided into letter case, text adjustments, name and form of address, and length. For filters with a parameter you fill in a number or a text, or pick an option. You change the order by dragging the handle — filters are applied from top to bottom — and delete a filter you do not need. A sample value shows what the filter does.

The editor saves the variable in the same notation described in When the value is missing and Filters, for example <company_name:your company|trim|cut:8>. An older shortcut with an equals sign is rewritten to a filter along the way.

Which fields you can use

variable what it holds
<first_name>, <last_name> first name and last name
<first_name_vokativ>, <last_name_vokativ> first name and last name in the Czech vocative case — filled in automatically, see Czech vocative
<title_before>, <title_after> title before and after the name
<company_name> company name
<company_number>, <company_vat> company number and VAT number
<email> email
<url> web address
<street1>, <street2>, <city>, <zip>, <state>, <country> address — street, city, ZIP code, state, country
<phone_mobile> phone number
<note> note
<custom_field_0> to <custom_field_9> custom fields

When you import from a file, you map each column to one of these fields. A column that none of them fits — an order number, a discount amount — goes to a custom field, and in the text you then use, for example, <custom_field_0>.

Channels, length and preview

  • Channels. Variables work in the message text of SMS, Viber and RCS, and for RCS in the title too.
  • Length and price. The character counter in the editor counts with the values of the contact selected in the preview. Each recipient may have values of a different length, though — so the number of SMS parts and the price are calculated for each recipient separately, after the values are filled in.
  • Unicode. Diacritics from a filled-in value switch the SMS to Unicode only when you have it enabled in the text settings.
  • Preview. Both the message preview and Send test message fill in the values of the contact selected in the preview — so you see how the text turns out before it is sent. The vocative and gender filters are the exception: the preview in the editor does not decline the name, it only marks it with 🗣️, and for gender it shows both texts, for example Milý/Milá. The character counter counts with these forms too. You see the actual result in a test message.

Variables in the API

In the API you send the values right in the request, in the variables parameter: an object whose key is the variable name and whose value is what should be filled in. The text uses the same notation, including default values and filters.

{ "number": "420777777777", "text": "Hi <first_name:there>, order <order> is on its way.", "variables": {"first_name": "Peter", "order": "12345"} }

The recipient gets Hi Peter, order 12345 is on its way. You can name a variable however you like — <order> in the example is not a contact field, just a key from variables.

Where the variables go

API where variables goes
Advanced API – transactional with the whole message; in version 2.0 also with each number in number separately — values with the number take precedence
Advanced API – promotional with each number in number separately; variables for the whole message is not used
Advanced API – address book groups not sent — the fields of the address book contacts are filled in, with the same names as in a campaign
Integration API with each message

What values to send

  • Text or a number. Numbers are filled in as they are (12 → 12).
  • null, false and empty text count as a missing value — the default value applies, otherwise the variable stays in the text literally.
  • An array or an object as a value is not accepted by the Advanced API, which returns the error invalid_input_parameters.
  • Extra keys that are not in the text are ignored.
  • Vocative case. From first_name and last_name the Advanced API works out first_name_vokativ and last_name_vokativ by itself — it overwrites your own values of these two keys. The Integration API does not work out the vocative. How it works is described in Czech vocative.

Channels and length

channel where variables are filled in
SMS text
Viber text, button caption and link
RCS text, card title and description
Voice text

The number of SMS parts and the price are both calculated from the text after the values are filled in. Diacritics from a filled-in value switch the SMS to Unicode only with "unicode": true. Viber, RCS and WhatsApp text that grows beyond the channel limit after the values are filled in (Viber 1,000 characters, RCS and WhatsApp 5,000) is cut short.

Note

E-shop plugins have their own set of variables, for example <customer_firstname>. They are described in Customer SMS.

Was this page helpful?