メニュー

Expand
Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Task Resource

A Task represents a single item of work waiting to be processed. Tasks can represent whatever type of work is important for your team. Twilio applications can create tasks from phone calls or SMS messages. Your CRM or ticketing system can generate tasks from emails or chat messages sent in by your customers. Your own applications can create custom tasks representing whatever unique work your users handle.

Task properties

Taskの属性

すべてのTaskに属性が存在し、それを使って、アプリケーションがTaskをルーティングし、割り当て時に適切なアクションを実行するために必要などんな種類のデータも渡すことができます。 属性はJSONデータで表されます。次に例を示します。

{ 
    "type": "call", 
    "contact": "+15558675309", 
    "customer-value": "gold", 
    "task-reason": "support", 
    "callSid": "CA42ed11..." 
}

Task Lifecycle

A Task does not have an explicit Lifecycle property, but it's an important concept for understanding how Tasks work. A Task's lifecycle is controlled by a Workflow, which will manage the Task's priority and find matching Workers to handle the Task. The Task State page and Workflows and Assignment page provide more detail on the Task lifecycle.

Names in REST API format
account_sid
sid<AC> Not PII

The SID of the Account that created the Task resource.

age
integer Not PII

The number of seconds since the task was created.

assignment_status
enum:status Not PII

The current status of the Task's assignment. Can be: pending, reserved, assigned, canceled, or completed.

attributes
文字列 PII MTL: 30 DAYS

The JSON string with custom attributes of the work. Note If this property has been assigned a value, it will only be displayed in FETCH action that returns a single resource. Otherwise, it will be null.

addons
文字列 Not PII

An object that contains the addon data for all installed addons.

date_created
date_time<iso8601> Not PII

The date and time in GMT when the resource was created specified in ISO 8601 format.

date_updated
date_time<iso8601> Not PII

The date and time in GMT when the resource was last updated specified in ISO 8601 format.

priority
integer Not PII

The current priority score of the Task as assigned to a Worker by the workflow. Tasks with higher priority values will be assigned before Tasks with lower values.

reason
文字列 Not PII

The reason the task was canceled or completed, if applicable.

sid
sid<WT> Not PII

The unique string that we created to identify the Task resource.

task_queue_sid
sid<WQ> Not PII

The SID of the TaskQueue.

task_queue_friendly_name
文字列 Not PII

The friendly name of the TaskQueue.

task_channel_sid
sid<TC> Not PII

The SID of the TaskChannel.

task_channel_unique_name
文字列 Not PII

The unique name of the TaskChannel.

timeout
integer Not PII

The amount of time in seconds that the task is allowed to live.

workflow_sid
sid<WW> Not PII

The SID of the Workflow that is controlling the Task.

workflow_friendly_name
文字列 Not PII

The friendly name of the Workflow that is controlling the Task.

workspace_sid
sid<WS> Not PII

The SID of the Workspace that contains the Task.

url
url Not PII

The absolute URL of the Task resource.

links
uri_map Not PII

The URLs of related resources.

Create a Task resource

post
https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Tasks
パラメーター
Names in REST API format
workspace_sid
Path
post sid<WS> Not PII

The SID of the Workspace that the new Task belongs to.

timeout
オプション
post integer Not PII

The amount of time in seconds the new task is allowed to live. Can be up to a maximum of 2 weeks (1,209,600 seconds). The default value is 24 hours (86,400 seconds). On timeout, the task.canceled event will fire with description Task TTL Exceeded.

priority
オプション
post integer Not PII

The priority to assign the new task and override the default. When supplied, the new Task will have this priority unless it matches a Workflow Target with a Priority set. When not supplied, the new Task will have the priority of the matching Workflow Target.

task_channel
オプション
post 文字列 Not PII

When MultiTasking is enabled, specify the TaskChannel by passing either its unique_name or sid. Default value is default.

workflow_sid
オプション
post sid<WW> Not PII

The SID of the Workflow that you would like to handle routing for the new Task. If there is only one Workflow defined for the Workspace that you are posting the new task to, this parameter is optional.

attributes
オプション
post 文字列 PII MTL: 30 DAYS

A URL-encoded JSON string with the attributes of the new task. This value is passed to the Workflow's assignment_callback_url when the Task is assigned to a Worker. For example: { "task_type": "call", "twilio_call_sid": "CAxxx", "customer_ticket_number": "12345" }.

例 1
        
        
        
        

        The maximum amount of in-flight Tasks allowed for any given Workspace is 500,000. Please contact us if your use case will require more.

        Fetch a Task resource

        GET
        https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Tasks/{Sid}
        パラメーター
        Names in REST API format
        workspace_sid
        Path
        GET sid<WS> Not PII

        The SID of the Workspace with the Task to fetch.

        sid
        Path
        GET sid<WT> Not PII

        The SID of the Task resource to fetch.

              
              
              
              

              Read multiple Task resources

              GET
              https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Tasks
              パラメーター
              Names in REST API format
              workspace_sid
              Path
              GET sid<WS> Not PII

              The SID of the Workspace with the Tasks to read.

              priority
              オプション
              GET integer Not PII

              The priority value of the Tasks to read. Returns the list of all Tasks in the Workspace with the specified priority.

              assignment_status
              オプション
              GET string[] Not PII

              The assignment_status of the Tasks to read. Can be: pending, reserved, assigned, canceled, and completed. Returns all Tasks in the Workspace with the specified assignment_status.

              workflow_sid
              オプション
              GET sid<WW> Not PII

              The SID of the Workflow with the Tasks to read. Returns the Tasks controlled by the Workflow identified by this SID.

              workflow_name
              オプション
              GET 文字列 Not PII

              The friendly name of the Workflow with the Tasks to read. Returns the Tasks controlled by the Workflow identified by this friendly name.

              task_queue_sid
              オプション
              GET sid<WQ> Not PII

              The SID of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this SID.

              task_queue_name
              オプション
              GET 文字列 Not PII

              The friendly_name of the TaskQueue with the Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this friendly name.

              evaluate_task_attributes
              オプション
              GET 文字列 Not PII

              The attributes of the Tasks to read. Returns the Tasks that match the attributes specified in this parameter.

              ordering
              オプション
              GET 文字列 Not PII

              How to order the returned Task resources. y default, Tasks are sorted by ascending DateCreated. This value is specified as: Attribute:Order, where Attribute can be either Priority or DateCreated and Order can be either asc or desc. For example, Priority:desc returns Tasks ordered in descending order of their Priority. Multiple sort orders can be specified in a comma-separated list such as Priority:desc,DateCreated:asc, which returns the Tasks in descending Priority order and ascending DateCreated Order.

              has_addons
              オプション
              GET boolean Not PII

              Whether to read Tasks with addons. If true, returns only Tasks with addons. If false, returns only Tasks without addons.

              例 1
                    
                    
                    
                    
                    例 2
                          
                          
                          
                          
                          Fetches all Tasks which have a language attribute of "en" or "fr" and a "skill_rating" attribute with value greater than 5.1

                          List Tasks with Filters

                          Fetches all Tasks which have a language attribute of "en" or "fr" and a "skill_rating" attribute with value greater than 5.1

                          Tasks are deleted 5 minutes after either they are canceled or completed. You can still query events that occurred for a Task via the Events API.

                          EvaluateTaskAttributes で以下の演算子を使うことができます。

                          • 等号:===
                          • 不等号: !=
                          • より大きい: >
                          • より小さい: <
                          • 以上: >=
                          • 以下: <=
                          • カッコ(演算子の優先度を示す): ( )
                          • 角カッコ(リスト/配列を示す): [ ]
                          • HAS, >-。比較式の左辺のTask属性の値にExpressionの右辺の文字列が含まれるかどうか判断します。
                          • IN, <-。Expressionの左辺のTask属性の値が右辺のリストに * 含まれるかどうか判断します。
                          • AND - 左辺と右辺のサブExpressionが両方とも true の場合、true として解決されます。それ以外の場合は false として解決されます。
                          • OR - 左辺と右辺のサブExpressionの一方または両方とも true の場合、true として解決されます。それ以外の場合は false として解決されます。

                          By default, this will return the first 50 Tasks. Supply a PageSize parameter to fetch more than 50 Tasks. See paging for more information.

                          Update a Task resource

                          post
                          https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Tasks/{Sid}
                          パラメーター
                          Names in REST API format
                          workspace_sid
                          Path
                          post sid<WS> Not PII

                          The SID of the Workspace with the Task to update.

                          sid
                          Path
                          post sid<WT> Not PII

                          The SID of the Task resource to update.

                          attributes
                          オプション
                          post 文字列 PII MTL: 30 DAYS

                          The JSON string that describes the custom attributes of the task.

                          assignment_status
                          オプション
                          post enum:status Not PII

                          The new status of the task. Can be: canceled, to cancel a Task that is currently pending or reserved; wrapping, to move the Task to wrapup state; or completed, to move a Task to the completed state.

                          reason
                          オプション
                          post 文字列 Not PII

                          The reason that the Task was canceled or completed. This parameter is required only if the Task is canceled or completed. Setting this value queues the task for deletion and logs the reason.

                          priority
                          オプション
                          post integer Not PII

                          The Task's new priority value. When supplied, the Task takes on the specified priority unless it matches a Workflow Target with a Priority set.

                          task_channel
                          オプション
                          post 文字列 Not PII

                          When MultiTasking is enabled, specify the TaskChannel with the task to update. Can be the TaskChannel's SID or its unique_name, such as voice, sms, or default.

                          例 1
                                
                                
                                
                                

                                When a pending Task's attributes are updated, the Task will be re-driven through the Workflow identified by the WorkflowSid associated with the task. Depending on the Workflow's filters, TaskRouter may move the Task into a different TaskQueue. The age of the Task will remain the same. If the Task is moved to a new TaskQueue, its TaskQueue position relative to other tasks will be determined by its age and priority, as usual.

                                Delete a Task resource

                                削除する
                                https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSid}/Tasks/{Sid}

                                {TaskSid} で識別されるTaskを削除します。 削除されたTaskに関連づけられたすべての保留中のReservationについては、Taskの削除時に同様に削除されます。

                                パラメーター
                                Names in REST API format
                                workspace_sid
                                Path
                                削除する sid<WS> Not PII

                                The SID of the Workspace with the Task to delete.

                                sid
                                Path
                                削除する sid<WT> Not PII

                                The SID of the Task resource to delete.

                                      
                                      
                                      
                                      
                                      Rate this page:

                                      ヘルプが必要ですか?

                                      誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。