Real-Time Transcription Stream

Stream and display live speech-to-text transcriptions from active sessions using the Nextiva Web SDK.

Overview

The Nextiva SDK supports real-time transcription events, enabling you to receive, process, and display transcribed speech from live sessions.

There are two key event types:

  • LiveTranscriptionNotification – emitted in real time as audio is transcribed.
  • LiveTranscriptionCompletedNotification – emitted after the transcription session ends.

These events are delivered over WebSocket and can be subscribed to using the SDK.

Prerequisites

Before using transcription notifications:

  • SDK configuration
    • Ensure you have a valid SDK configuration.
  • Login & initialization
    • Log in and call init() after a successful login.
  • Transcription settings
    • Transcription must be enabled in the Nextiva platform.

Install the SDK

Event flow: LiveTranscriptionNotification

  1. Server sends WebSocket message

The server pushes real-time transcription via WebSocket in the following format:

{
  "name": "LiveTranscriptionNotification",
  "createdAt": 1634764567,
  "id": "unique-notification-id",
  "workitemId": "workitem-123",
  "result": "SUCCESS",
  "message": {
    // Transcribed text or message object
  }
}
  1. SDK processes the message
    • The SDK parses the WebSocket message.
    • It updates the internal work item cache with new transcription data.
    • It emits the parsed event to the events$ stream.

Subscribing to Transcription Events

You can subscribe to transcription events via the SDK’s observable event stream: sdk.events$.

Using observable (recommended for flexibility)

import { EventTypes, ofType } from '@nextiva/ncx-web-sdk';

// Get the SDK instance (assuming you have initialized it)
const sdk = /* your SDK instance */;

sdk.events$
  .pipe(ofType(EventTypes.LiveTranscriptionNotification))
  .subscribe((event) => {
    const data = event.getProperties();
    console.log('Transcription received:', data);
  });

TypeScript-safe subscription

import type {
  LiveTranscriptionNotificationData,
  NotificationEvent
} from '@nextiva/ncx-web-sdk';
import { EventTypes, ofType } from '@nextiva/ncx-web-sdk';

sdk.events$
  .pipe(ofType(EventTypes.LiveTranscriptionNotification))
  .subscribe((event: NotificationEvent<LiveTranscriptionNotificationData>) => {
    console.log(event.data);
  });

Sample response

{
  "id": "4d42d7f2-e7af-40d6-a662-f7eb40851102",
  "name": "LiveTranscriptionNotification",
  "result": "SUCCESS",
  "workitemId": "52d9a90c-d246-4e6a-bb10-28f79f53d16b",
  "message": {
    "filename": "",
    "transcript": {
      "createdAt": 1760630644931,
      "modifiedAt": 1760630700882,
      "objectType": "transcript",
      "id": "agent-transcription-51-2",
      "type": "call",
      "status": "ok",
      "startedAt": 51.2,
      "endedAt": 56.14,
      "content": "So this shows the messages going back and forth.",
      "contentType": "text/plain",
      "tone": "neutral"
    },
    "viewedBy": [],
    "fileContentSize": 0,
    "textMsg": "So this shows the messages going back and forth.",
    "id": "agent-transcription-51-2",
    "priority": false,
    "type": "USER",
    "fromId": "Derrick (NOT DIRK)",
    "fileContentType": "",
    "timestamp": 1760630700883
  },
  "createdAt": 1760630700883
}

Debugging tips

  • Ensure your WebSocket connection is active.
  • Verify the workitem ID is valid.

Related events

LiveTranscriptionCompletedNotification: Triggered when the transcription session ends. Subscribe similarly using EventTypes.LiveTranscriptionCompletedNotification.