On this page
Sommatic Docs
Open portal

WebSocket Client

Send message to WebSocket Server.

View as Markdown
Open in
Input and output Available io.websocket Version 1.0.0 Execution: async

Opens a WebSocket connection, sends one message and either closes at once or waits for the first message back.

How it works

  1. Resolves the config. connection_id, message and waitForResponse (default false) fall back to the same keys of the incoming payload; connection_id and message are required.
  2. Resolves the credential: the URL is config.url; when the secret has token, the handshake sends Authorization: Bearer <token>.
  3. Opens the connection and sends message as soon as it is open.
  4. Without waitForResponse, closes and returns { result: "sent" }. With it, waits for the first incoming message, closes and returns it as text in result.

In a workflow

The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.

{
  "node_id": "node-push-event",
  "label": "Push event",
  "operator_slug": "io.websocket",
  "operator_version": "1.0.0",
  "config": {
    "connection_id": "pi-credential-xxxx",
    "message": "{{ JSON.stringify($json.event) }}",
    "waitForResponse": true
  }
}

Configuration

connection_id string Required

Credential for the WebSocket endpoint. Accepts credentials of type `api-key`, `basic-auth`, or `object` (custom handshake headers).

message string Required

Message to send

waitForResponse boolean Optional

Default: false

Behaviour in the code

What the implementation does with these keys beyond what the schema says.

connection_id
The URL comes from the credential config url; only token is read from the secret. api-key and basic-auth secrets add no handshake header. A value starting with ws:// or wss:// is used as the URL itself, without authentication.
message
Must be a string. To send JSON, build the string first, for example {{ JSON.stringify($json.event) }}.
waitForResponse
Waits without a time limit. If the server never sends a message, or closes without one, the node does not finish.

Output ports

out default

The message was sent (result is "sent") or, with waitForResponse, the first reply arrived (result is its text).

Data
{
  "result": "{\"type\":\"ack\",\"id\":\"msg_881\"}"
}
error

A required field is missing, the credential cannot be resolved, or the connection failed.

Data
{
  "error": "Unexpected server response: 401"
}

In expressions

What a later node can read from this node's output with $("WebSocket Client").item.json.<path> (write your node's label instead of WebSocket Client). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through out, from the output shown in Ports.

ExpressionEditorWorker
$("WebSocket Client").item.json.resultstring= "{\"type\":\"ack\",\"id\":\"msg_881\"}"Ack or Response

Errors

Message Port Cause and fix
Unexpected server response: <status> error The server refused the upgrade (for example 401 or 404). Check the URL and the token in the credential.
message is required error The message is empty in the config and in the incoming payload (connection_id is required is the equivalent for the credential).
Failed to resolve connection <connection_id>: <detail> error The credential does not exist or this workflow cannot use it.

Input contract

connection_id string Required
message string Required
waitForResponse boolean Optional

Output contract

result string Optional

Ack or Response

Contracts (JSON Schema)

The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.

{
  "slug": "io.websocket",
  "name": "WebSocket Client",
  "category": "io",
  "version": "1.0.0",
  "description": "Send message to WebSocket Server.",
  "capabilities": [
    "websocket",
    "realtime",
    "messaging"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "connection_id": {
        "type": "string",
        "title": "WebSocket Credential",
        "description": "Credential for the WebSocket endpoint. Accepts credentials of type `api-key`, `basic-auth`, or `object` (custom handshake headers).",
        "ui_widget": "connection_picker",
        "ui_options": {
          "credential_types": [
            "api-key",
            "basic-auth",
            "object"
          ],
          "types": [
            "websocket"
          ]
        }
      },
      "message": {
        "type": "string",
        "description": "Message to send"
      },
      "waitForResponse": {
        "type": "boolean",
        "default": false
      }
    },
    "required": [
      "connection_id",
      "message"
    ]
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "connection_id": {
        "type": "string"
      },
      "message": {
        "type": "string"
      },
      "waitForResponse": {
        "type": "boolean"
      }
    },
    "required": [
      "connection_id",
      "message"
    ]
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "result": {
        "type": "string",
        "description": "Ack or Response"
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Sent/Response",
      "description": "Message sent or response received",
      "is_default": true,
      "supports_condition": true
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Connection or transmission error",
      "is_default": false,
      "supports_condition": false
    }
  ],
  "execution_mode": "async",
  "required_resources": [],
  "compatible_worker_pools": [
    "standard-io",
    "realtime"
  ],
  "tags": [
    "realtime",
    "messaging"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_link_loom",
    "profile": {
      "name": "Link Loom",
      "verified": true,
      "url": "https://me.veripass.com/link-loom",
      "logo_url": null
    }
  }
}

Execution

Execution
async
Stateful
No
Credentials
Resolved on the server from connection_id; the secret never reaches the workflow.
Capabilities
websocketrealtimemessaging
Tags
realtimemessaging

Notes and limits

  • Only the first incoming message is returned; later messages are discarded. A binary reply is converted to text.
  • A new connection is opened and closed on every run. No retries.

Reviewed against the orchestrator code · 31e874b · 2026-11-26

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs