NickVapi
11/30/2024, 11:00 PMVapi
11/30/2024, 11:03 PM@vapi-ai/web
package is correctly installed in your project. You can check if the package is in your node_modules
directory or by running yarn list @vapi-ai/web
or npm list @vapi-ai/web
.
2. Verify that you are importing the Vapi class correctly at the top of your file. The import statement should look like this:
javascript
import Vapi from "@vapi-ai/web";
3. Ensure that there are no typos in your import statement and that the case of the letters matches exactly, as JavaScript imports are case-sensitive.
4. If you're using a module bundler or a build tool like Webpack, Babel, or TypeScript, make sure that it's configured correctly to handle ES6 imports.
5. If you're working in an environment that doesn't support ES6 imports, you might need to use the require
syntax instead:
javascript
const Vapi = require("@vapi-ai/web").default;
If you've checked all of the above and the issue persists, please provide more details about the error message you're receiving, and I'll be happy to help you further.Vapi
11/30/2024, 11:03 PMNickVapi
11/30/2024, 11:33 PMNickVapi
11/30/2024, 11:50 PMbryant
12/01/2024, 1:52 AMbryant
12/01/2024, 1:53 AMNickVapi
12/01/2024, 6:21 AMbryant
12/01/2024, 6:28 AMNickVapi
12/01/2024, 6:29 AMbryant
12/01/2024, 6:35 AMawait fetch(`https://api.vapi.ai/call/web`, {
method: 'POST',
headers: {
Authorization: `Bearer
${YOUR_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
assistantId: <your assistant id>
}),
});
NickVapi
12/01/2024, 7:18 AMNickVapi
12/01/2024, 2:04 PMNickVapi
12/02/2024, 12:34 PMShubham Bajaj
12/02/2024, 4:50 PMNickVapi
12/02/2024, 5:46 PMShubham Bajaj
12/03/2024, 2:32 PMShubham Bajaj
12/03/2024, 2:41 PMwindow is not defined
) happened because you tried running client-side code (Web SDK) in a Node.js environment. Client SDKs are built for browsers and depend on browser-specific objects like window
.
3. **Bryant's Suggestion**: He pointed you to the server SDK, but it doesn't support the interactive web call functionality you're looking for.
4. **API Call Attempt**: The fetch()
example you tried returned a "queued" call status because you're bypassing the Web SDK, but that approach doesn't handle the session management and WebSocket handshake required for web-based calls. That’s why the session ends abruptly.
### What Next?
To stick with web-based interactions, you must use the Web SDK.
You’ll need to ensure:
1. Your app is running in the browser.
2. The Web SDK is properly set up and connected to handle WebSocket interactions via the provided URLs (listenUrl
and controlUrl
) if required.
Let me know how else I can help.NickVapi
12/03/2024, 9:42 PMShubham Bajaj
12/04/2024, 7:24 PMNickVapi
12/07/2024, 7:12 PM