Task Client

View as Markdown

The Task Client enables server-side task processing. It connects to SignalWire and listens on one or more topics for tasks sent via Task.send from client applications.

1import { Task } from "@signalwire/realtime-api";
2
3const client = new Task.Client({
4 project: "<project-id>",
5 token: "<api-token>",
6 topics: ["office"],
7});

Once instantiated, listen for the task.received event to handle incoming tasks. See Events for all available events.

Constructor

new Task.Client(opts): Task.Client

Creates a new Task Client instance.

Parameters

NameTypeDescription
opts.projectstringRequired. SignalWire project ID.
opts.tokenstringRequired. SignalWire API token.
opts.topicsstring[]Required. Topics to listen on for incoming tasks (e.g., ["office", "jobs"]).
opts.debug.logWsTraffic?booleanLog WebSocket traffic for debugging. Default: false.

Examples

Receiving tasks

1client.on("task.received", (payload) => {
2 console.log("Task received:", payload);
3 // Process the task data...
4});