Sending Metadata in Web Snippet
# support
r
I am using web Snippet, to implement Vapi in my website. First, I am fetching all the assistants, then when the user clicks on any assistant, the request goes to the Vapi and the user can talk to it. but I want to send the userId of the user so that when Vapi calls the webhook, that particular userId is available to the webhook to fetch the data from the database. How can I do it? Currently, I am sending it like this : vapiInstance = vapiSDK.run({ apiKey: apiKey, assistant: agentId, metadata: { userId: userId }, config: buttonConfig, }); Can anyone tell me, It's urgent.
c
To send the
userId
to the webhook, you can use the
assistantOverrides
parameter when starting the Vapi instance. Include the
userId
in the
variableValues
object. Here's a quick example:
Copy code
javascript
vapiInstance = vapiSDK.run({
  apiKey: apiKey,
  assistant: assistant,
  config: buttonConfig,
  assistantOverrides: {
    variableValues: {
      userId: "yourUserIdHere"
    }
  }
});
This way, the
userId
will be available when Vapi calls the webhook. Let me know if you need more help.
3 Views