What goes inside the braces
Everything between {{ and }} is an expression. The simplest one is a field. It can also be a sum, a function that shapes a number, or a value with a fallback, and these combine.
The examples on this page use the event below. The text after each arrow is what the message shows.
{
"event": {
"token_symbol": "USDC",
"value_decimal": "7000000.0001",
"price_usd": "0.9998",
"change": "-12.345",
"fee": "0",
"memo": ""
}
}Fallbacks
Write two bars after a value, then what to use when the value is not there. The fallback can be text in double quotes, a number, or another field.
A fallback is used when the field does not exist on this event, when it is empty or only spaces, or when a calculation on it cannot be done. It is not used for 0 or false: a fee of zero stays 0.
Text needs quotes. Without them the words are read as a field name, so {{ event.memo || none }} looks for a field called none and shows nothing. Use straight quotes; the curly quotes a document editor inserts are not accepted.
Fallbacks chain from left to right, and the first value that exists is used.
A fallback hides a misspelt field name: the message shows the fallback and nothing warns you. Check the name against the field picker before you add one.
{{ event.token_name || "an unnamed token" }} → an unnamed token
{{ event.memo || "no memo" }} → no memo
{{ event.token_name || event.token_symbol }} → USDC
{{ event.nickname || event.token_name || "unknown" }} → unknown
{{ event.fee || "free" }} → 0Arithmetic
Add, subtract, multiply and divide with + - * /. Multiplication and division are done first, and brackets change the order. A minus in front of a value negates it.
Results are exact decimals, so a large token amount keeps every digit. Division keeps 18 decimal places and drops the rest.
Both sides must be numbers. Text that is not a number, or a division by zero, has no result: the value shows as empty and is listed under the preview, unless you give it a fallback.
{{ event.value_decimal * event.price_usd }} → 6998600.00009998
{{ event.value_decimal / 1000000 }} → 7.0000000001
{{ (event.value_decimal - 1000000) / 2 }} → 3000000.00005
{{ 1 / 3 }} → 0.333333333333333333
{{ event.value_decimal / event.fee || "n/a" }} → n/aRound and format a number
format writes a number the way people read money: commas between thousands and a fixed number of decimals. format(value, 2) gives two decimals, and so does format(value).
compact writes a large number the short way, for a headline: 80000000 becomes 80M. K is thousands, M millions, B billions and T trillions. It keeps up to two decimals and drops the zeros at the end, so 84560000 is 84.56M. Give a second input for fewer or more: compact(value, 0) gives 85M. A number under a thousand is only rounded.
round, floor and ceil cut a number to the decimals you ask for, without commas. Leave the second input out for a whole number. round goes to the nearest value, and a half goes away from zero. floor always goes down and ceil always goes up. abs removes the minus sign.
round, floor and ceil do not pad: a result that ends in zeros is written without them. Use format when every message should show the same number of decimals.
The number of decimals is a whole number from 0 to 18. format and compact produce text, so do the arithmetic inside them, not on the result. The other four produce numbers and can go into a further sum.
A small token amount can vanish at two decimals: 0.00042 becomes 0.00. Ask for more decimals, or leave the value as it is.
{{ format(event.value_decimal, 2) }} → 7,000,000.00
{{ format(event.value_decimal) }} → 7,000,000.00
{{ format(event.value_decimal, 0) }} → 7,000,000
{{ format(event.value_decimal * event.price_usd, 2) }} → 6,998,600.00
{{ format(0.00042, 2) }} → 0.00
{{ compact(event.value_decimal) }} → 7M
{{ compact(event.value_decimal * 12.08) }} → 84.56M
{{ compact(event.value_decimal * 12.08, 0) }} → 85M
{{ round(event.price_usd, 2) }} → 1
{{ round(event.change, 2) }} → -12.35
{{ floor(event.value_decimal) }} → 7000000
{{ ceil(event.value_decimal, 2) }} → 7000000.01
{{ abs(event.change) }} → 12.345
{{ round(event.value_decimal / 1000000, 1) + 1 }} → 8Put them together
A fallback after a function covers two cases at once: the field is missing, or it is there but is not a number.
Everything outside the braces is ordinary text, so a currency sign or a unit goes next to the expression, not inside it.
{{ event.token_symbol || "Token" }} transfer worth ${{ format(event.value_decimal * event.price_usd, 2) }} → USDC transfer worth $6,998,600.00
Worth {{ format(event.usd_value, 2) || "an unpriced amount" }} → Worth an unpriced amount
Memo: {{ event.memo || "none" }}, fee {{ format(event.fee, 2) }} → Memo: none, fee 0.00When a value shows as empty
An expression that cannot be worked out leaves a gap in the message, and the preview lists it under Unknown. A message with a gap is still sent, so clear the list before you enable the flow.
- The field does not exist on this example. Pick the path from the field picker, and look at more than one example: a field present on one event can be absent on the next.
- The fallback text has no quotes. Write || "none", not || none.
- The sum uses something that is not a number, or divides by zero. Add a fallback, or use a numeric field.
- The expression is written wrongly: a bracket or a quote was never closed, there is a single bar, a function name is misspelt, or the number of decimals is not a whole number from 0 to 18. A fallback does not cover this. Correct the expression.