Even though RPA stands for robotic process automation, it is more about task automation, which means helping a worker to perform their tasks. On the other hand, when we want to create an intelligent automation solution that involves multiple workers and systems, we need something that can oversee the orchestration of many activities. This is where workflow automation comes in.
Workflow is about the orchestration of activities that can be performed by humans, robots, and systems. In this chapter, we will use workflow automation to manage a business process of an organization. We will also investigate how RPA bots can work collaboratively with Task and Knowledge workers to maximize efficiency.
Specifically, we will cover the following main topics:
The source code of this chapter can be found on GitHub at https://github.com/PacktPublishing/Intelligent-Automation-with-IBM-Cloud-Pak-for-Business-Automation/tree/main/Chapter%207.
Request and Approve is a very common workflow automation pattern in any intelligent automation solution.
In a typical Request and Approve workflow, we perform the following steps:
This typical pattern can be applied to multiple use cases such as the following:
In this chapter, we will implement a simplified version of the hiring process, as shown in Figure 7.1:
Figure 7.1 – Request and Approve workflow for position request
A real hiring process will include more steps, for example, the subsequent interview of the candidates by the hiring managers or the creation of the hiring contracts. For the purpose of building a workflow solution, it is generally easier to start from a basic business process and iteratively evolve it to handle more use cases.
We will go through the major steps in building a workflow automation solution:
In this section, let us understand how to build the workflow process.
To get started, we will create new workflow automation within the Business Automation Studio by selecting the Workflow automation option in the Create dropdown, as shown in Figure 7.2:
Figure 7.2 – Creating new workflow automation
For this example, we will just create workflow automation by providing the name, Hiring Process, and a brief description of the purpose of this workflow automation:
Figure 7.3 – Creating new workflow automation – hiring process
Once the workflow automation project is created, you will be directed to the Process App Settings page of the Hiring Process application (Process App).
Within the Process App Settings page, there are three major tabs:
The following screenshot displays those three tabs:
Figure 7.4 – Hiring Process – Process App Settings
Let us discuss these tabs in detail:
In addition to the Overview section, there are two other sections:
In most cases, automation developers can start with the default values in the preceding settings. In the next section, we will create our first business process.
To get started, we will first create a process to describe the logical flow of the hiring process:
Figure 7.5 – Creating a new process
Figure 7.6 – Creating a new process – Request New Position process
Figure 7.7 – Default process
One of the key advantages of the low code workflow automation design experience is its ability to run the process at any time without having to write a single line of code or set up any CI/CD pipeline integration. Even now, if you press the play button, the designer will run the newly created process and bring up the built-in process inspector.
In the process inspector, you will see information such as follows:
It also highlights the current process is stopped at the Inline User Task activity. The process is stopped at the activity because it is waiting for a response from the user.
All this information is shown in the following screenshot:
Figure 7.8 – Running the default process with built-in Inspector
To work on the task, we can claim the task by pressing the play icon right next to the task in the Inspector view:
Figure 7.9 – Claiming the Inline User Task
This will in turn bring up the generated Task UI. At this point, given this is the default process, there is nothing of interest as we have not specified any inputs and outputs of the activities.
Figure 7.10 – Generated UI for the default “Inline User Task”
The only thing we can do is to press Done and complete the task, which will also move the process to the end activity and complete the process.
If we review the scenario, there are three distinct personas participating in the automation:
Each persona in the solution is represented by different swimlanes in a BPMN diagram.
There are two default swimlanes to start with:
We will repurpose the first swimlane and rename it for Hiring Manager:
Figure 7.11 – Modifying the swimlane for “Hiring Managers”
Figure 7.12 – Adding swimlane
Figure 7.13 – Incomplete process diagram for “Request New Position”
Figure 7.14 – Drag-n-connect wire from one activity to another
Figure 7.15 – Complete process diagram for Request New Position
However, in a real-world situation, we will need to provide more details for the process to be meaningful, for example, who are the hiring managers, how do you make a position request, and how do we save all the collected data?
We have three groups of people that can participate in this process, which means we want to make sure we will only assign the tasks to people who can work on the tasks, and only people that are authorized to work on certain tasks can claim them; for example, we do not want hiring managers to be able to approve their own requests. To do that, we will need to set up the team assignment for each swimlane by creating three different teams:
Let us see how to set them up:
Figure 7.16 – Creating a new Team
Figure 7.17 – Selecting team membership
Figure 7.18 – Completed team definitions
Figure 7.19 – Updating team assignment
At this point, we have defined the process diagram and corresponding team definitions. However, how would the hiring managers specify which position they are making a request for? To do that, we need to first create a data model.
Let us design a simple data model for our tutorial. In workflow automation, we use the term business object (BO) to describe the data models within a process. The position request is represented by the PositionRequest BO, and it contains the following:
In our tutorial, we have four BOs, as shown in Figure 7.20:
Figure 7.20 – Business objects for Hiring Process
Now, to define this in the workflow designer, in the Data section of the left navigation panel, we will select the New | Business Object options:
Figure 7.21 – Creating a new BO
A New Business Object dialog will pop up, and within it, specify PositionRequest as the name of the new Business Object:
Figure 7.22 – Creating a new Business Object “PositionRequest”
We will then be directed to the BO definition screen. To define the content of a BO, we’ll follow a simple three-step process:
Figure 7.23 – Business object details for PositionRequest
By following the preceding steps, we can define all four BOs. Here is the final definition of the PositionRequest BO:
Figure 7.24 – Final definition for PositionRequest
With all the BOs defined, we will need to update the process definition to indicate how the data will be used. We can do that by first updating the Variables section of the Request New Position process flow. Select the Process section and select the Request New Position process. Once we are there, go to the Variables section.
In the Variables section, we can specify the Input, Output, and Private variables of the process:
Input and Output variables are typically used as an interface for a subprocess. For this tutorial, we will be defining four private variables (reqID, requestor, request, and candidates).
We will follow a four-step process to define a variable, as shown in Figure 7.25:
Figure 7.25 – Initializing variables for Request New Position process
In our case, we want to initialize the default reqID value to the same as the process instance ID. The process instance ID is guaranteed to be unique within a given workflow server environment, but it is not a global unique ID. If that is needed, it is best to generate a UUID. For now, we can initialize reqID to tw.system.process.instanceId.
For requestor, we will initialize it with the name of the person that started this process:
tw.system.user.fullName
The tw.system variable contains a set of system predefined values.
For the request and candidates variables, we will just use the system to generate the default initialization code for us by selecting the Has default checkbox:
Figure 7.26 – Setting default for complex variable
With all four variables defined in the process, they can now be used by the different tasks and gateways within the process.
To do that, flip to the Definition section and follow these steps:
Figure 7.27 – Assigning inputs and outputs to Submit New Position Request activity
Activity |
Inputs |
Outputs |
Review New Request |
request |
request |
Find Candidates |
request |
candidates |
Table 7.1 – Inputs and outputs for Review New Request and Find Candidates
Figure 7.28 – Gateway configuration for GM approved?
Figure 7.29 – Testing out the new updated process with Inspector
Figure 7.30 – Generated UI based on inputs and outputs
So far, we have covered the basics of building workflow automation:
In the previous section, we used an Inline User Task to automatically generate the Task UI based on input and output data mapping. While that is a useful technique to speed up our development, it is also common for business users to demand a more customized experience when working on tasks. To achieve that, we can make use of the built-in UI designer to build a custom task with the Client-Side Human Service (CSHS) and reusable View capabilities. In this part of the tutorial, we will replace the generated UI of Submit New Position Request with a custom UI.
To create this custom UI, we will create two reusable views (QualificationView and PositionRequestView) and one CSHS (Submit New Position Request):
Figure 7.31 – Custom UI with Client-Side Human Service and views
Views are reusable UI widgets that can be combined to create a more complex UI. There are close to 100 out-of-the-box views available for reuse. This same technology is used in both workflow automation and business applications, and we will go into more detail in Chapter 11, Engaging Business Users with Business Applications.
We will create QualificationView by first selecting the User interface section and then New | View options:
Figure 7.32 – Creating new views
Afterward, we specify the view name, QualificationView, and accept all the defaults:
Figure 7.33 – Creating new views
Next, we go to the Variables tab of the view and add a new business data called qualifications with BO type Qualifications to it. This defines the data model that we will be using in the view:
Figure 7.34 – Assigning Variables in View
We then go to the Layout tab and start building the view using the WYSIWYG visual designer. To get started quickly, we can do the following:
Figure 7.35 – View design for QualificationView
Figure 7.36 – Changing label placement in View design
Figure 7.37 – Changing to “Single select” in View design
Figure 7.38 – Providing a static list in Single select
As a result of the preceding settings, the Education Level field will become a dropdown with the following information:
Figure 7.39 – Education Level dropdown
Figure 7.40 – Items From Service
Figure 7.41 – Creating a new service flow
tw.local.results = new tw.object.listOf.NameValuePair();
tw.local.results[0] = new tw.object.NameValuePair();
tw.local.results[0].name = "N/A";
tw.local.results[0].value = "N/A";
tw.local.results[1] = new tw.object.NameValuePair();
tw.local.results[1].name = "High School";
tw.local.results[1].value = "High School";
tw.local.results[2] = new tw.object.NameValuePair();
tw.local.results[2].name = "Bachelor";
tw.local.results[2].value = "Bachelor";
tw.local.results[3] = new tw.object.NameValuePair();
tw.local.results[3].name = "Master";
tw.local.results[3].value = "Master";
tw.local.results[4] = new tw.object.NameValuePair();
tw.local.results[4].name = "Ph.D.";
tw.local.results[4].value = "Ph.D.";
The code illustrates how we can make use of a service flow to provide information at runtime.
Figure 7.42 – Final PositionRequestView
Figure 7.43 – Changing from “Inline User Task” to “User Task”
Figure 7.44 – Creating a new CSHS
Figure 7.45 – Selecting the Input and Output for CSHS
This will create a simple CSHS with a single coach. A coach is like a view, except it represents the entire user interface that a task worker will see, as opposed to being just a reusable UI widget with the view. In our case, we will directly use PositionRequestView, and bind the inputs to reqID and requestor variables, and the outputs to request variables:
Figure 7.46 – Page flow for Request Position CSHS
We now have created a simple User Task UI with a custom CSHS implementation. If we are to go back to the process diagram and rerun the process, you will now have a new UI replacing the original generated UI:
Figure 7.47 – Submit New Position Request Task UI
In IBM BAW, we provide a very powerful user interface builder. There is a lot more that can be done by building a custom responsive task UI. To learn more, we can refer to the IBM Redbook, Deliver Modern UI for IBM BPM with the Coach Framework and Other Approaches (http://www.redbooks.ibm.com/abstracts/sg248355.html).
As mentioned briefly before, we can use a service flow to call an external service to retrieve and store information gathered from the user interface. A typical use case is to store information in some external system of record (SOR). It is a good practice to not use the workflow automation itself as a system of record because of the following:
In our case, we will use an external data store to save the position request. For the sake of simplicity in this tutorial, we are going to use a simple PositionRequest service that is created using Loopback4.
To use the PositionRequest service, we must first import its service interface into the workflow project. We can do that by choosing the New | External Service options in the left navigation panel, Service. Once we are there, we will select the REST service from URL option and specify the URL where the service is being hosted:
Figure 7.48 – Creating new external service
By going through the rest of the dialog (accepting all defaults), we now have a new external service called PositionRequestStore with a set of operations matching those that are created by the Loopback4 implementation:
Figure 7.49 – PositionRequestStore External Service
In our case, we will create a service flow (PositionRequestCreate) that will call the PositionRequestController.create operation from the PositionRequest service:
Figure 7.50 – PostionRequestCreate service flow
The inputs and outputs of the new service flow are shown in Table 7.2:
Inputs |
Outputs |
request (type: PositionRequest) |
Success (type: Boolean) |
Table 7.2 – Inputs and outputs for the PositionRequestCreate service flow
In Figure 7.50, we also make use of an Error Event () to redirect the logic to another script task to handle the failure should there be any error in the creation of the position request record. In this case, we will set the output variable (Success) of the service flow to false to indicate the call to the external service has failed.
Once the service flow is created, we can use it inside the Submit New Position Request CSHS by changing the CSHS to call the service flow once the user presses the OK button. We will also test the result of the save; if it fails, we will re-route the UI flow back to the coach and the user can resubmit the request at another time:
Figure 7.51 – Updated page flow to handle an exception
The preceding flow will stop the workflow from moving forward unless the request is saved successfully to the system of record.
Now that we have a runnable workflow, how can we make this workflow available to be used by others? To do that, we need to first make this workflow solution exposed to other users by assigning the team that can start the process:
Figure 7.52 – Exposing teams to start a workflow
Another important setting is Instance owners. This is where we can specify who can manage the life cycle of all instances of this process. In our case, we will assign that to the Human Resources team.
Figure 7.53 – IBM Workplace
Figure 7.54 – Starting a new workflow in IBM Workplace
Figure 7.55 – Claiming task in IBM Workplace
Since IBM Workplace is built as a business application (see Chapter 11, Engaging Business Users with Business Applications), the automation developers can build similar applications to create custom solutions to manage workflows differently or to even embed your experience within other applications by making use of the available task management API.
In the context of workflow automation, the purpose of RPA bots is to help human workers to simplify or automate their tasks. There are typically two approaches to incorporating the use of robots into a Workflow solution:
The ability to create versions (we call them snapshots) and branches is not a new concept in development. In Business Automation Studio, we provide a built-in version control system so automation developers can be productive on the first day. To use that, we can go to the details page of the selected workflow automation to create new versions and branches:
Figure 7.56 – Managing Versions and Branches for workflow automation
In addition, it is also possible to share the workflow automation project by exporting a particular version of it from the Versions tab:
Figure 7.57 – Exporting workflow automation package
Once you have the version exported, the automation developers can then share it with others or for deployment into other workflow systems.
Now let’s move on to the advanced topics of escalation, exception handling, and later, troubleshooting.
During a workflow, there can be two major exceptions kinds:
Unless the exceptions are handled, it will usually result in the failure of the task at hand. To increase the robustness of your workflow automation, we provide several techniques to handle the exception by attaching an intermediate event to the activity:
Figure 7.58 – Error event
Figure 7.59 – Timer event
It is not unusual for automation developers to initially focus on the success paths of workflow automation, but it is even more important for automation developers to consider both system errors and business errors that might arise during the execution of the workflow.
Even with the best and most careful planning ahead of time, there are going to be situations where the business conditions are different or unexpected system or business exceptions happen during the execution of the workflow instance. In those situations, we will have to rely on the ability to manage the workflow instance outside of the development cycle. To do that, we will log into the Workflow Administration Console, and Workflow system administrators and instance owners will have visibility into the states of the currently running workflow instances.
Workflow instance owners and Workflow administrators can go into the runtime process inspector within the Process Admin Console to examine the current states of the workflow instances:
Figure 7.60 – Runtime process inspector
Inside the process inspector, we can provide different search conditions to search for active or completed workflow instances, and for each instance, we can find out their current state, the current set of tasks, and whether any of those have been claimed, completed, or failed. For failed tasks, the administrator can even restart them if they believe the failure conditions have been addressed already.
In addition, there are many things that workflow administrators can do, such as managing the operational health of the system by managing the various caches, cleaning up an orphaned or unwanted task, onboarding users, and creating teams (groups).
In this chapter, we provided a detailed walkthrough on building workflow automation with the Workflow designer using the BPMN notations. We also explained how automation developers can customize the task UI, and add integrations with external services or RPA bots.
We also provided a brief introduction on how to manage the process life cycle, how to handle exceptions and escalation with error and timer events respectively, and how to troubleshoot and manage the process instances with the runtime process inspector. While we only showed a simple Request and Approval process pattern, the same technique can be applied to implement more complicated workflow patterns.
In the next chapter, we will describe how to create reusable business logic with decision services.
There are many other more advanced features such as process federation (allowing users to work on tasks from multiple workflow systems at the same time), or process instance migration (upgrading a running process instance to a new version). We will not be covering those topics here but more information can be found in IBM Business Automation Workflow Knowledge Center: https://www.ibm.com/docs/en/baw/20.x.