Skip to content

Topics

Topics provide a general-purpose messaging layer on top of Ironflow’s NATS infrastructure. Use them for service-to-service communication, analytics, or notifications — without triggering workflows.

Topics vs Events

Featureemit()publish()
Namespaceevents:topic:
Triggers Functions?YesNo
Use CaseBusiness logic triggers.Real-time messages / broadcasting.

Publishing to Topics

From Application Code

import { createClient } from "@ironflow/node";
const ironflow = createClient({ apiKey: process.env.IRONFLOW_API_KEY });
await ironflow.publish("notifications.email", {
to: "user@example.com",
body: "Welcome to Ironflow!",
});

From Within a Workflow

Use step.publish() to emit a message as a durable step. This ensures that if the workflow retries, the message is not published more than once.

export const myFn = ironflow.createFunction(config, async ({ step }) => {
// Durable publish — memoized and observable
await step.publish("analytics.workflow_step", { status: "reached" });
});

Subscribing to Topics

Topics use the topic: prefix for subscriptions.

import { ironflow } from "@ironflow/browser";
await ironflow.subscribe("topic:notifications.>", {
onEvent: (event) => console.log("Broadcasting:", event.data),
});

Clean Patterns

Use topic:notifications.* to listen to specific categories, or topic:> to listen to all custom messages in the system.