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.

Last edit: May 5, 2022