Building a custom chat UI using the WebSocket-based Guest API instead of the default widget. The connection drops after 30 seconds of inactivity and I’m not sure how to handle the reconnect logic properly. Here is my basic connection setup:
const ws = new WebSocket('wss://api.mypurecloud.com/api/v2/guest/sessions/chat');
ws.onopen = () => console.log('Connected');
ws.onclose = () => console.log('Disconnected');
The onclose event triggers but the subsequent reconnect attempt fails with a 401 Unauthorized. How do I manage the session token refresh during the reconnection?