Relay.Task is simple way to send jobs to your
Relay.Consumers 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.
A Task is a simple object with 2 required arguments:
$token. Project and Token are used to send the Task to your Consumers. Once created, the Task has only one method
deliver to send jobs to your Consumer.
require dirname(__FILE__) . '/vendor/autoload.php';
$task = new Task('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', 'PTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
$context = 'office';
$delivered = $task->deliver($context, [
'key' => 'value',
'data' => 'data for your job'
Send a job to your
Consumer in a specific context.
|string||required||Context where to send the Task.|
|array||required||Array with your custom data that will be sent to your Consumer's |
boolean - Whether the Task has been sent successfully.
Deliver a task to your Consumer with a message to then make an outbound Call.
$delivered = $task->deliver('office', [
'action' => 'call',
'from' => '+18881112222'
'to' => '+18881113333'