We’ve set up a Node.js service to consume streaming analytics events from Genesys Cloud and push them to a Kafka topic. The goal is to get real-time queue metrics without polling. We are using the @genesyscloud/node-sdk to handle authentication and then opening a raw WebSocket connection to the notification endpoint.
The connection establishes successfully. We see the connected event. But when we subscribe to the analytics:conversations:queues channel, we only get a few initial snapshots. After that, the stream goes silent. No updates come in even when we know calls are entering the queue.
Here is the relevant part of the consumer logic:
const GenesysCloudSdk = require('@genesyscloud/node-sdk');
const WebSocket = require('ws');
const client = new GenesysCloudSdk.PlatformClient();
const auth = new GenesysCloudSdk.AuthenticationApi();
async function startConsumer() {
const token = await auth.getOAuthToken('client_credentials', 'my-client-id', 'my-client-secret');
const accessToken = token.accessToken;
const wsUrl = `wss://api.mypurecloud.com/api/v2/analytics/events/ws?access_token=${accessToken}`;
const ws = new WebSocket(wsUrl);
ws.on('open', () => {
console.log('WebSocket Connected');
// Subscribe to queue analytics
const subscribeMsg = {
type: 'subscribe',
channel: 'analytics:conversations:queues',
filters: {
divisionId: 'my-division-id'
}
};
ws.send(JSON.stringify(subscribeMsg));
console.log('Sent subscribe message');
});
ws.on('message', (data) => {
const msg = JSON.parse(data);
console.log('Received event:', msg.type);
if (msg.type === 'event') {
// Push to Kafka
kafkaProducer.send({ topic: 'gc-queue-metrics', messages: [{ value: JSON.stringify(msg.payload) }] });
}
});
ws.on('close', () => {
console.log('WebSocket Closed');
});
}
The logs show:
WebSocket Connected
Sent subscribe message
Received event: connected
And then nothing. No analytics:conversations:queues events. We verified the division ID is correct. We also tried subscribing to conversation:call events and those work fine. It seems specific to the analytics queue channel.
Is there a specific header or query parameter required for analytics streams? Or maybe the filter syntax is wrong. The documentation is a bit sparse on the exact JSON structure for the subscribe payload when using raw WebSockets instead of the SDK helper methods.
We are in US/Pacific and running this on a local dev box first before moving to AWS. Any ideas why the analytics channel stays silent?