UiPath Flow Example

Example Overview

For this example, we have a UiPath automation that creates a simple expenses request, requiring four input arguments. We wish to trigger it via a Humley Studio flow and will be returning one of the resulting output arguments to the end-user. The assumptions for this example are as follows -

Process Inputs

Inputs passed to the UiPath process in order to authenticate and to select the job & robot -

  • Domain
  • Username
  • Password
  • TenancyName
  • RobotID
  • ReleaseKey

End-user Inputs

The inputs gathered from the end-user and passed to the UiPath process -

  • date
  • type
  • amount
  • description

End-user Output

The process, when successful, creates the expense claim and returns an output with a wide range of data. We will be returning one output argument to the end-user -

  • ExpenseID

In the following step-by-step example, we will :-

Set up a UiPath Integration Template

Unless already existing, we need to set up a UiPath Integration Template to allow access to the the UiPath requests.

See how to Set up a UiPath Integration Template

Create a Flow-type Intent

We need to create a Flow-type Intent that will trigger the Flow. The Flow and its basic details can be created here also.

See how to Create a Flow Intent

Build the Flow

Edit the Flow to gather the end-user inputs, call the UiPath Integration (to start a UiPath job) and respond with the job's output.
Open it from the Flow page or navigate to it from the Flow-type intent that will trigger it.

Add Gather modules

Ask for information and record it in a variable. Set prompt, success, and failure responses.

In this example, we will start with the first required input - date

Click the Add icon below the last module and select the Add Module option

Choose the Gather module-type in the sidebar

Enter in the sidebar -

  • Name
    Name the module - e.g. Gather Date

  • Variable
    Create a unassigned variable named $expenseDate

  • Prompt
    Enter the prompt to the end-user - e.g. What is the date of this expense? (DD/MM/YYYY)

  • Success Response
    Enter the response if the input is valid - e.g. Got it, thanks

  • Fail Response
    Enter the response if the input is invalid - e.g. Sorry, please enter the date of the expense in the following format - DD/MM/YYYY

Click Create Module in the sidebar

The new Gather module will be shown on the Flow's canvas.

In the same way as above, we add three more Gather modules to capture expenseType, expenseAmount, and expenseDesc.

To add validation to any of the end-user inputs, create some entities and either use those in the Gather modules or assign the variables to them

Add an Integration module

Add an Integration module to the Flow that will trigger the UiPath Integration that starts the UiPath process (in this example, starting a job).

Click the Add icon below the last module and select the Add Module option

Choose the Integration module-type in the sidebar

Enter in the sidebar -

  • Module Name
    Name the module - e.g. Add Expense Line

  • Base URL
    The base Integration that contains the request you want to make - e.g. UiPath Cloud

  • Request
    The integration Request that you want to make - e.g. Jobs - Start Job With Inputs

    When the Request is selected, more sections are revealed with labels relevant to that Request (see below)

Request Configuration section

Specify the entities or variables you are capturing in the flow, or free text, that will populate the UiPath Integration's request parameters.

The fields here will match the Request Parameters in the selected Request.

  • In each field, enter an Entity, a Variable or Freetext that you want passed to the corresponding request parameter. The field's tool tip should explain the request parameter's purpose.

    Start typing in the Search or Create field to either -

    • Create a new entity or unassigned variable (You shouldn't need to create any entities or variables in this module in this example as you've already created them in the Gather modules, above).

    • Select an existing entity or variable

    • Add a free text value

The method used depends on the type of information we're passing to the UiPath process i.e. the data provided by the end-user, or the data needed to authenticate with UiPath and identify the job & robot.

For this example we are using the Jobs - Start Job With Inputs integration Request which needs inputs for the request parameters as shown below. In this example we using all free text, although entities and/or variables can also be used if needed -

  • input_arguments - {\"date\": \"$expenseDate\", \"type\": \"$expenseType\", \"amount\": $expenseAmount, \"description\": \"$expenseDesc\"}

    The input_arguments parameter is a JSON object that can contain multiple key value pairs. Pass the values as seen above.
    When entering this type of JSON object into a request parameter, double quotes need to be 'escaped' with a backslash.
    The number and names of the keys depend on the UiPath process you're passing them to.
    Note that the value for the amount key (i.e. the $expenseAmount variable) is not enclosed in double quotes. This is because the UiPath process needs this input to be passed as an number, not a string. Read more about JSON datatypes here

  • no_of_robots - e.g. 0

  • release_key - e.g. 1cbb5620-3b73-4e9f-baa6-a1f64d59ce90

  • robot_ids - e.g 227512

  • source - e.g. Manual

  • strategy - e.g. Specific

Set Variables section

As mentioned previously, we need to wait for a response from the UiPath process. This will be handled by a following UiPath Subscribe module, which will subscribe to an event linked to the specific Job started by this Flow. To capture that Job ID, we need to capture the response from the Start Jobs With Inputs request (the reponse definition value) and hold it in a variable.

Enter in the sidebar -

  • value
    Create a variable named $expenseResult and set it here

Configure Response section

As mentioned previously, we need to wait for a response from the UiPath process once that process has finished. This response to the end-user will be handled by the UiPath Subscribe module below, but we may want to inform the end-user that the process has been started in the meantime.

Enter in the sidebar -

  • Return Response checkbox
    Check (checked by default) so that we can return a response

  • Success Response
    Enter freetext to be returned following a successful request - e.g. Your expense claim is being processed. You'll be provided with an expense ID once processing has finished.

  • Fail Response
    Enter freetext to be returned following a failed request - e.g. Your expense could not be logged. Please contact your HR representative.

Click Create Module in the sidebar

The new UiPath Integration module will be shown on your Flow's canvas.

Add a UiPath Subscribe module

Add a UiPath Subscribe module to subscribe to UiPath events and asynchronously receive event data back from the UiPath process.


In this example we are interested in the job.completed event for the job that was started by the Integration module we've just created, but first we need to tie that event to the correct Job ID. We can do this by looking at the response from the Start Job With Inputs request we made to start the job in the previous flow module.

The response for the Start Job with Inputs call was output as a JSON object into value and stored in the $expenseResult variable as follows:

[ 
   { 
      "Key":"9ee4e31f-bb75-4161-b3f6-e0f5ee96a9aa",
      "StartTime":null,
      "EndTime":null,
      "State":"Pending",
      "JobPriority":"Normal",
      "Source":"Manual",
      "SourceType":"Manual",
      "BatchExecutionKey":"96f3fb71-d83e-4de8-a2ec-d97b69a9ca74",
      "Info":null,
      "CreationTime":"2020-01-31T15:54:32.4055389Z",
      "StartingScheduleId":null,
      "ReleaseName":"DemoExpenseProcess_Standard Environment",
      "Type":"Unattended",
      "InputArguments":"{\"date\":\"01/01/1990\",\"type\":\"Travel\",\"amount\":\"23.89\",\"description\":\"Train ticket (return)\"}",
      "OutputArguments":null,
      "HostMachineName":null,
      "HasMediaRecorded":false,
      "PersistenceId":null,
      "ResumeVersion":null,
      "StopStrategy":null,
      "RuntimeType":"NonProduction",
      "ReleaseVersionId":null,
      "EntryPointPath":null,
      "Id":20069292
   }
]

The value of the Id key is what we need. So, we can extract that from the JSON response with $expenseResult[0].Id

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

We can then narrow the subscription down to a job.completed event, which can then narrowed down to the relevant Job with Type=job.completed,Job.Id=$expenseResult[0].Id, in this case 20069292.

For a full list of events that you can subscribe to, see UiPath's events documentation

The response for this job.completed event was output as a JSON object into value and stored in the $subscriptionResult variable as follows:

{ 
   "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
}

We will store this whole response (again, a JSON object) in a variable, e.g. subscriptionResult and can extract the desired piece of information from the OutputArgument like so - $subscriptionResult.Job.OutputArguments.ExpenseID, in this case ID-1580486092

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


Click the Add icon below the last module and select the Add Module option

Choose the UiPath Subscribe module-type in the sidebar

Enter in the sidebar -

  • Name
    Name the module - e.g. Subscribe to Job Completed Event

Input Configuration section

Specify the details you are providing for the Events Subscription.

Enter in the sidebar -

  • TenancyName
    Enter a value as freetext - e.g. abcTenancy1

  • Username
    Enter a value as freetext - e.g. uipathteam@example.com

  • Password
    Enter a value as freetext - e.g. UiPathpassw0rd

  • Domain
    Enter a value as freetext - e.g. https://platform.uipath.com

  • Events
    The events you wish to subscribe to (comma separated) - e.g. job.completed

  • Constraints
    The constraints (comma separated) - e.g. Type=job.completed,Job.Id=$expenseResult[0].Id

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

  • 'Restrict to first event' checkbox
    Check to close the subscription after the first response (defaults to checked). The process in this example will only return results once, so keep this checked.

Output Configuration section

Specify the variable that will be populated with all the data passed back from the subscribed events, and the Success and Error Responses

Enter in the sidebar -

  • Variable
    The variable that will be populated with the data passed back from the subscribed events. Unlike Integration modules, there is only one variable field as this will capture the entirety of the event's output.

    Start typing in the Search or Create field to either -

    • Select an existing variable

    • Create a new variable (If you create a variable from here, it will be unassigned. Once you've finished building your Flow, you may need to Assign the Variable to an Entity).

    In this example, we will need to create a new unassigned variable - e.g. $subscriptionResult and set it here.

  • Event Message The response given to the end-user following a successful response from the subscribed events - e.g. Your expense claim has been recorded under $subscriptionResult.Job.OutputArguments.ExpenseID

  • Subscription Error Response The response given to the end-user following a failed response from the subscribed events - e.g. Sorry, an error occurred so no Expense ID can be given. Please contact accounts@abc-corp.com about this expense claim.

Click Create Module in the sidebar

The new UiPath Subscribe module will be shown on your Flow's canvas.

Save the Flow

Save your finished Flow to ensure you don't lose your work.

Click Save Flow in the sidebar

Your new Flow will be shown on the Flow list page.


Further help

Getting Started with UiPath
Prebuilt UiPath Integrations
Subscribe Module within Flow

Still need help? Get in touch!
Last updated on 5th Jun 2020