Using WebSockets provides the ability to stream responses back to a client in order to allow partial results for certain requests. This improves the perceived responsiveness of applications and offers a better user experience.

The WebSocket url is

Message Streaming

Stream a message response back to a client as it's being generated.

  • WebSocket URL:

  • Requirements:

    • accessToken: The existing access token for the session (see Authentication).

    • WebSocket client library (see npm package).

Setup and Connection

  1. Import to create a WebSocket connection.

import { io } from "";
  1. Initialize socket connection.

const options = {
  transportOptions: {
    polling: {
      extraHeaders: {
        "access-token": "<access-token>"

const socket = io("", options);

Receiving Messages

  • Listen for messages on the message event.

  • Filter messages by checking if the event data matches chatbot.responseGenerated.

  • Process the streamed message data.

socket.on("message", (eventData) => {
  if (eventData.event === "chatbot.responseGenerated") {
    console.log("Streaming message data:",;

Last updated