Voice Assistant From Website
# support
n
Currently we are using Vapi from the BE to trigger calls or return a dynamic assistant object when called. We want to add in an option to use a Vapi assistant from our website, but is there an option to do this dynamic assistant option in this way? Is there a way we could trigger it from the backend and stream the audio?
v
Yes, you can implement dynamic assistant selection on your website by fetching the assistant ID from your backend and passing it to the Vapi Web SDK, which handles audio streaming in the browser. Here’s a simple example:
Copy code
javascript
// Frontend: fetch dynamic assistant ID from your backend
const getAssistantId = async () => {
  const res = await fetch('/api/get-assistant-id');
  const { assistantId } = await res.json();
  return assistantId;
};

const assistantId = await getAssistantId();
vapi.start(assistantId); // Web SDK streams audio automatically
No need to stream audio from your backend—the Web SDK manages this for you in the browser. For more, see the [Web Snippet guide](https://docs.vapi.ai/assistants/examples/voice-widget). Source: - [Web Snippet guide](https://docs.vapi.ai/assistants/examples/voice-widget)
2 Views