Using data passed via Control Room Process API in your robot code

When you enable the Control Room API for one of your workspaces in Control Room, you can then trigger processes via an API call.

The API also allows you to pass additional data in JSON format to the process.

To be able to access the data you send in your robot code, you will use the RPA.Robocloud.Items library, part of the rpaframework.

Here is a very simple example of an robot using the library:

*** Settings ***
Documentation     Simple Robot to demonstrate how to use variables from the Work Item,
...               passed via the Control Room Process Api
Library           RPA.Robocloud.Items

*** Tasks ***
Log A Message Passed Via The Control Room Process API
    ${MESSAGE}=    Get Work Item Variable    message
    Log    ${MESSAGE}

Notice that:

  • we added the RPA.Robocloud.Items library in the *** Settings *** section.
  • we are accessing a single variable with the Get Work Item Variable keyword.

If we trigger this robot in Control Room via the Control Room Process API, passing this JSON as the request body:

{
  "variables": {
    "message": "Hello World!"
  }
}

Note that the message property is nested in the variables property.

We will get this resulting log:

Log of executed robot

You can use this technique to pass any information you need dynamically to your robots and processes in Control Room.

An alternative approach

You can also make your robots more dynamic using environment variables.

Learn more about the libraries mentioned on this page:

June 30, 2021