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.
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({ name: "John", 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 (name, plan) are the names you use here.
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:
{{name ? "The visitor's name is " + 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 |
|---|---|
{{name}} | The value, or nothing if it wasn't passed. |
{{name || "there"}} | The value, or a default when it's missing. |
{{name ? "…" : "…"}} | If it was passed, the first text; otherwise the second. |
{{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_id}} | 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”. - •Names ignore upper and lower case:
{{Name}}and{{name}}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
Membership level, every case covered
{{plan ? "Their membership plan is " + plan + "." : "You don't know their plan; don't guess it."}}
{{plan == "Platinum" ? "Offer same-day priority service." : ""}}Returning 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." : ""}}Picking up an unfinished request
{{open_request ? "They have an unfinished request open. Offer to help them complete it." : ""}}Several cases in one line
{{plan == "Platinum" ? "Answer within the Platinum policy." : plan == "Gold" ? "Answer within the Gold policy." : "Answer within the standard policy."}}A friendly default
Always address the visitor as {{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. Keep reference numbers out of the conversation
Your website can pass things the avatar shouldn't read aloud, like a customer ID or a draft number. Only the details you use here reach the avatar. Everything passed is still available to your data handoffs, so an ID can travel back to your systems without ever being spoken.
3. Mark trusted details “Only when signed”
Details typed into a web page can be changed by the visitor. If a detail unlocks something, such as a plan with better terms, tick Only when signed next to it. The avatar then uses it only when your website's server signed it, and treats it as missing otherwise, so your “else” text applies. 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.