Skip to main content

Example

v3.17.0+

This example explains how to create an RPA bot for Flowable. First the RPA bot environment needs to be setup, followed by creating the RPA bot and at the end everything is integrated into a BPMN process. The example used on this page is using the rpaframework to control the screen based on screenshots. Furthermore, it will read text from the screen and return it back to the process.

Installing the dependencies

First, you need to setup a python virtual environment. Therefore, ensure that you have installed python.

note

Please note that rpaframework is as of writing this documentation the package rpaframework is using pendulum in an old version which is not compatible with Python 3.12 and newer. You may want to consider using python 3.10 or 3.11 in case you get an error during the installation of rpaframework. See rpaframework GitHub issue #1155 for further details.

Go to a folder of your choice to start the project and type the following command:

python -m venv .
note

On some systems you need to use python3 or python3.11 instead of just python.

The virtual environment can be enabled with the following command:

source ./bin/activate

To deactivate the virtual environment, it is required to type deactivate.

Once the environment is activated, the following pip command will install all the dependencies:

pip install rpaframework graphviz rpaframework-recognition pytesseract flowable.rpaframework-client 

The first four are required for the rpaframework, while the last one is the Flowable specific client to connect to Flowable.

note

It might be also required to install the system package tesseract and on windows you may need to install graphviz

Creating the .robot-File

The next step is to create the robot file companyvalue.robot. There is an example file below which is explained with a few comments in there (lines starting with #):

*** Settings ***
# Importing the different libraries, this includes the Flowable API which is used to read input parameters
# and also write output parameters.
Library RPA.Tasks
Library RPA.Desktop
Library flowable.rpaframework_client.API

*** Tasks ***
# "Discounted cash flow" is the name which is used inside the process/case to reference to this specific task
Discounted cash flow
# Reading variables from the input in the process. The first part is the variable in the .robot file,
# while the last name is the name how it's defined as input parameter.
${fc1}= flw input fc1
${fc2}= flw input fc2
${fc3}= flw input fc3
${wacc}= flw input wacc
# This opens an application, in this case it's the command to open excel on a Mac.
Open Application open -a /Applications/Microsoft\ Excel.app
# Clicks on a certain position the screen
Click image:images/fc1.png click
# A few key presses, which are used to enter the input data. Here we can see how the variables from above are used.
Press keys right
Type text ${fc1}
Press keys enter
Type text ${fc2}
Press keys enter
Type text ${fc3}
Press keys enter
Type text ${wacc}
Press keys enter
# Searches the next element, but this time without clicking on it. Instead, it saves the position of it.
${terminal_region}= Find element image:images/terminal-value.png
# We are using an offset to go to the region on which probably the result is stored
${moved_t_region}= Move Region ${terminal_region} 205 0
# We read the text from the region to a new variable called `terminal_value`
${terminal_value}= Read Text ${moved_t_region}
# The same in the next three lines for the company value
${company_region}= Find element image:images/company-value.png
${moved_c_region}= Move Region ${company_region} 205 0
${company_value}= Read Text ${moved_c_region}
# We take a screenshot, which isn't used in the process but stored in the rpaframework report.
Take screenshot
# Writing the output values back to Flowable, so that they can be mapped to the process or case
flw output companyValue ${company_value}
flw output terminalValue ${terminal_value}
note

The above example is written for Mac or linux. On Windows the RPA.Excel.Application library is a better option as it allows for direct cell referencing.

Next, the example document can be downloaded here here.

Example document

For that document a few screenshots need to be taken which are used above:

  • FC1 - the first field the robot needs to click on: fc1
  • Terminal Value - a field which is then read later: terminal value
  • Company value - second field to be read by the robot: company value
note

It might not be enough to download the images from above and use those images, since the robot is searching the exact image on the screen. When a few pixels are different or the Zoom level doesn't match, it won't find the picture and it will fail.

Images are referenced from and should be stored in an images folder inside the main project folder.

Starting the RPA Framework Client

To start the RPA Framework client the Python module needs to be called, with the above example when published to the Flowable Trial the following command line can be used:

python -m flowable.rpaframework_client --flowable-token <flowable-token> calculateCompanyValue companyvalue.robot
info

The <flowable-token> needs to be replaced with a token generated in the Flowable Trial. The parameters to connect to a different Flowable installation than the Flowable Cloud Trial are described in the introduction.

If using a local installation of Flowable, use the <flowable-username>, <flowable-password> and <flowable-host> parameters to access the Flowable engine.

Creating the Process

Now the next step is to create the process. A really simple process can be used to start with, which is capturing the FC1, FC2, FC3 and WACC in the start form. Those can be parsed then down to the RPA Framework task. The result of the RPA Framework task will be the companyValue and the terminalValue. It is important that the task name matches the task name used in the robot file and the topic matches the topic specified when calling the flowable.rpaframework_client.

Those two variables are containing the string which is displayed on the screen. That can be converted to a number with the following expression:

${flw.math.parseInt(flw.string.replaceAll(companyValue, "[^0-9]", ""))}

The replaceAll part removes all none numeric characters. In case there would be a decimal point, that would be removed as well. Afterward, parseInt converts the number to an integer, with that's a numerical value which can be used for comparison.

The process might look like this:

Example process with a RPA Framework task

Conclusion

This example demonstrates the seamless integration of an RPA bot with Flowable BPMN processes, leveraging the rpaframework for screen-based automation. By following the steps, you’ve set up an environment, created a bot script to interact with application interfaces, and integrated the bot into a Flowable process to handle input and output parameters.

Through this approach, the power of RPA can enhance your BPMN workflows, automating tedious tasks like data extraction and entry. This makes processes more efficient, while the flexibility of Python and rpaframework ensures adaptability to various use cases.