WebSocket API 2 VAPI
# support
Hey VAPI Team! @jayvapi.ai πŸš€ : I've got a bit of a unique situation here and could really use your insight. I'm working on integrating with a WebSocket API that listens to messages and provides replies (utilizing Bedrock Claude). My goal is to access this API and build an inbound phone client. I'm weighing two approaches and could use your guidance on which might be more efficient, easier, or faster: Direct Integration with Twilio: Adding the STT/TTS code directly to Twilio and managing WebSocket communication from there. Using VAPI as a Proxy: Leveraging VAPI, utilizing the serverUrl to act as a middleman between the WebSocket messages and the VAPI assistant. T Given my context – needing to access a WebSocket API for message exchanges – I'm uncertain which path to take. Specifically, if opting for the VAPI route, how should I begin, considering that the documentation on "handling serverUrl events with VAPI" doesn’t seem to cover passing and retrieving messages to/from a WebSocket API directly? Any recommendations on how to proceed? If VAPI can indeed serve as an effective proxy in this scenario, could you point me towards any starting steps, tips, or resources that could help bridge this gap? Thanks a ton for your help! Looking forward to making this work with your guidance. πŸ™Œ
Here is what I am using to connect to the websocket. I can retrieve and pass messages in this format ({"action":"sendMessage", "message": "hello"}) no problem, but what is now the fastest way to interact with my VAPI so that I don't have to build this directly in twilio ?
any idea @jayvapi.ai ?
thank you @nikhil will revert when I have a solution
@nikhil I deployed https://github.com/VapiAI/server-side-example-serverless-vercel on vercel but with the following error : "Error: api/webhook/.assistantRequest.ts(60,27): error TS2322: Type '{ name: string; model: { provider: string; model: string; temperature: number; messages: { role: string; content: string; }[]; functions: { name: string; description: string; parameters: { type: string; properties: { ...; }; required: string[]; }; }[]; }; voice: { ...; }; firstMessage: string; }' is not assignable to type 'Assistant'. The types of 'model.messages' are incompatible between these types. Type '{ role: string; content: string; }[]' is not assignable to type 'ChatCompletionMessageParam[]'. Type '{ role: string; content: string; }' is not assignable to type 'ChatCompletionMessageParam'. Property 'name' is missing in type '{ role: string; content: string; }' but required in type 'ChatCompletionFunctionMessageParam'." Any idea ?
ah it's possible there's typing issues
just use
as any
deployed @nikhil thanks