We are trying to build a custom chat UI because the default widget doesn’t fit our brand guidelines. I’m following the Guest API docs to connect via WebSocket instead of using the standard SDK. The initial HTTP handshake to /api/v2/guest/conversations/channels/webmessaging works fine and returns the wss:// URL.
The issue is when I try to upgrade to the WebSocket connection. I’m passing the access_token in the query string like this:
const ws = new WebSocket(`${wssUrl}?access_token=${token}`);
The connection opens briefly but then closes with a 1006 code. Looking at the network tab, the WebSocket upgrade request seems to be failing authentication. I’ve verified the token is valid for the webmessaging scope. Is there a specific header I need to send during the WebSocket upgrade phase? The docs aren’t super clear on this part.
I’ve also tried passing the token in the first JSON message after connection but that just results in a silent failure. Any pointers on how to handle the auth for the WS connection?