Connect to the listenUrl via WebSocket to receive a real-time audio stream of the call without any interaction:
const WebSocket = require('ws');
let pcmBuffer = Buffer.alloc(0);
const ws = new WebSocket("wss://phone-call-websocket.sulus.ai/<call-id>/transport");
ws.on('open', () => console.log('WebSocket connection established'));
ws.on('message', (data, isBinary) => {
if (isBinary) {
pcmBuffer = Buffer.concat([pcmBuffer, data]);
} else {
console.log('Received message:', JSON.parse(data.toString()));
}
});
The listenUrl is a unidirectional, listen-only channel — it supplements the existing call without interfering with it.