Web Snippet for signed-in users
# support
m
I am presenting the web snippet only to signed-in users. It launches upon sign-in and runs similar to below, but the
variableValues
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?
Copy code
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",
        },
      },
    });
a
HeyMarcos Polanco Thank you for creating the ticket! A member of our team will reach out to you shortly.
v
@Marcos Polanco 1. Regarding
variableValues
, 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.
You can continue this conversation by mentioning me in the message.
Got it. Tagging @User for additional help.
m
TypeError: window.vapiSDK?.terminate is not a function
also, are there docs for the web snippet other than https://docs.vapi.ai/examples/voice-widget?
s
@Marcos Polanco 1. Would you be able to provide the call ID so that I may investigate the issue regarding variableValues not functioning properly? 2. Typically, the method of identifying whether a user is logged in depends on your auth-router, which subsequently determines the routing. Therefore, attending office hours would be beneficial for you in this regard. > How is it possible for the snippet to disappear when the user signs out? 3. Yes, this is indeed feasible as outlined below. Here's how to implement this:
Copy code
1. 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.
There is no such function named,
terminate
I suggest joining office hours for live tech support. https://discord.gg/amX87g6K?event=1333839871458152598
@Marcos Polanco because of no response closing this ticket.
4 Views