Dynamic variables

How dynamic variables work

Dynamic variables are details about the visitor that your website passes in when a call starts: their name, their plan, an order number. Your avatar uses them to greet the visitor by name and adapt to them, and they can come back to your systems with what the avatar collected.

How it works

Three parts, each with its own page:

What happensPage
1Your website passes details about the visitor when they start a call: their name, plan, an order number. These are called dynamic variables.Pass them from your website
2You tell the avatar what to do with them, in plain instructions, in your agent's Brain.Dynamic Instructions
3The details come back to your systems with what the avatar collected, through a data handoff.Webhooks

For details that unlock something, like a membership plan with better terms, your website can also prove they're genuine: see Signed values.

An example, end to end

1. The website passes the details

When John, a signed-in Platinum member, opens the avatar on the website:

SelviaAI.identify({ name: "John", plan: "Platinum", order_id: "A-1042" });

2. Dynamic Instructions use them

{{name ? "The visitor's name is " + name + ". Greet them by name." : "Ask for their name."}}
{{plan == "Platinum" ? "Offer same-day priority service." : ""}}

So for this call the avatar is told:

The visitor's name is John. Greet them by name.
Offer same-day priority service.

order_id isn't used in the instructions, so the avatar never sees it. It's kept for step 3.

3. The details come back with the answers

A data handoff's webhook sends the order number along with what the avatar collected:

{
  "order_id": "{{visitor.order_id}}",
  "request": "{{request_summary}}"
}

For the whole round trip with working server code (passing the ID, the webhook message, and updating the right record), see Example: pass an ID in, get it back.

Who does what

StepUsually done byWhere
Add the details next to the avatar on your websiteWhoever edits your website. On Shopify you can paste it yourself.Pass them from your website
Write what the avatar does with themYou, in the consoleDynamic Instructions
Sign details you need to trustYour developer, on your serverSigned values
Receive the details backYour developer, in your own systemWebhooks