This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Task Handling in Clio

The second use case in the Clio business scenario is used for task handling. This page describes the relevant tasks and the operations you use in the Clio connector and the other ESB connectors. It contains the following sections:

Overview

The flow for task handling is illustrated in the following diagram. The ESB connectors for Gmail will be used to connect to each service. Gmail can be used to send e-mails or notifications as emails to relevant personnel. 

Sending notifications of tasks

  1. Create a task using the createTask operation in the Clio API.

  2. Send notification to task assignee using the sendMail operation in the Gmail API when a task is created.
Gmail operations
Clio operations
Samples
Sample proxy for creating a task in Clio and emailing the details of the created task to the assignee via Gmail
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="clio_sendTaskNotificationsToAssignees" transports="https,http"
   statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence onError="faultHandlerSeq">
         <!-- Clio parameters -->
         <property name="clio.apiUrl" expression="json-eval($.clioApiUrl)" />
         <property name="clio.accessToken" expression="json-eval($.clioAccessToken)" />
         <property name="clio.name" expression="json-eval($.clioTaskName)" />
         <property name="clio.description" expression="json-eval($.clioTaskDescription)" />
         <property name="clio.priority" expression="json-eval($.clioTaskPriority)" />
         <property name="clio.assignee" expression="json-eval($.clioTaskAssignee)" />
         <property name="clio.assigner" expression="json-eval($.clioTaskAssigner)" />
         <property name="clio.matter" expression="json-eval($.clioTaskMatter)" />
         <property name="clio.dueAt" expression="json-eval($.clioTaskDueAt)" />
         <property name="clio.complete" expression="json-eval($.clioTaskComplete)" />
         <property name="clio.completedAt" expression="json-eval($.clioTaskCompletedAt)" />
         <property name="clio.isPrivate" expression="json-eval($.clioTaskIsPrivate)" />
         <property name="clio.isStatuteOfLimitations" expression="json-eval($.clioTaskIsStatuteOfLimitations)" />
         <property name="clio.reminders" expression="json-eval($.clioTaskReminders)" />
         <property name="clio.activities" expression="json-eval($.clioTaskActivities)" />
         <property name="clio.cascadingSource" expression="json-eval($.clioTaskCascadingSource)" />
         <property name="clio.cascadingOffset" expression="json-eval($.clioTaskCascadingOffset)" />
         <property name="clio.cascadingOffsetType" expression="json-eval($.clioTaskascadingOffsetType)" />
         <property name="clio.optionalFields" expression="json-eval($.clioTaskOptionalFields)" />
         <!-- Gmail parameters -->
         <property name="gmail.username" expression="json-eval($.gmailUsername)" />
         <property name="gmail.oAuthAccessToken" expression="json-eval($.gmailOauthAccessToken)" />
         <!-- Properties required by faultHandler -->
               
         <property name="activityName" value="clio_sendTaskNotificationViaGmail" scope="operation" />
         <property name="processName" value="clio_sendNotificationsToTaskAssigneesByMail" scope="operation" />
         <!-- Create a task in Clio -->
         <clio.init>
            <apiUrl>{$ctx:clio.apiUrl}</apiUrl>
            <accessToken>{$ctx:clio.accessToken}</accessToken>
         </clio.init>
         <clio.createTask>
            <name>{$ctx:clio.name}</name>
            <description>{$ctx:clio.description}</description>
            <priority>{$ctx:clio.priority}</priority>
            <assignee>{$ctx:clio.assignee}</assignee>
            <assigner>{$ctx:clio.assigner}</assigner>
            <matter>{$ctx:clio.matter}</matter>
            <dueAt>{$ctx:clio.dueAt}</dueAt>
            <complete>{$ctx:clio.complete}</complete>
            <completedAt>{$ctx:clio.completedAt}</completedAt>
            <isPrivate>{$ctx:clio.isPrivate}</isPrivate>
            <isStatuteOfLimitations>{$ctx:clio.isStatuteOfLimitations}</isStatuteOfLimitations>
            <reminders>{$ctx:clio.reminders}</reminders>
            <activities>{$ctx:clio.activities}</activities>
            <cascadingSource>{$ctx:clio.cascadingSource}</cascadingSource>
            <cascadingOffset>{$ctx:clio.cascadingOffset}</cascadingOffset>
            <cascadingOffsetType>{$ctx:clio.cascadingOffsetType}</cascadingOffsetType>
            <optionalFields>{$ctx:clio.optionalFields}</optionalFields>
         </clio.createTask>
         <sequence key="removeResponseHeaders" />
         <property name="clio.taskId" expression="json-eval($.task.id)" />
         <!-- Check if task.id value is available on task creation response. -->
         <filter source="boolean(get-property('clio.taskId'))" regex="false">
            <then>
               <!-- Message to be sent as a task not been created in Clio. -->
               <property name="id" expression="fn:concat('clio_name:', get-property('clio.name'))" />
               <property name="status" value="Failed" />
               <property name="errorResponse" expression="json-eval($)" />
               <!-- Call responseHandler template -->
               <call-template target="responseHandlerTemplate">
                  <with-param name="activity" value="clio_createTask" />
                  <with-param name="id" value="{$ctx:id}" />
                  <with-param name="status" value="{$ctx:status}" />
                  <with-param name="message" value="{$ctx:errorResponse}" />
               </call-template>
               <loopback />
            </then>
            <else>
               <!-- If a task has been created successfully, extract the task details. -->
               <property name="clio.taskAssigneeEmail" expression="json-eval($.task.assignee.email)" />
               <property name="clio.taskAssignerEmail" expression="json-eval($.task.assigner.email)" />
               <property name="clio.taskAssigneeName" expression="json-eval($.task.assignee.name)" />
               <property name="clio.taskAssignerName" expression="json-eval($.task.assigner.name)" />
               <property name="clio.taskId" expression="json-eval($.task.id)" />
               <property name="clio.taskName" expression="json-eval($.task.name)" />
               <property name="clio.description" expression="json-eval($.task.description)" />
               <property name="clio.priority" expression="json-eval($.task.priority)" />
               <property name="clio.complete" expression="json-eval($.task.complete)" />
               <property name="clio.matter" expression="json-eval($.task.matter)" />
               <filter source="get-property('clio.matter')" regex="null">
                  <then>
                     <property name="clio.matter" value="Not Specified" />
                  </then>
               </filter>
               <property name="clio.createdAt" expression="json-eval($.task.created_at)" />
               <property name="clio.dueAt" expression="json-eval($.task.due_at)" />
               <property name="status" value="Success" />
               <property name="message"
                  expression="fn:concat('A task is created in Clio with the following name - ', get-property('clio.taskName'))" />
               <!-- Call responseHandler template -->
               <call-template target="responseHandlerTemplate">
                  <with-param name="activity" value="clio_createTask" />
                  <with-param name="id" value="{$ctx:clio.taskId}" />
                  <with-param name="status" value="{$ctx:status}" />
                  <with-param name="message" value="{$ctx:message}" />
               </call-template>
               <payloadFactory media-type="json">
                  <format>{
                     "mailSubject": "Clio Task - $11",
                     "mailContent": "Hi $1,\n\nPlease note that the following task has been assigned to you.\n\nTask ID:     $2\nDescription: $3\nPriority:    $4\nAssigner:    $5 ($6)\nMatter:      $7\nCreated on:  $8 at $9\nDue date:    $10.\n\nPlease do not respond to this mail as it was auto-generated by the system."
                     }
                  </format>
                  <args>
                     <arg expression="get-property('clio.taskAssigneeName')" />
                     <arg expression="get-property('clio.taskId')" />
                     <arg expression="get-property('clio.description')" />
                     <arg expression="get-property('clio.priority')" />
                     <arg expression="get-property('clio.taskAssignerName')" />
                     <arg expression="get-property('clio.taskAssignerEmail')" />
                     <arg expression="get-property('clio.matter')" />
                     <arg expression="fn:substring-before(get-property('clio.createdAt'), 'T')" />
                     <arg expression="fn:substring-after(fn:substring-before(get-property('clio.createdAt'),'+'), 'T')" />
                     <arg expression="get-property('clio.dueAt')" />
                     <arg expression="get-property('clio.taskName')" />
                  </args>
               </payloadFactory>
               <property name="gmail.responseIds" expression="fn:concat('clio_taskId:', get-property('clio.taskId'))" />
               <!-- Build the message body -->
               <property name="gmail.mailSubject" expression="json-eval($.mailSubject)" />
               <property name="gmail.mailContent" expression="json-eval($.mailContent)" />
               <!-- Send email notifications to responders. -->
               <call-template target="sendNotifications">
                  <with-param name="gmail.username" value="{$ctx:gmail.username}" />
                  <with-param name="gmail.oAuthAccessToken" value="{$ctx:gmail.oAuthAccessToken}" />
                  <with-param name="gmail.subject" value="{$ctx:gmail.mailSubject}" />
                  <with-param name="gmail.toRecipients" value="{$ctx:clio.taskAssigneeEmail}" />
                  <with-param name="gmail.textContent" value="{$ctx:gmail.mailContent}" />
                  <with-param name="gmail.responseIds" value="{$ctx:gmail.responseIds}" />
               </call-template>
               <loopback />
            </else>
         </filter>
      </inSequence>
      <outSequence>
         <payloadFactory media-type="json">
            <format>{
               "Response":{
				   "process":"clio_sendTaskNotificationsToAssignees",
				   "activityResponse":[$1]
				   }
               }
            </format>
            <args>
               <arg expression="get-property('operation','responseString')" />
            </args>
         </payloadFactory>
         <property name="messageType" value="application/json" scope="axis2" />
         <send />
      </outSequence>
   </target>
   <description />
</proxy>                     
Sample request for creating a task in Clio and emailing the details of the created task to the assignee via Gmail
{
    "clioApiUrl": "https://app.goclio.com",
    "clioAccessToken": "QS9sMwAIyxjldou4xpbsbplxDW5jOpePniqRk5ZD",	
    "clionTaskName": "Call and inform Sahan about the meeting",	
    "clioTaskDescription": "Call and inform Sahan about the meeting with the lawyer from colombo.",	
    "clioTaskMatter": "",
    "clioTaskAssignee": "",
    "clioTaskAssigner": "",
    "clioTaskCompletedAt": "2015-02-20",
    "clioTaskDueAt": "2015-03-20",
    "clioTaskIsPrivate": "false",
    "clioTaskComplete": "false",
    "clioTaskPriority": "Normal",
    "clioTaskCascadingSource": "",
    "clioTaskIsStatuteOfLimitations": "false",
    "clioTaskOptionalFields": "activities",
    "clioTaskascadingOffsetType": "CalendarDays",
    "clioTaskCascadingOffset": "5",
    "clioTaskReminders": [ {
            "minutes": 30,
            "method": "Popup"
    }],
    "clioTaskActivities": [
      {
        "type": "TimeEntry",
        "quantity": 1,
        "note": "Note down to take the number."
      }
    ],
    "gmailUsername" : "wso2.connector.virtusa",
    "gmailOauthAccessToken" : "ya29.CAFA5iPtpZKtf5dX2VyZp3-z1_PzmaVIpDitu0w6s6qQAjfCdivfi1e2XlsNTxZF3-sBKoWUvHSIXw"   
}
{
    "clioApiUrl": "https://app.goclio.com",
    "clioAccessToken": "fL9aZC3k6wprSqVtlfuowat1JMXX9WazGyQCkQzG",	
    "clioTaskName": "Sample Task 0007",	
    "clioTaskDescription": "Let's create a Sample Task 0007",	
    "clioTaskMatter": "",
    "clioTaskAssignee": {
      "id": 344411004
    },
    "clioTaskAssigner": {
      "id": 344410994
    },
    "clioTaskDueAt": "2015-02-28",
    "clioTaskIsPrivate": "true",
    "clioTaskComplete": "false",
    "clioTaskPriority": "High",
    
    "gmailUsername" : "courtycorp",
    "gmailOauthAccessToken" : "ya29.GQG5U4A-vhzaXu0Go0gV24ulksOgTpQARrc-1u97Btz2NZj_WJiuI9JwL_GlDrjyPOfiFJbLWVgXLA"   
}

Sending task completion mails

  1. Retrieve the tasks from the Clio API using the getTask operation.

  2. Once the assignee marks the task as completed in the Clio API using the updateTask operation, send a mail to the assigner using the sendMail operation in the Gmail API, notifying the task completion.
Gmail operations
Clio operations
Samples
Sample proxy for notifying the assigner via an email about the completion of the task
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="clio_sendNotificationsToAssignersOnTasksCompletion"
   transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence onError="faultHandlerSeq">
         <!-- Clio parameters. -->
         <property name="clio.apiUrl" expression="json-eval($.clioApiUrl)" />
         <property name="clio.accessToken" expression="json-eval($.clioAccessToken)" />
         <property name="clio.complete" expression="json-eval($.clioTaskComplete)" />
         <!-- Gmail parameters. -->
         <property name="gmail.username" expression="json-eval($.gmailUsername)" />
         <property name="gmail.oAuthAccessToken" expression="json-eval($.gmailOauthAccessToken)" />
         <!-- Properties required by faultHandler. -->
               
         <property name="activityName" value="clio_sendTaskNotificationViaGmail" scope="operation" />
         <property name="processName" value="clio_sendNotificationsToAssignersOnTasksCompletionByMail" scope="operation" />
         <!-- Operation Properties. -->
         <property name="clio.taskIdsCount" expression="count(//clioTaskIds)" scope="operation" />
         <property name="clio.taskIdsIndex" value="0" scope="operation" />
         <!--FOR EACH clioTaskIds : BEGIN -->
         <iterate continueParent="true" id="taskIdsVal" expression="//clioTaskIds" sequential="true">
            <target>
               <sequence>
                  <property name="clio.taskId" expression="//clioTaskIds/text()" />
                  <!-- Check task as completed in Clio. -->
                  <clio.init>
                     <apiUrl>{$ctx:clio.apiUrl}</apiUrl>
                     <accessToken>{$ctx:clio.accessToken}</accessToken>
                  </clio.init>
                  <clio.getTask>
                     <taskId>{$ctx:clio.taskId}</taskId>
                  </clio.getTask>
                  <sequence key="removeResponseHeaders" />
                  <property name="clio.taskStatus" expression="json-eval($.task.complete)" />
                  <property name="clio.taskId" expression="json-eval($.task.id)" />
                  <property name="id" expression="fn:concat('clio_taskId:', get-property('clio.taskId'))" />
                  <!--Checking the status of the task -->
                  <filter source="boolean(get-property('clio.taskId'))" regex="false">
                     <then>
                        <property name="errorResponse" expression="json-eval($)" />
                        <!-- Call responseHandler template -->
                        <call-template target="responseHandlerTemplate">
                           <with-param name="activity" value="clio_getTask" />
                           <with-param name="id" value="{$ctx:id}" />
                           <with-param name="status" value="Failure" />
                           <with-param name="message" value="{$ctx:errorResponse}" />
                        </call-template>
                     </then>
                     <else>
                        <!--Checking the status of the task -->
                        <filter source="get-property('clio.taskStatus')" regex="true">
                           <then>
                              <!-- Call responseHandler template -->
                              <call-template target="responseHandlerTemplate">
                                 <with-param name="activity" value="clio_getTask" />
                                 <with-param name="id" value="{$ctx:id}" />
                                 <with-param name="status" value="Failure" />
                                 <with-param name="message" value="Task is already completed in Clio." />
                              </call-template>
                           </then>
                           <else>
                              <!-- Update tasks as completed in Clio. -->
                              <clio.init>
                                 <apiUrl>{$ctx:clio.apiUrl}</apiUrl>
                                 <accessToken>{$ctx:clio.accessToken}</accessToken>
                              </clio.init>
                              <clio.updateTask>
                                 <taskId>{$ctx:clio.taskId}</taskId>
                                 <complete>true</complete>
                              </clio.updateTask>
                              <sequence key="removeResponseHeaders" />
                              <property name="clio.taskIdUpdatedStatus" expression="json-eval($.task.complete)" />
                              <property name="clio.updatedTaskId" expression="json-eval($.task.id)" />
                              <!-- Check if task.complete value is updated as 'true' on response. -->
                              <filter source="get-property('clio.taskIdUpdatedStatus')" regex="false">
                                 <then>
                                    <property name="errorResponse" expression="json-eval($)" />
                                    <!-- Call responseHandler template -->
                                    <call-template target="responseHandlerTemplate">
                                       <with-param name="activity" value="clio_getTask" />
                                       <with-param name="id" value="{$ctx:id}" />
                                       <with-param name="status" value="Failure" />
                                       <with-param name="message" value="{$ctx:errorResponse}" />
                                    </call-template>
                                 </then>
                                 <else>
                                    <!-- If complete status was updated as 'true', extract the task details. -->
                                    <property name="clio.taskAssignerEmail" expression="json-eval($.task.assigner.email)" />
                                    <property name="clio.taskAssigneeEmail" expression="json-eval($.task.assignee.email)" />
                                    <property name="clio.taskAssigneeName" expression="json-eval($.task.assignee.name)" />
                                    <property name="clio.taskAssignerName" expression="json-eval($.task.assigner.name)" />
                                    <property name="clio.taskId" expression="json-eval($.task.id)" />
                                    <property name="clio.taskName" expression="json-eval($.task.name)" />
                                    <property name="clio.description" expression="json-eval($.task.description)" />
                                    <property name="clio.priority" expression="json-eval($.task.priority)" />
                                    <property name="clio.matter" expression="json-eval($.task.matter)" />
                                    <filter source="get-property('clio.matter')" regex="null">
                                       <then>
                                          <property name="clio.matter" value="Not Specified" />
                                       </then>
                                    </filter>
                                    <property name="clio.completedAt" expression="json-eval($.task.completed_at)" />
                                    <!-- Call responseHandler template -->
                                    <call-template target="responseHandlerTemplate">
                                       <with-param name="activity" value="clio_updateTask" />
                                       <with-param name="id" value="{$ctx:clio.taskId}" />
                                       <with-param name="status" value="Success" />
                                       <with-param name="message" value="The task was completed successfully." />
                                    </call-template>
                                    <!-- Build the message body -->
                                    <payloadFactory media-type="json">
                                       <format>{
                                          "mailSubject": "Clio Task - $10",
                                          "mailContent": "Hi $1,\n\nPlease be informed that the following task has been completed in Clio.\n\nTask ID:      $2\nDescription:  $3\nPriority:     $4\nAssignee:     $5 ($6)\nMatter:       $7\nCompleted on: $8 at $9\n\nPlease do not respond to this mail as it was auto-generated by thesystem."
                                          }
                                       </format>
                                       <args>
                                          <arg expression="get-property('clio.taskAssignerName')" />
                                          <arg expression="get-property('clio.taskId')" />
                                          <arg expression="get-property('clio.description')" />
                                          <arg expression="get-property('clio.priority')" />
                                          <arg expression="get-property('clio.taskAssigneeName')" />
                                          <arg expression="get-property('clio.taskAssigneeEmail')" />
                                          <arg expression="get-property('clio.matter')" />
                                          <arg expression="fn:substring-before(get-property('clio.completedAt'), 'T')" />
                                          <arg
                                             expression="fn:substring-after(fn:substring-before(get-property('clio.completedAt'),'+'), 'T')" />
                                          <arg expression="get-property('clio.taskName')" />
                                       </args>
                                    </payloadFactory>
                                    <!-- Build the message body -->
                                    <property name="gmail.mailSubject" expression="json-eval($.mailSubject)" />
                                    <property name="gmail.mailContent" expression="json-eval($.mailContent)" />
                                    <property name="gmail.responseIds" expression="fn:concat('clio_taskId:', get-property('clio.taskId'))" />
                                    <!-- Send email notifications to responders. -->
                                    <call-template target="sendNotifications">
                                       <with-param name="gmail.username" value="{$ctx:gmail.username}" />
                                       <with-param name="gmail.oAuthAccessToken" value="{$ctx:gmail.oAuthAccessToken}" />
                                       <with-param name="gmail.subject" value="{$ctx:gmail.mailSubject}" />
                                       <with-param name="gmail.toRecipients" value="{$ctx:clio.taskAssignerEmail}" />
                                       <with-param name="gmail.textContent" value="{$ctx:gmail.mailContent}" />
                                       <with-param name="gmail.responseIds" value="{$ctx:gmail.responseIds}" />
                                    </call-template>
                                 </else>
                              </filter>
                           </else>
                        </filter>
                     </else>
                  </filter>
                  <property name="clio.taskIdsIndex" expression="get-property('operation','clio.taskIdsIndex') + 1"
                     scope="operation" />
               </sequence>
            </target>
         </iterate>
         <filter xpath="get-property('operation', 'clio.taskIdsCount') = get-property('operation', 'clio.taskIdsIndex')">
            <then>
               <loopback />
            </then>
         </filter>
      </inSequence>
      <outSequence>
         <payloadFactory media-type="json">
            <format>{
               "Response":{
               "process":"clio_sendNotificationsToAssignersOnTasksCompletion",
               "activityResponse":[$1]
               }
               }
            </format>
            <args>
               <arg expression="get-property('operation','responseString')" />
            </args>
         </payloadFactory>
         <property name="messageType" value="application/json" scope="axis2" />
         <send />
      </outSequence>
   </target>
   <description />
</proxy>
Sample request for notifying the assigner via an email about the completion of the task
{
    "clioApiUrl": "https://app.goclio.com",
    "clioAccessToken": "fL9aZC3k6wprSqVtlfuowat1JMXX9WazGyQCkQzG",
    "clioTaskIds": ["12544783","12544789"],
    "gmailUsername" : "courtycorp",
    "gmailOauthAccessToken" : "ya29.GQG5U4A-vhzaXu0Go0gV24ulksOgTpQARrc-1u97Btz2NZj_WJiuI9JwL_GlDrjyPOfiFJbLWVgXLA"
}