Dynamic variables
Dynamic Instructions
Instructions that change for each visitor, based on details your website passes in when a call starts.
What they do
Your avatar already knows your business from its Business Brain. Dynamic Instructions add what it should know about this visitor: their name, their membership plan, whether they have an order in progress. Your website passes those details in (they're called dynamic variables), and your instructions decide what the avatar does with them.
You'll find them in the console: open your agent's Brain, then the Dynamic Instructions tab. Type straight into the box and press Save; the rules and ready-made examples are right below it, each with an Insert button.
Where the details come from
Your website passes them when a visitor starts a call. With the floating widget, it's one line next to the widget snippet, for example:
SelviaAI.identify({ client_name: "John", subscription_plan: "Gold" });See Pass them from your website for every way to do it, including a Shopify snippet you can paste yourself. The names you use there (client_name, subscription_plan) are the names you use here, letter for letter.
The basics
Write instructions the way you would anywhere else, and put a detail in double braces. This line greets the visitor by name, or asks for it when the website didn't pass one:
{{client_name ? "The visitor's name is " + client_name + ". Greet them by name." : "You don't know the visitor's name yet; ask for it."}}For a visitor your website knows as John, the avatar is told:
The visitor's name is John. Greet them by name.For a visitor with no name passed, it is told:
You don't know the visitor's name yet; ask for it.Cheat sheet
| Write | Means |
|---|---|
{{client_name}} | The value, or nothing if it wasn't passed. |
{{client_name || "there"}} | The value, or a default when it's missing. |
{{client_name ? "…" : "…"}} | If it was passed, the first text; otherwise the second. |
{{subscription_plan == "Gold" ? "…" : "…"}} | Equals. Text compares ignore upper/lower case. Use != for "not equal". |
{{orders >= 10 ? "…" : ""}} | Numbers: > < >= <= |
{{vip && orders > 5 ? "…" : "…"}} | And: && or the word and. Or: || or or. Not: ! or not. Use ( ) to group. |
{{"Order " + order_number}} | Join text and values with +. |
{{avatar_name}}, {{business_name}} | Always available, no website needed. |
Good to know
- •A detail that is missing, empty,
0orfalsecounts as “not passed”. - •The name must match what your app or website sends, letter for letter:
client_nameis notclientNameorname. - •Upper and lower case don't matter:
{{Plan}}and{{plan}}are the same. - •Text goes in quotes. Straight or curly quotes both work, so text pasted from a document is fine.
- •A placeholder that doesn't make sense (say,
=instead of==) is pointed out when you save, with the reason. Nothing broken ever reaches a call. - •Double braces only work in Dynamic Instructions. Anywhere else in the Brain they're plain text.
Examples
By plan, every case covered
{{subscription_plan == "Platinum" ? "They are on Platinum: offer priority support." : subscription_plan == "Gold" ? "They are on Gold: mention what Platinum adds." : "You don't know their plan; don't guess it."}}Regular customer
{{orders >= 10 ? "They are a regular customer; thank them for coming back." : ""}}
{{orders == 0 ? "This is their first time; briefly explain how things work." : ""}}By page
{{page_url == "/pricing" ? "They are on the pricing page; focus on plans and prices." : ""}}Order question
{{order_number ? "They are asking about order " + order_number + "." : "If they ask about an order, ask for the order number."}}A friendly default
Always address the visitor as {{client_name || "there"}}.Tips
1. Always say what to do when a detail is missing
If an instruction only covers the case where a detail was passed, the avatar may fill the gap with a guess, like calling a Gold member “standard”. End every if/else with what to do otherwise: “you don't know their plan; don't guess it”, or “ask for it”.
2. Tracking and verification values don't belong here
Need a value only for tracking or verification, like a session or order ID? Don't use it in your instructions: the avatar doesn't need it, and only the values you use here ever reach it. Get it back in your app or server through a data handoff webhook instead, by clicking Add dynamic variable on the handoff's destination.
3. Never unlock anything from a value
Anyone can change what a web page sends, so never give a discount or share private details because of a value. If you have to rely on one, have your server sign it and turn on Require a verified visitor; see Signed values.
4. Preview before you save
Under your instructions, Try it with sample values shows exactly what the avatar would be told. Leave a value empty to check the “missing” case.