Follow a call's transcript live
Summary
This guide opens the live transcript stream of a call, shows each line while the call runs, and
resumes the stream after a dropped connection. It covers streamLiveCallTranscript. It does not
cover the verified transcript of a finished call; see Calls and results.
Facts
Steps
Set CALL_ID to the id of the call, from the answer of createCall or createAgentSession, or
from listCalls. You can open the stream any time after the call is created: it waits for the call
to connect.
1. Open the stream and print each line
The sample keeps the newest payload of each segment_id and prints it. It also keeps the last
event id, for step 2.
Each transcript.message is one payload of one line. A customer line arrives when its speech
recognition is final. An agent line arrives as its words go to speech, then once more with its
final words. start_ms and end_ms are milliseconds from the start of the call recording. When
the call is over, transcript.end arrives with the call’s state, and the stream closes.
2. Resume after a dropped connection
Set LAST_EVENT_ID to the last id: value that step 1 printed.
The stream continues after the last line you received. Event IDs are opaque and bind the workspace and the call: send an ID only to the stream of the call that gave it.
Rules
- MUST show the newest payload of each
segment_id, and MUST NOT replace afinal: trueline with a laterfinal: falseone. - MUST treat a
segment_idofnullas a line of its own. - MUST reconnect with
Last-Event-IDwhen a connection drops or reaches 55 minutes. - MUST NOT treat the live lines as the call’s record. The last words of a call can be missing
from them when the call ends first. After the call, read the verified transcript with
getCallTranscriptorstreamCallTranscript. - MUST NOT treat comment frames as lines. They are heartbeats.
- The stream never starts work on the call.
Verify
After the call is over, read its verified transcript:
Expected output: the transcript items with speaker, text, start_ms and end_ms.