November 3rd, 2021 12:00 PM EDT
Automation for Field Services & DistributionNovember 3rd, 2021 12:00 PM EDT
Learn how creating a digital workforce can improve your supply chain processes!

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.Robocorp.WorkItems 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.Robocorp.WorkItems

*** 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.Robocorp.WorkItems 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:

  "message": "Hello World!"

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:

August 30, 2021