send

View as Markdown

send

  • Const send(params): Promise<void>

Send a job to your Task Client in a specific topic.

Parameters

params
objectRequired

Object containing the parameters of the method.

topic
string | string[]Required

Topic to send the task to. Previously known as "context" or "contexts". Can also use params.topics.

message
Record<string, unknown>Required

Message to send.

project
string

SignalWire project id, e.g. a10d8a9f-2166-4e82-56ff-118bc3a4840f.

token
string

SignalWire project token, e.g. PT9e5660c101...a360079c9.

Returns

Promise<void>

Example

Sending a task with a message to then make an outbound Call. Please note that the call is not performed automatically: your Task.Client gives you back your payload, which you should interpret by your own custom logic.

1import { SignalWire } from "@signalwire/realtime-api";
2
3const client = await SignalWire({ project: "ProjectID Here", token: "Token Here"})
4
5const clientTask = client.task
6
7const message = {
8 'action': 'call',
9 'from': '+1XXXXXXXXXX',
10 'to': '+1YYYYYYYYYY'
11}
12
13const taskSend = await clientTask.send({
14 topic: 'office',
15 message: message
16})