• Create a task

    Create a task with one API call, and include all the attributes that will be useful to base the task routing on.

    View Docs
    • cURL
    • Node
    • .NET (C#)
    • Java
    • PHP
    $ curl -XDELETE https://taskrouter.twilio.com/v1/Workspaces/WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/Tasks/WTXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
        -u '{account_sid}:{auth_token}'
    
    // Download the Node helper library from twilio.com/docs/node/install
    // These vars are your accountSid and authToken from twilio.com/user/account
    var twilio = require('twilio');
    
    var accountSid = "ACa711a24f5aef39d6526280d46877c7c5";
    var authToken = "your_auth_token";
    var workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    var workflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    
    var client = new twilio.TaskRouterClient(accountSid, authToken, workspaceSid);
    
    client.workspace.tasks.create({
        workflowSid: workflowSid,
        attributes: '{"type":"support"}'
    });
    // Download the twilio-csharp library from twilio.com/docs/csharp/install
    using System;
    using System.Collections.Generic;
    using Twilio.TaskRouter;
    
    class Example
    {
      static void Main(string[] args)
      {
        // Find your Account Sid and Auth Token at twilio.com/user/account
        string AccountSid = "ACa711a24f5aef39d6526280d46877c7c5";
        string AuthToken = "your_auth_token";
        string WorkspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        string WorkflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
        var client = new TaskRouterClient(AccountSid, AuthToken);
    
        Task task = client.AddTask(WorkspaceSid, "{\"type\":\"support\"}", WorkflowSid, null, null);
        Console.WriteLine(task.Attributes);
      }
    }
    // Install the Java helper library from twilio.com/docs/java/install
    import com.twilio.Twilio;
    import com.twilio.rest.taskrouter.v1.workspace.Task;
    
    public class Example {
      private static final String ACCOUNT_SID = "ACa711a24f5aef39d6526280d46877c7c5";
      private static final String AUTH_TOKEN = "your_auth_token";
      private static final String WORKSPACE_SID = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
      private static final String WORKFLOW_SID = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    
      public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
    
        Task task = Task.creator(WORKSPACE_SID, "{\"type\":\"support\"}", WORKFLOW_SID).create();
    
        System.out.println(task.getAttributes());
      }
    }
    <?php
    // Get the PHP helper library from twilio.com/docs/php/install
    require_once '/path/to/vendor/autoload.php'; // Loads the library
    
    use Twilio\Rest\Client;
    
    // Your Account Sid and Auth Token from twilio.com/user/account
    $accountSid = "ACa711a24f5aef39d6526280d46877c7c5";
    $authToken = "your_auth_token";
    $workspaceSid = "WSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    $workflowSid = "WWXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    
    $client = new Client($accountSid, $authToken);
    
    $task = $client->taskrouter
        ->workspaces($workspaceSid)
        ->tasks
        ->create(array(
          'workflowSid' => $workflowSid,
          'attributes' => json_encode(array('type' => 'support'))
          ));
    
    echo $task->attributes;
  • Create a task automatically from a Twilio Voice Call

    When you receive a call on a Twilio number, simply respond to the webhook with TwiML to automatically create a Task.

    View Docs
    • TwiML
    <Response>
      <Enqueue workflowSid="<?php echo $workflowSid ?>">
          <Task>{"account_number": "12345abcdef"}</Task>
      </Enqueue>
    </Response>
  • Route based on skill

    Define a workflow in TaskRouter that inspects attributes and chooses the right TaskQueue to send the call to.

    View Docs
    • JSON
    {
      "task_routing": {
        "filters": [
          {
            "friendly_name": "Support Ticket Filter",
            "expression": "type=='ticket'",
            "targets": [
              {
                "queue": "WQbbb",
                "priority": 10
              }
            ]
          }
        ],
        "default_filter": {
          "queue": "WQccc"
        }
      }
    }
  • Timeout escalation

    TaskRouter doesn’t just route and forget. Progressively increase the set of matching workers by expressing a timeout rule.

    View Docs
    • JSON
    {
      "task_routing": {
        "filters": [
          {
            "friendly_name": "Gold Tickets",
            "expression": "type == 'ticket' AND customer_value == 'Gold'",
            "targets": [
              {
                "queue": "WQbbb",
                "priority": "10",
                "timeout": 300,
                "expression": "task.required_language IN worker.spoken_languages"
              }
            ]
          },
        ],
        "default_filter": {
          "queue": "WQccc"
        }
      }
    }
  • Target Worker Expressions

    Identify a subset of matching workers for a given TaskQueue by matching attributes on a task to attributes on a worker.

    View Docs
    • JSON
    {
      "task_routing": {
        "filters": [
          {
            "friendly_name": "Gold Tickets",
            "expression": "type == 'ticket' AND customer_value == 'Gold'",
            "targets": [
              {
                "queue": "WQbbb",
                "priority": "10",
                "expression": "task.required_language IN worker.spoken_languages"
              },
              {
                "queue": "WQccc"
              }
            ]
          }
        ],
        "default_filter": {
          "queue": "WQccc"
        }
      }
    }
The Twilio advantage
  • Communicate reliably

    Experience a 99.95% uptime SLA made possible with automated failover and zero-maintenance windows.

  • Operate at scale

    Extend the same app you write once to new markets with configurable features for localization and compliance.

  • Many channels

    Use the same platform you know for voice, SMS, video, chat, two-factor authentication, and more.

  • No shenanigans

    Get to market faster with pay-as-you-go pricing, free support, and the freedom to scale up or down without contracts.