Marcos Polanco
01/29/2025, 1:34 AMvariableValues
are not populating as expect. So three questions
1. what's wrong or un-supported about variableValues?
2. how can the snippet disappear if the user signs out?
3. if I gather more data from the customer, can this be passed to the assistant? perhaps by re-running it?
window.vapiSDK?.run({
apiKey: process.env.NEXT_PUBLIC_VAPI_KEY!,
assistant: process.env.NEXT_PUBLIC_VAPI_ASSISTANT!,
config: {
position: "fixed",
offset: "20px",
width: "50px",
height: "50px",
style: {
position: "fixed",
bottom: "20px",
right: "20px",
zIndex: 2147483647,
},
idle: {
color: "rgb(93, 254, 202)",
type: "pill",
title: "Let's get started!",
subtitle: "Dee is ready to go.",
icon: "https://o5yazhda3t.ufs.sh/f/__icon__.png",
},
},
assistant_overrides: {
variableValues: {
user_first_name:"Matthew",
program_title: "Engineering 2025",
},
},
});
Atlas
01/29/2025, 1:34 AMVapi
01/29/2025, 1:37 AMvariableValues
, it seems like you're using the correct structure to pass dynamic variables to the assistant. However, if the variableValues
are not populating as expected, it could be due to one of the following reasons:
- The variable names you are using (user_first_name
, program_title
) may not match the variable names defined within the assistant. Ensure that the variable names in variableValues
exactly match those expected by the assistant.
- There might be an issue with the assistant's configuration or the way it handles dynamic variables. Double-check the assistant's setup to ensure it's designed to accept and use dynamic variables.
2. To make the snippet disappear if the user signs out, you would need to implement a sign-out handler in your application that calls window.vapiSDK?.terminate()
when the user signs out. This will remove the assistant from the page.
3. Yes, you can pass more data to the assistant by re-running it with updated variableValues
. If you gather additional data from the customer, you can call window.vapiSDK?.run()
again with the new data included in the assistant_overrides
object.
If you need further assistance with the variableValues
not populating or any other issues, please ask support for more info on this.Vapi
01/29/2025, 1:37 AMVapi
01/29/2025, 1:39 AMMarcos Polanco
01/29/2025, 1:40 AMTypeError: window.vapiSDK?.terminate is not a function
also, are there docs for the web snippet other than https://docs.vapi.ai/examples/voice-widget?Shubham Bajaj
01/30/2025, 11:19 AM1. Before each call, retrieve the customer's previous call history from your database
2. Format this historical information as context that can be understood by the AI
3. Include this context in your API calls to the language model
Here's an example of how to structure your API request:
{
"model": {
"provider": "openai",
"model": "gpt-4",
"messages": [
{
"role": "system",
"content": "You are a voice assistant handling a call with a customer. Use the following previous call history to provide more personalized and contextual responses."
},
{
"role": "system",
"content": "Previous call history: [Include formatted call logs, outcomes, and important details from past interactions with this customer]"
}
]
}
}
This approach allows your voice agent to maintain continuity across multiple conversations and provide more personalized service by referencing past interactions and issues discussed with the customer.
Shubham Bajaj
01/30/2025, 11:20 AMterminate
I suggest joining office hours for live tech support. https://discord.gg/amX87g6K?event=1333839871458152598Shubham Bajaj
02/03/2025, 5:01 AM