How do I set the variables to pass on make?
# support
b
I want to set variables that will be passed on make using the tools. But I don't exactly know how to set the variables during the call.
@Vapi how do I explicitly assign a value to a variable in the prompt?
v
@binaryruel To explicitly assign a value to a variable in the prompt for use with VAPI, you would typically include the variable within double curly braces and assign it a value before starting the call. For example, if you have a template with a variable
{{userName}}
, you can set it like this:
Copy code
"Hello {{userName}}, how can I assist you today?"
And before making the call, you would replace
{{userName}}
with the actual user's name:
Copy code
"Hello John, how can I assist you today?"
This way, when the call is made, the prompt is personalized for the user named John. If you're setting this up in a system or script, you would replace
{{userName}}
with the appropriate value programmatically.
@binaryruel Certainly! When you want to pass variables to a tool using VAPI, you typically include the variables as parameters in the function call. The parameters are usually structured in a JSON-like format, where each variable is a key-value pair. For example, if you have a tool that requires a
user_id
and a
message
, you would call the tool and set the variables like this:
Copy code
json
{
  "user_id": "12345",
  "message": "Hello, this is your message!"
}
You would include this structure in the function call within the parameters section. If you can tell me which tool you're trying to use and what variables you need to set, I can help you construct the correct function call.
You can continue this conversation by mentioning me in the message.
b
@User How to set dynamically? for example, I want to let the AI ask for the patient status and assign it to a variable "patientStatus"?
s
Hey @binaryruel check this example https://gist.github.com/bajajcodes/ff0bc6e126d4956fb422d47a397abeff I believe it will answer all of your questions. If you still require further help do ping me then.