Subscribe Module within Flow

Gaining access to the UiPath features on Humley Studio will, on the creation of a new project, load a number of pre-configured UiPath-specific Variables, and give access to the UiPath Subscribe module within Flows.

The UiPath Subscribe module allows you to wait for and receive event data back from a UiPath process. This is done asynchronously, allowing for continued flow actions or, if finished, more end-user interaction whilst the UiPath process is running.

Before continuing, you may want to refresh your understanding of how standard Integrations are built by reading About Integrations and how they are called within Flow by reading more About Flow & the Flow Integration module.

Overview

Using our pre-built Integrations you can control your robots, processes, etc. but in order to receiving updates throughout their lifecycle you can use our UiPath Subscribe module found within Flow. Add this module to a Flow where you need to subscribe to, and receive event data back from, a UiPath process.

For example, when you start a job, this job may take a few minutes to complete. By by using our subscribe module you can inform your users when the job has faulted or completed.

How to use the Subscribe module

You can interact with your UiPath processes via a Flow by referencing an Integration:

  1. Ensure you have access to the UiPath Integration requests by first Setting up your UiPath Integration Template

  2. Create a Flow that includes an Integration module that references your desired Request

  3. Add a UiPath Subscribe module to your Flow

See more in our UiPath Flow Example

Module Fields

When configuring a UiPath Subscribe module you will be presented with two sections, one section to configure the authentication andinput details, and another to configure the output.

Input Configuration section

Field Description
Module Name A friendly name for the module
Tenancy Name Your UiPath Tenacy Name
Domain Represents the name or domain\name of the machine on which Orchestrator is installed, or the user account, such as docteam or uipath.local\docteam
Username The unqiue identifier of the newly created job
Password A key that relates to the newly created job
Events The events that you wish to subscribe to
Constraints Filters on the result provided from each subscribed event
One-Time Use If the webhook connection should be terminated after first use - checked by default.

Output Configuration section

Field Description
Variable The full result as returned from UiPath - presented as a JSON Object
Event Message A custom response for the end-user when the event subscription is successful
Subscription Error Response A custom response for the end-user when the event subscription returns an error

Input Configuration section

Event

The Events field allows you to subscribe to any number of UiPath events using a webhook. You can find more information about the different types of events here.

In order to configure multiple events within the configuration field you must comma-seperate them. For example: job.complete, queueItem.transactionStarted, robot.started etc.

There is currently a known issue where you must specify a type and cannot have multiple event types in a single subscription

During this stage, we're subscribed to all events of a particular type. In order to filter this down further we'll use the Constraints field to show your end-users specific content only.

Constraints

The Constraints field allows you provide specific filters of what should be shown within your experience. In the Events field we have subscribed to a number of events based on their type. In order for us to filter these down further, we can add constraints. This allows you target filters on multiple items that are presented within the JSON provided as an output for event.

For example if we wished to only reference queue.created messages related to a particular queue, we could do this by adding the following in the Constraints field:

Type=queue.created,Name=$queueID

If the variable $queueID contained "MyNewQueue", only the responses from queue.created events where the value Name = "My New Queue" would be returned (as below):

{ 
   "@odata.context":"https://platform.uipath.com/odata/$metadata#QueueDefinitions/$entity",
   "Name":"MyNewQueue",
   "Description":"Humley Studio example queue",
   "MaxNumberOfRetries":1,
   "AcceptAutomaticallyRetry":true,
   "EnforceUniqueReference":false,
   "CreationTime":"2019-12-01T10:31:22.176966Z",
   "Id":67621
}

In another example, if we wished to only reference job.completed messages related to a particular job, we could do this by adding the following in the Constraints field:

Type=job.completed,Job.Id=$expenseResult[0].Id

where -

  • Job.Id is the Job ID of all the job.completed events that may be occurring
  • $expenseResult is a variable that was used to capture the entire JSON returned in a response from an Integration module that started a UiPath job just previously in the same Flow
  • Id is the Job ID that was created by the job that was started within the same Flow

The full result from the initial Start Job call is returned in an array (a list). The [0] appended to the variable indicates that we are referencing the first line of that array only.

The response from this event would be returned as below:

{ 
   "Type":"job.completed",
   "EventId":"a58743a7a0f1442ca5e576ab144f9f6a",
   "Timestamp":"2020-01-31T15:54:52.8941258Z",
   "Job":{ 
      "Id":20069292,
      "Key":"9ee4e31f-bb75-4161-b3f6-e0f5ee96a9aa",
      "State":"Successful",
      "StartTime":"2020-01-31T15:54:37.64Z",
      "EndTime":"2020-01-31T15:54:52.7691182Z",
      "Info":"Job completed",
      "OutputArguments":{ 
         "ExpenseID":"ID-1580486092"
      },
      "Robot":{ 
         "Id":227512,
         "Name":"Dev Robot",
         "MachineName":"EVERYDAY-RPA1"
      },
      "Release":{ 
         "Id":194777,
         "Key":"1cbb5620-3b73-4e9f-baa6-a1f64d59ce90",
         "ProcessKey":"DemoExpenseProcess"
      }
   },
   "TenantId":33333,
   "OrganizationUnitId":12345
}

Output Configuration

When we configure how our event output should be shown to an end-user, we have to configure three fields - Variable, Event Message & Subscription Error Response.

Variable

Variables are used to capture the result that is returned by the event. The event's entire response is returned in JSON - we must store this in a variable which allows us to extract specific values within it when needed.

If we use a variable $subscriptionResult we would be setting it with the entire JSON returned by the event. Once we have set the variable, we can use it in the Event Message field (see below).

Event Message

Using the previous example of the response from a job.completed event, we want to create a message that informs the end-user of that job completing, as follows:

Job 20069292 has completed

In order to configure this we would need to add the following in the Event Message response field:

Job $subscriptionResult.Job.Id has completed

where -

  • $subscriptionResult is a variable that was used to capture the entire JSON returned in the subscribed event's response
  • Job.Id is the ID that was created by the job that was started within the same Flow

Notice that the subscribed event response was not returned in an array, so we don't append [0] to the variable

We access items in the variable using standard JSON notation, by first having $subscriptionResult equal to the entire object returned by the UiPath event. We then dig deeper by targeting an individual key - in the above example, targeting Job.Id within the overall result.

Subscription Error Response

The subscription error response is provided to an end-user when we are unable to subscribe to any given event that was specified within the Subscribe module. This is not linked to the Event Message, and is instead related solely to the UiPath Subscribe module action.

Further help

Getting Started with UiPath
Prebuilt UiPath Integrations
UiPath Flow Example

Still need help? Get in touch!
Last updated on 3rd Apr 2020