[How To] Build your own API Orchestrator Process Scheduler to increase the efficiency of your Robots

Hi!

If you’ve been wondering how to increase the efficiency of your Robots at work through the most effective process management, you’ve come to the right place.

In my company, I have prepared a solution that maximizes the use of licenses by filling free spaces on machines by running selected processes (fast or high-volume).

This solution has been working in my company since February 2020 and I would like to share this project with you.

The presented process is only the skeleton (frame) of the working Robot, where the entire logical layer is located.

Much will depend on you, because the Robot is built based on API communication with the Orchestrator. What you will have to do is prepare communication for specific 9 API services:

POST / api / Account / Authenticate

GET / odata / QueueDefinitions

GET /odata / QueueProcessingRecords / UiPathODataSvc.RetrieveQueuesProcessingStatus ()

GET / odata / ProcessSchedules

GET / odata / ProcessSchedules / UiPath.Server.Configuration.OData.GetRobotIdsForSchedule(key=//key})

PUT / odata / ProcessSchedules ({Id})

POST / odata / ProcessSchedules / UiPath.Server.Configuration.OData.SetEnabled

GET / odata / Robots

GET / odata / Sessions

You can learn how to create such a web service here:

Documentation

Name: Process_Scheduler
Purpose
Running processes (Job) on machines that have the status READY (not working) from previously prepared Triggers for a specified time, ie. until the next scheduled start of another process.


Proces_Scheduler

Mode of Action

Specification
  • The process uses API queries to communicate with the Orchestrator PROD database (equivalent of queries available in SWAGGER: https: //orchestrator.domain/swagger/ui/index#/ ).
  • After starting:
    • you can verify the selected queue;
      • If the number of new transactions in the indicated queue = 0, the robot exits.
  • Machine states are checked.
    • Machines in the READY state (not working) are processed further
      • The machine is available;
      • When the next scheduled process (Job) will start later than the previously defined minimum time ( e.g. 15 minutes machine availability), a trigger will be prepared which:
        • will be modified in terms of the process runtime (setting the time when the process is to end),
        • will be modified in terms of the start time (setting the start at a specific time (date and time)) - one-time start ,
        • will be enabled to start the Process.

Functions

Specification
  • ability to run on any process previously prepared schedule (Trigger)
  • the ability to verify the queue whether it contains ‘New’ transactions (so as not to generate empty runs of triggered processes when new transactions = 0 )

Requirements

Specification
  • Specification of the Machines on which the process is to start in the format: machine1 | machine2
    • separated by the sign: | ( pipe )
  • *e.g. VM0000xxx | VM0000xxx | VM0000xxx
  • The Machine Name is also the SUFFIX name of the Trigger
    • e.g .: Rxxx_Scheduler_R???_ VM0000xxx
  • Specifying the Trigger Name ( PREFIX )
    • e.g .: Rxxx_Scheduler_R???_
  • Specification of the minimum machine availability time in seconds
    • e.g. 900 (i.e. 15 min)
  • Specifying the name of the queue to be checked (optional)
    • default phrase: none
    • or for example: Claims_ABC

Reports network location

\\ your_server \ your_Report_Folder_location

ASSET Orchestrator Settings

**Screenshot**

Trigger Preparation

Specification
  • Trigger Name:
    • PREFIX + SUFFIX
      • e.g. Rxxx_Scheduler_R???_VM0000000
  • Robot term as in the name of the Trigger
    • e.g. VM000000x
  • After saving, the Trigger should be turned off
  • Other parameters irrelevant (the robot will make the necessary adjustments)
Screenshot

Sample report

Table view
State MachineName Status Trigger ID Enabled
OK VM0000xxx BUSY
OK VM0000xxx BUSY
??? VM0000xxx The time interval is too short. Rxxx_Scheduler_R???_ VM0000xxx 1 NO
OK VM0000xxx BUSY
OK VM0000xxx BUSY
??? VM0000xxx The time interval is too short. Rxxx_Scheduler_R???_ VM0000xxx 2 NO
OK VM0000xxx BUSY
OK VM0000xxx BUSY

Process map

Click to expand

UiPath Project & Orchestrator Swagger Screenshots

Authenticate:

POST / api / Account / Authenticate settings

GET Queue Definitions:

GET / odata / QueueDefinitions settings

GET Queue Processing Records Stats:

GET / odata / QueueProcessingRecords / UiPathODataSvc.RetrieveQueuesProcessingStatus() settings

GET Process Schedule (‘Enabled’):

GET / odata / ProcessSchedules settings

GET Robot Ids For Schedule:

GET / odata / ProcessSchedules / UiPath.Server.Configuration.OData.GetRobotIdsForSchedule(key={key}) settings

GET Robots (1: by ID):

GET / odata / Robots settings

GET Sessions (available):

GET / odata / Sessions settings

GET Process Schedule by Schedule Name:

GET / odata / ProcessSchedules settings

GET Robots (2: by Machine Name):

GET / odata / Robots settings

PUT Process Schedules (Edit):

PUT / odata / ProcessSchedules({Id}) settings

POST Process Schedule Set Enabled:

POST / odata / ProcessSchedules / UiPath.Server.Configuration.OData.SetEnabled settings

Arguments

List of Type of Arguments in process

"arguments": {
"input": [
{
"name": "bearerToken",
"type": "System.String",
},`` {``
"name": "getJobsResponse",
"type": "UiPathWebApiNamespace.ODataResponseOfListOfJobDto",
},
{
"name": "getRobotsResponse",
"type": "UiPathWebApiNamespace.ODataResponseOfListOfRobotDto",
},
{
"name": "getRobotLogsResponse",
"type": "UiPathWebApiNamespace.ODataResponseOfListOfLogDto",
},
{
"name": "getQPRResponse",
"type": "UiPathWebApiNamespace.ODataResponseOfListOfQueueProcessingRecordDto",
},
{
"name": "getQDefResponse",
"type": "UiPathWebApiNamespace.ODataResponseOfListOfQueueDefinitionDto",
},
{
"name": "getQueueStatsResponse",
"type": "UiPathWebApiNamespace.ODataResponseOfListOfQueueProcessingStatusDto",
},
{
"name": "getSessionsResponse",
"type": "UiPathWebApiNamespace.ODataResponseOfListOfSessionDto",
},
{
"name": "getReleasesResponse",
"type": "UiPathWebApiNamespace.ODataResponseOfListOfReleaseDto",
},
{
"name": "getPSResponse",
"type": "UiPathWebApiNamespace.ProcessScheduleDto",
},
{
"name": "getEnaDisaResponse",
"type": "UiPathWebApiNamespace.ODataResponseOfBoolean",
},
{
"name": "getRobotIdsResponse",
"type": "UiPathWebApiNamespace.ODataResponseOfListOfInt64",
},
{
"name": "getPSchedResponse",
"type": "UiPathWebApiNamespace.ODataResponseOfListOfProcessScheduleDto",
},
{
"name": "getPutPSchedResponse",
"type": "UiPathWebApiNamespace.ProcessScheduleDto",
}
}

Screenshot

Workflow

Process_Scheduler_UiPath_Forum.7z (41,0 KB)
Workflow includes:

  • Main process as logic
  • Create_CRON.xaml - workflow to create CRON expression based on the given date
18 Likes

Thank you for sharing this guide. You can also look into placing it on Marketplace, I think :slight_smile:

1 Like

Well build solution ! There is one other way to maximize utilization of robots. In my company we are running queue based robots between those who have to run schedule based. We have implemented method that checks ( API orchestrator ) if any robot is pending in this case queue based robot ends job to let work schedule one. There is of course some kind of logic behind and prioritization of jobs.

3 Likes

can you provide xaml file