Skip to main content

SignalWire.Relay.TaskingAPI

This represents the API interface for the Tasking Relay Service. A [SignalWire.Relay.RelayTask] is simple way to send jobs to your SignalWire.Relay.Consumer from a short lived process, like a web framework. Relay Tasks allow you to pass commands down to your Consumers without blocking your short lived request. Think of a Relay Task as a way to queue a job for your background workers to processes asynchronously.

For example, if you wanted to make an outbound call and play a message when your user clicks a button on your web application, since Relay is a realtime protocol and relies on you to tell it what to do in realtime, if you did this within your web application, your web server would block until the call was finished... this may take a long time! Instead, simply create a new Relay Task. This task will be handled by a running Relay Consumer process and your web application can respond back to your user immediately.

Methods

Deliver

Deliver the specified message.

Parameters

ParameterTypeRequiredDescription
contextstringrequiredThe context to receive inbound events.
messageJObjectrequiredThe message to deliver.

Returns

bool - true if the delivery is successfully started, false if a problem is encountered.

Examples

Send a message.

bool isSuccessful = client.Tasking.Deliver(
validContext,
new JObject() {
["number_to_call"] = "+1555XXXXXXX",
["message_to_play"] = "We have a message for you",
});

if (isSuccessful)
{
// Message has been queued, you can subscribe to TaskingAPI.OnTaskReceived to receive further updates
}

Events

All these events can be used to track a task.

Receive Events

PropertyDescription
OnTaskReceivedA task has been received.

SignalWire.Relay.RelayTask

A SignalWire.Relay.RelayTask is a simple way to send jobs to your SignalWire.Relay.Consumer from a short lived process, like a web framework. Relay Tasks allow you to pass commands down to your Consumers without blocking your short lived request. Think of a Relay Task as a way to queue a job for your background workers to processes asynchronously.

For example, if you wanted to make an outbound call and play a message when your user clicks a button on your web application, since Relay is a realtime protocol and relies on you to tell it what to do in realtime, if you did this within your web application, your web server would block until the call was finished... this may take a long time! Instead, simply create a new Relay Task. This task will be handled by a running Relay Consumer process and your web application can respond back to your user immediately.

Constructor

The only constructor is the default constructor, properties should all be assigned by initializer or after construction.

Parameters

None

Examples

Basic Example

RelayTask task = new RelayTask
{
SpaceID = validSpaceID,
ProjectID = validProjectID,
Context = validContext,
Message = new JObject {
["greet"] = "Hello"
},
}

Properties

PropertyTypeDescription
SpaceIDstringThe SignalWire space ID.
ProjectIDstringThe SignalWire project ID.
TimestampdoubleSeconds since the epoch with up to microsecond resolution (hence double). Represents the time the task was received.
ContextstringThe context used to receive events.
MessageJObjectThe message to send.

Methods

Deliver

Deliver a message to the specified host. This is typically not used directly, TaskingAPI.Deliver is used instead.

Parameters

ParameterTypeRequiredDescription
hoststringrequiredThe host to post the message to.
projectstringrequiredThe SignalWire project ID.
tokenstringrequiredThe authentication token.
contextstringrequiredThe context to receive inbound events.
messageJObjectrequiredThe message to send.

Returns

void

Examples

Send a message.

RelayTask.Deliver(validHost, validProjectID, validToken, validContext, new JObject {
["number_to_call"] = "+1555XXXXXXX",
["message_to_play"] = "We have a message for you",
});

Events

None