Workitem flows
Overview
Work Automation has been integrated with Architect to support the processing of workitems at different times during their lifecycle using workitem flows.
Objects involved in the integration of Work Automation and Architect.
- Workitem: A genesys cloud object that can be used to track a piece of work.
- Workitem flow: A new flow type that can be used to process workitems with native workitem actions.
- Worktype: Defines the structure and behaviour of workitems. Workitems are created from worktypes. A worktype contains:
- Statuses: Statuses are used to define the business process of workitems of that worktype. A workitem will always be labelled with a single status and it can be updated during its lifecycle.
- Schema: A custom field schema that defines the custom field structure of workitems of that worktype.
- Rules: A worktype contains a list of rules. Rules are used to control when the workitem flow is executed for workitems of that worktype. There are three types of rules:
- OnCreate rules can be used to launch the workitem flow associated with the worktype at workitem creation time.
- OnAttributeChange rules can be used to launch the workitem flow on specific attribute updates. For example an OnAttributeChange rule can be created to launch the workitem flow when a workitems statusId attribute is updated from one status to another.
- Date rules can be used to launch the workitem flow at a certain time before, on or after the value of a date attribute. For example a Date rule can be created to launch a workitem flow 60 minutes before the
dateDue
.
Flow association
There is a one-to-one mapping between workitem flows and worktypes. The worktype must be created first. Selecting a worktype is mandatory when creating a workitem flow. The worktype, its statuses and its schema are all dependencies of the workitem flow meaning the flow will be aware of the statuses and workitems customFields (defined by the schema) and flow authors can reference them within the flow.
Flow invocation
When a workitem flow is launched it will always be launched with an individual workitem object. That workitem object can be accessed and updated as part of the flow execution. As described above workitems can launch the workitem flow linked to its worktype at different times and this is controlled by the rules defined on the workitems worktype. Rules are specific to a worktype and can be one of two types which are described below.
OnCreate rules
An OnCreate rule can be added to a worktype to launch the workitem flow when a workitem is created. A workitem can launch a flow OR be sent to a queue for assignment at creation time i.e. A worktype can have its assignmentEnabled
property set to true
OR have an onCreate flow launch rule.
Example API call to create an OnCreate rule:
{
"name": "An onCreate rule"
}
OnAttributeChange rules
OnAttributeChange rules can be added to a worktype to launch the workitem flow when a workitem is updated. OnAttributeChange rules contain a condition. When the condition is met as part of a workitem update the workitem flow will be launched. statusId
is the only supported attribute that can be used within an OnAttributeChange rule.
Example API call to create an OnAttributeChange rule:
{
"name": "An onAttribute change rule",
"condition": {
"attribute": "statusId",
"newValue": "{{newStatusId}}",
"oldValue": "{{oldStatusId}}"
}
}
Looking at the example rule above the workitem flow will be launched if a workitems statusId
attribute is updated from the value {{oldStatusId}}
to the value {{newStatusId}}
.
Date rules
Date rules can be added to a worktype to launch the workitem flow before or after certain key dates (due date, expiration date and life span). These rules contain a condition. The condition will be combined with the value of the date attribute in the workitem to calculate the rule execution time. Then the workitem flow will be launched on the execution time.
Example API call to create a Date rule:
{
"name": "A date rule",
"condition": {
"attribute": "dateExpires",
"relativeMinutesToInvocation": "-60"
}
}
The example above creates a date based rule that will launch the workitem flow 60 minutes before the workitems expiration date.
Possible values for attribute
are dateDue
, dateExpires
and ttl
. relativeMinutesToInvocation
can assume negative or positive values, depending on if the execution will be before or after the specified date.
For the ttl
attribute the value of relativeMinutesToInvocation
cannot be greater than -5.
The minimum time interval between rules of the same date attribute is 15 minutes.
Date rules modifications will take effect for workitems created after the change.
Date rules modifications will affect existing workitems after the next rule execution. At any time, the next rule execution is already scheduled for a given workitem and it will not be canceled. When that execution runs the system calculates the next one based on the latest rule configuration.
Toggling workitem flow rules
The workitem flow launch rules on the worktype can be toggled on and off using the flowRulesEnabled
ruleSettings
property on the worktype. This property can be updated at any time.
{
"ruleSettings": {
"flowRulesEnabled": true
}
}
Workitem flow
Workitem flow variables
There are several notable workitem flow variables that can be used within a workitem flow:
- Workitem.Workitem: This is the workitem object that launched the flow. The workitems properties are accessible within the workitem flow. The workitem can be updated using different architect actions such as
Update Workitem Data
andTransfer to ACD
. The workitem flow will always be launched with the latest version of the workitem. - Workitem.eventType: This is the
eventType
that caused the workitem flow to launch. It can be one of three valuesworkitemCreated
,workitemStatusChanged
orworkitemDateBasedEvent
. - Workitem.WorkitemOriginal: For workitem flow invocations that are caused by an onAttributeChange rule this variable will be the previous state of the workitem. It can be accessed to view the properties of the workitem before it was updated.
- Workitem.WorkitemOriginal may be null for workitem flow invocations where the workitem state hasn't changed i.e flow launches from onCreate rules.
- Workitem.EventData.rule.name: For flow invocations caused by a Date rule this variable will contain the name of the rule.
Reading workitem properties
Workitem properties can be accessed within the flow within expressions. The example below shows how a custom field value can be accessed and compared to a String:
Workitem.Workitem.customFields.location_text == "Europe"
Updating workitem properties
Workitem flows contain multiple actions that can be used to update the Workitem.Workitem
object. These include but are not limited to Update Workitem
, Transfer to ACD
and Terminate Workitem
. When a workitem is updated as part of a flow execution a synchronous update is performed. Workitem updates by a workitem flow adhere to the same constraints as any other workitem update such as status transition restrictions and assignmentState
based restrictions.
Flow execution history
Workitem flow execution history can be viewed in Architect under Flow Execution History. It is possible to search for and replay individual workitem flow executions to debug the actions and paths taken within the workitem flow.
Limits
There are several limits to be aware of:
- Execution limit: There can be a maximum of one workitem flow execution at a time per workitem i.e. If a rules condition is met for a workitem and there is a workitem flow already running for that workitem the workitem flow will not be launched.
- Flow launch limit: There is a limit on the amount of times an individual workitem can launch a workitem flow per day. Detail on limit can be viewed here.
- Flow runtime limit: Workitem flows have a limited runtime. Detail on limit can be viewed here.
- Date rules limit: There is a limit on the amount of rules associated to one date attribute. Detail on limit can be viewed here.