All documentation
Messages

Messages and Custom Events

Send normal text messages or structured business events over HTTP and WebSocket using the same channel model.

Multi-language

Overview

PulseGrid supports two common publishing styles: - WebSocket send: a connected client sends a realtime event over its live socket. - Server publish: a trusted backend publishes over HTTP into the same channel. Use event=message for normal text. Use predictable dot-separated names such as order.created, delivery.updated or support.ticket.assigned for structured business events.

Setup

Use WebSocket sending when the sender already has a live connection. Use HTTP publishing for backend workflows, scheduled jobs, bots, integrations and services that do not need to stay connected. Keep business data inside data. Use meta for supporting context such as source, trace IDs or UI origin.

Code example

Messages and Custom Events
JavaScript HTTP publish
await pg.channel("operations").publishEvent("delivery.updated", {
  identifierId: "dispatch_api",
  identifierLabel: "Dispatch API",
  data: { order_id: "ORD-1042", status: "in_transit" },
  meta: { source: "node_backend" },
});

Notes

Do not put a whole event envelope inside normal message text. PulseGrid already supplies event IDs, channel/project information, sender, source and timestamp. Persisted history depends on the channel's persist_events setting and retention policy.