Docs
On this page
reference2 min readApplication: Platform

Websocket

Websocket methods that send messages from a server script to signed-in users' browsers, for example to drive a progress dialog.

Websocket sends a message from a server script to the browsers of signed-in users. The browser delivers it on a topic of its message bus, where a component such as the progress dialog listens. Websocket is a global object in server scripts, such as script libraries, jobs and system controllers.

Get an instance

Call the methods on the global object.

Websocket.sendMessage("example.topic", { text: "Done" });

Methods

A message reaches every browser session of the user. A user who is not signed in receives nothing, and nothing is queued.

Method Returns Description Since
sendMessage(topic: string, message: any) nothing Sends the message on the topic to the user the script runs as. 1.11
sendMessage(topic: string, message: any, responseTo: string) nothing As above, marked as the response to the request ID in responseTo. 1.11
sendUserMessage(userID: string, topic: string, message: any) nothing Sends the message on the topic to the user with this ID. 1.11
sendUserMessage(userID: string, topic: string, message: any, responseTo: string) nothing As above, with a request ID. 1.11
sendGlobalBroadcast(topic: string, message: any) nothing Sends the message on the topic to every signed-in user. 1.11

The sendApi variants address a named browser API instead of the message bus: sendApiMessage(api, topic, message), sendApiUserMessage(userID, api, topic, message) and sendApiGlobalBroadcast(api, topic, message). The first two also take a responseTo argument. Since 1.11.

Progress dialog messages

The progress dialog listens on the topic it was opened with. A message for it can carry these keys.

Key Type Description
percentage number Progress from 0 to 100.
message.text string The status line under the bar.
message.type string The style of the status line, for example success.
title string The dialog title.
complete boolean true marks the job as finished. A percentage of 100 or more does the same.

A client script opens the dialog with Navigate.progressDialog, giving a title, the topic, autoClose and a closeCallback.

Examples

Report progress to the current user

This server script reports progress while it summarises a record, for example while an AI prompt runs. The topic name is an example.

Servicely Script

const topic = "incident.ai_summarisation.progress.update";

function sendProgressUpdate(text, percentage) {
    Websocket.sendMessage(topic, {
        message: { text: text, type: "success" },
        percentage: percentage
    });
}

sendProgressUpdate("Summarising incident...", 25);

Response

The progress dialog open on this topic
shows 25% and "Summarising incident...".

Open the dialog from a client script

The shipped table operations open the dialog this way. The topic comes back from the controller that starts the job.

Navigate.progressDialog({
    title: "Summarising incident",
    topic: response.data.topic,
    autoClose: false,
    closeCallback: function () {
        Navigate.reload();
    }
});
Last updated 3 December 2026commit 6777698daac5Chris Jones
Back to top