Web SDK
Show live captions
Show what the agent and the visitor say, as they say it.
wayloVoice.on('transcript', line => {
let row = document.getElementById(line.id);
if (!row) {
row = document.createElement('li');
row.id = line.id;
captions.append(row);
}
row.textContent = `${line.speaker}: ${line.text}`;
row.style.opacity = line.final ? '1' : '0.6';
});- Each
transcriptevent is one line:{ id, speaker: 'agent' | 'user', text, final }. - A line keeps its
idwhile it grows, andtextis the whole line so far. Replace the row with thatid; don't append. finalistrueonce the line stops changing.- If one line can't be read, an
errorevent withTRANSCRIPT_FAILEDarrives and the call goes on. - Captions are for display. The stored session is the record.