We are building a custom agent desktop component using the Genesys Cloud Embeddable Client App SDK. The requirement is to listen for real-time conversation updates via the Notification API WebSocket. The goal is to trigger a screen pop when a new task arrives.
The code initializes the connection correctly. We get the access token from the SDK context. Then we open the WebSocket to wss://api.mypurecloud.com/api/v2/analytics/events. The handshake succeeds. But the connection stays in the ‘connecting’ state forever. No data events come through.
I’ve checked the browser console. No errors. The status code is 101 Switching Protocols. But the stream never starts. Here is the relevant snippet:
const ws = new WebSocket('wss://api.mypurecloud.com/api/v2/analytics/events');
ws.onopen = () => {
const sub = {
"id": "conv-sub-1",
"channel": "conversations",
"type": "subscribe"
};
ws.send(JSON.stringify(sub));
};
The subscription payload looks correct per the docs. Is there a specific scope needed for the token used in the WebSocket upgrade header? Or is the channel name wrong? The token has admin:conversation:view scope.
Any ideas why the stream hangs?