Conditional dynamic variables
# support
a
Is it possible to have a conditional dynamic variable so you don't have to have two different assistants? For example, if the assistant was to greet the customer with "Hello, am I speaking with {{XYZ}}?" but if they don't know who it is then they say "Hello, whom am I speaking with?". For reference, I'm trying to not have to create two different assistants that do the same thing but might use dynamic variables in some spots.
v
You can continue this conversation by mentioning me in the message.
@andrew Yes, it is indeed possible to use conditional dynamic variables to tailor the assistant's greeting based on whether the customer's name is known or not. You can set up your assistant to use a dynamic variable for the customer's name and have a default value or a conditional statement that changes the greeting if the name is not provided. For example, you could configure the assistant to check if the
name
variable is set and use it in the greeting. If the
name
variable is not set, the assistant would default to a generic greeting. Here's a pseudo-code example of how you might set this up:
Copy code
if (name is provided) {
  greeting = "Hello, am I speaking with {{name}}?"
} else {
  greeting = "Hello, whom am I speaking with?"
}
When starting the call, you would pass the
assistantOverrides
with
variableValues
to the API or SDK. If you have the customer's name, you would include it; if not, you would omit it, and the assistant would use the default greeting. Here's how you might pass the variable when starting the call:
Copy code
{
  "variableValues": {
    "name": "John" // Only include this if the name is known
  }
}
If the name is not known, you would simply not include the
name
key in the
variableValues
, and the assistant would use the conditional logic to choose the appropriate greeting. This way, you can maintain a single assistant that adapts to the information available.
@Vapi Sweet. Have a great day!
@andrew Sweet. Have a great day!