Roberty
Roberty
The Roberty module is responsible for integrating the robot with other workspace resources: IDP templates and Roberty Code projects. Its methods can be accessed as in the example below:
const idpResult = await Roberty.RunIdpTemplate["v1_0_0"]({
templateId: "idp-template-id",
filePath: "C:\\Documents\\invoice.pdf",
robotKey: robotKey,
actionId: "readInvoice",
});
Both methods require robotKey, the key of the running robot (available in the robotKey variable in the robot code), and actionId, an identifier of the call. The actionId is required by the method validation, but it does not change the result.
Methods
RunIdpTemplate
Method responsible for sending a local file to an IDP template of the workspace and waiting for the processing result.
const idpResult = await Roberty.RunIdpTemplate["v1_0_0"]({
templateId: "idp-template-id",
filePath: "C:\\Documents\\invoice.pdf",
page: "1-2",
params: { customer: "ACME" },
timeout: 600000,
robotKey: robotKey,
actionId: "readInvoice",
});
Required parameters
templateId:String - expects the ID of the workspace IDP template.filePath:String - expects the path of the file to be processed, on the device that runs the robot: PDF or image (png, jpg, jpeg, webp, tiff, tif, bmp). If the file does not exist, the robot stops the execution with theFILE_NOT_FOUNDerror.robotKey:String - expects the key of the running robot.actionId:String - expects an identifier of the call.
Optional parameters
page:String - pages to work on. It replaces the pages configured in the template and is only accepted when the template allows choosing the pages through the API.params:Object - object with the template parameters.timeout:Number - maximum time to wait for the result, in milliseconds.0waits indefinitely. Default:600000(10 minutes). When the limit is reached, the robot stops the execution with theTIMEOUTerror.
Return
actions.idpResult.requestId // identifier of the IDP run (String)
actions.idpResult.result // full IDP result: preprocessing, identification, extraction, postprocessing and validations (Any)
If the processing ends with an error, the robot stops the execution with the IDP error message; if the run expires, with the EXPIRED error.
RunCodeProject
Method responsible for running a Roberty Code project of the workspace with arguments and waiting for its output.
const codeResult = await Roberty.RunCodeProject["v1_0_0"]({
codeId: "code-project-id",
args: { x: 1 },
deviceTarget: "leastBusy",
timeout: 600000,
robotKey: robotKey,
actionId: "calculate",
});
Required parameters
codeId:String - expects the ID of the Roberty Code project.robotKey:String - expects the key of the running robot.actionId:String - expects an identifier of the call.
Optional parameters
args:Object - object handed to the project as arguments. Default:{}.deviceTarget:String - expects"leastBusy"(the least busy device of the project) or"currentDevice"(the device running the robot, which must be part of the project). Default:"leastBusy".timeout:Number - maximum time to wait for the output, in milliseconds.0waits indefinitely. Default:600000(10 minutes). When the limit is reached, the robot stops the execution with theTIMEOUTerror.
Return
actions.codeResult.requestId // identifier of the Code run (String)
actions.codeResult.response // project output (Any)
If the project run fails, the robot stops the execution with the project error message. For projects that do not run in parallel, the call is refused with CODE_PROJECT_BLOCKS_PARALLEL_ON_CURRENT_DEVICE (when deviceTarget is "currentDevice") or NO_OTHER_DEVICE_FOR_BLOCKING_CODE_PROJECT (when no other device is available).