Some node properties support Handlebars. For example, the message text of the message node.
Handlebars lets you insert dynamic state data directly into a node’s message content. In practice, you write templates like {{text}} and the builder replaces them with values from the node’s state at runtime.
In this example:
"Cat")42)Those edges push the incoming values into the Message Node’s state, so the Message Node can render them immediately.
Put this directly into your Message Node:
Your text: {{text}}
Your number: {{number}}
After the edges have delivered the values, your Message Node state might look like this (some fields are created by the Message Node itself, others were pushed in):
{
"sent": true,
"arrived": true,
"text": "Cat",
"number": 42
}
You can inspect a node’s current state anytime by selecting the node in the builder. This is the easiest way to decide which variables are available for your templates (for example text, number, sent, arrived, etc.).
if / else{{#if text}}
You entered: {{text}}
{{else}}
Please provide a text value.
{{/if}}
Greater than
{{#if (gt number 10)}}
Big number: {{number}}
{{else}}
Small number: {{number}}
{{/if}}
Less than
{{#if (lt number 10)}}
Small number: {{number}}
{{else}}
Big number: {{number}}
{{/if}}
Equal
{{#if (eq text "Cat")}}
Meow. 🐾
{{else}}
You typed: {{text}}
{{/if}}
Useful for scoring, ages, levels, budgets, etc.:
{{#if (between number 1 5 true)}}
Rating accepted (1–5): {{number}}
{{else}}
Rating must be between 1 and 5.
{{/if}}
(In this example, true means “inclusive”, so 1 and 5 are allowed.)