I have node.js agent running stt. How do I access ...
# ask-ai
c
I have node.js agent running stt. How do I access the full transcription on FE (meaning even before the current user joined)?
t
Thanks for reaching out, Jakub. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
You're asking how to show the full transcription on the frontend, including text produced before the user joined. Short answer: LiveKit does not replay past transcriptions to new participants automatically. To provide pre-join transcripts you must surface the agent's stored history to the frontend. Options you can implement (recommended order): 1) Expose full transcript from the agent (recommended) • Have your Node.js agent read
session.history
(which contains prior transcriptions) or your persistent store. • Add a REST or WebSocket endpoint that returns the full transcript (or a range). • On FE, fetch that endpoint immediately after authentication and render the returned transcript, then subscribe to live
lk.transcription
updates via
room.registerTextStreamHandler
to append new lines. 2) Replay past transcriptions into the room (advanced) • Agent republishes historical transcription messages onto the
lk.transcription
text stream when a new participant joins. • Tag replayed messages (e.g., attribute
replay=true
) so the frontend can display them as historical. 3) Post-session reports (if only needed after session) • Use
make_session_report()
or session reporting to retrieve the full transcript after the session ends. If you want, I can: • Provide a concise Node.js example for a REST endpoint that returns
session.history
. • Show the exact FE code to fetch that endpoint and wire
room.registerTextStreamHandler
for live updates. Which example would you like? Sources: Text and transcriptions | LiveKit docs | Observability data hooks | LiveKit docs
c
agent cannot publish a rest endpoint (we are running livekit cloud). It should probably post it in a different way
t
You're right — if the agent running in LiveKit Cloud can't host a REST endpoint, you should push the transcript out through LiveKit features instead. You're asking for alternatives to deliver pre-join transcripts to the FE; here are practical options and a quick question to pick the best path. Options to deliver prior transcriptions from a cloud-hosted agent • Replay to the text stream: have the agent publish past transcription entries onto the
lk.transcription
text stream (or a custom text topic) when a new participant joins. Tag replayed messages (e.g., attribute
replay=true
) so the FE can distinguish history from live updates. • Send a summary via data messages: use
room.localParticipant.sendText()
(or other data message APIs) to push a full transcript or summary to connected clients on a custom topic like
transcript-full
. • Egress / storage export: use LiveKit Egress to write the full transcript (or session report) to cloud storage (S3/GCS) and share the storage URL with the FE. This is best if you only need the complete transcript after or near the end of the session. • Agent-side push to your backend (if available): if you have any external backend you control, the agent can post history to that backend, and the FE can fetch it there. Quick clarification to recommend exact steps Do you need transcripts delivered in real time to users who join mid-session, or is it acceptable to provide the full transcript only after/near session end? Sources: Text and transcriptions | LiveKit docs | Observability data hooks | LiveKit docs | Sending text | LiveKit docs | Agent insights in LiveKit Cloud | LiveKit docs | Agents (Node.js) | livekit/livekit_composite | DeepWiki
c
• Replay to the text stream: have the agent publish past transcription entries onto the
lk.transcription
text stream (or a custom text topic) when a new participant joins. Tag replayed messages (e.g., attribute
replay=true
) so the FE can distinguish history from live updates.
t
You're on the right track. Below is a concise, practical Node.js + frontend pattern to replay past transcriptions to a joining participant by publishing them as a text stream and tagging them with
replay=true
. It uses a custom topic so you don't interfere with live
lk.transcription
. Server / Agent (Node.js) 1. Store transcripts as they arrive:
Copy code
const transcriptHistory: Array<{text: string, meta?: any}> = [];

session.on(voice.AgentSessionEventTypes.ConversationItemAdded, (event) => {
  const txt = event.item.textContent;
  if (txt) transcriptHistory.push({ text: txt, meta: { role: event.item.role } });
});
1. When a participant joins, create a text writer targeted to that identity and publish history with attributes:
Copy code
const REPLAY_TOPIC = 'lk.transcription_replay';

ctx.room.on('participant_joined', async (participant) => {
  const writer = await ctx.room.localParticipant.streamText({
    topic: REPLAY_TOPIC,
    attributes: { replay: 'true' },
    destinationIdentities: [participant.identity],
  });

  for (const entry of transcriptHistory) {
    await writer.write(entry.text);
  }

  await writer.close();
});
Notes: • Use
destinationIdentities
so only the joining participant receives the replay. • Add per-message metadata if you need timestamps/roles: either include in the text (JSON) or maintain parallel attributes if supported. Frontend 1. Register handler for replay topic and for live transcriptions:
Copy code
room.registerTextStreamHandler('lk.transcription_replay', async (reader, participantInfo) => {
  const msg = await reader.readAll();
  // treat as historical because attribute replay=true is set on the stream
  displayTranscript({ text: msg, replay: true });
});

room.registerTextStreamHandler('lk.transcription', async (reader, participantInfo) => {
  const msg = await reader.readAll();
  displayTranscript({ text: msg, replay: false });
});
1. If you need to mark boundary between replayed history and live updates, show a divider after replayed items or use the
replay
flag. Variations / Considerations • If you need per-message attributes (timestamps/roles), send JSON strings and parse on FE. • If many messages/large history, paginate replay (send chunks) to avoid UI freeze. • Use a custom topic name to avoid confusion with live transcription consumers. • If you want replays to be visible to multiple existing participants, omit
destinationIdentities
or include more identities. If you want, I can: • Show how to include timestamps/role metadata in the messages, • Provide a chunked replay example (pagination) for very large histories, • Or adapt this to send replays on the live
lk.transcription
topic and include a
replay
attribute instead. Which would you prefer? Sources: Sending text | LiveKit docs