UiPath: Integrating UiPath Studio and Arria NLG Studio


Documentation for Arria NLG’s Custom Activity for UiPath Studio

This guide takes you through the process of setting up a UiPath sequence that loads data from a CSV file and passes that on as table data to Arria NLG Studio, which then delivers a narrative to be used in subsequent activities.


This documentation is organized as follows:

The Arria Connect custom activity allows you to seamlessly connect your UiPath implementation to Arria NLG Studio. Using this activity, you call an NLG service (a published NLG Studio project) with data passed down from an upstream activity. The resulting narrative is then available to be consumed by a downstream activity, for delivery somewhere else.

Prerequisites:

  • You have installed UiPath Studio (Community Edition or the enterprise version).
  • You have basic knowledge of using UiPath Studio.
  • You have an Arria NLG Studio account. (Get started with a free trial.)

What can Arria Connect do for my automation?

Let’s assume you want to automate something you write – your daily stock portfolio email, weekly sales summary report, or bespoke customer response. You can make this happen by using Arria Connect activities and Arria NLG Studio. In any situation where you want to generate a narrative describing a dataset and then use that narrative inside your automation workflow, Arria Connect activities make it easy, thanks to collaboration with NLG Studio. In NLG Studio, you design the narrative required for your automation, and then grab it from Arria using the API.

In this example you will see how to:

  • Access a CSV file with an example dataset (typical sales data)
  • Create a simple Arria NLG Studio project (Describe a Table) to narrate the dataset
  • Save the narrative into a text file

Note:In this guide, we focus on the Arria Connect UiPath activities. There are endless ways you can integrate narratives with your existing or proposed automation workflows. For ideas, check our Samples library.

We also do not cover Arria NLG Studio concepts in detail. To learn more, try our comprehensive tutorials.

Download and configure the Arria Connect package

To download and configure the Arria Connect package:

    1. Contact Arria to request the Arria Connect package for UiPath Studio.
    2. Copy the package to a local folder (e.g. C:\UiPath\MyPackages).
    3. In UiPath Studio, click Start > New Project > Process.
    4. Give the new project a name (e.g. Connect with Arria) and click Create.
    5. In the Design tab, click the Manage Packages icon.
    6. Add a new package source:
        • Click Settings.
        • Under User defined package sources, in the Name field, type Arria.
        • In the Source field, click the ellipsis (…) to browse for the file location of the Arria Connect package you downloaded.
        • Click Add.

    7. Click All Packages, and select the ArriaConnect package from the list.
    8. Click Install, and then click Save. The ArriaConnect package is installed into the project. In the Activities pane, under Available, you should see the Arria Connect custom activity in your list.

 

Customize an Arria NLG Studio starter project

To get an Arria NLG Studio starter project:

  1. Download the sample dataset. This typical sales dataset contains sales and profit figures for years, products, and the countries and market segments where these products are sold.
  2. Download the Arria NLG Studio starter project. You’ll use this NLG Studio project to output a narrative for the dataset.

 

To set up your NLG Studio project:

  1. In NLG Studio, import the starter project you downloaded.
    • In the top right of the screen, click Import Project.
    • Browse to select the starter project you downloaded, then click Open.
  2. In the dashboard, click the Arria Starter Project for UiPath – Table Type Data card to open the project.
  3. In the left navigation bar, click Compose to go to the starter project’s scripts.
  4. In the list of sub-scripts under the Main script, click the ReadMe script.
  5. Click Preview to check the ReadMe script’s output.
  6. Click Done to exit the preview.
  7. In the Main script, delete the call to ReadMe, then copy/paste the following ATL script:
    For the [[inflectNoun('year',len(unique(Year)))]] [[unique(Year)]], the total sales were [[formatCurrency(totalVal(Sales),currency,'#.00')]] and the total [[direction(totalVal(Profit) ,'profit','loss' )]] was [[formatCurrency(abs(totalVal(Profit)),currency,'#.00')]]. The best-selling product was [[getKey(topNInstancesbyDimension(Product,Sales,1)[0])]] with a total of [[formatCurrency(getValue(topNInstancesbyDimension(Product,Sales,1)[0]),currency,'#.00')]]. The [[getKey(topNInstancesbyDimension(Segment,Profit,1)[0])]] segment reported the most [[direction(getValue(topNInstancesbyDimension(Segment,Profit,1)[0]), 'profit','loss')]] ([[formatCurrency(getValue(topNInstancesbyDimension(Segment,Profit,1)[0]),currency,'#.00')]]).
  8. Click Preview. You should see the following narrative:

 

Create the automation workflow

This section explains how to create your automation workflow in UiPath.

To read the data from the CSV file:

  1. Find the Read CSV activity (under App Integration > CSV) then drag and drop it into the Main screen.
  2. Provide the path to the sample data file that you downloaded earlier (SamplesSalesData.csv).
    • In the Properties pane, from the FilePath field, copy the CSV file name (the FilePath).
    • In the Main pane, select the Read CSV activity, and paste in the FilePath.

      You should see the activity and the sequence as shown:
  3. In the sequence that encapsulates the Read CSV activity, create a new DataTable type variable called inputData. The scope of the variable should be Sequence.
  4. In the Properties panel on the right of the screen, under Output, set the DataTable property to inputData (the name of the variable you have just assigned the loaded CSV file to). This variable will hold the data read from the activity, which can be passed to the Arria Call NLG Service.
  5. Add the Arria NLG Application Scope to the sequence. This is where you set the URL and the API key for the published NLG Studio project.
    • In the Activities panel, in the Arria Connect group, find the Arria NLG Application Scope activity.
    • Drag and drop it into the sequence after the Read CSV activity.

  6. Bring the Call NLG Service Table activity into the Do activity.

Configure the Arria Application Scope and the Call NLG Service activity

To call your NLG Studio project as part of the workflow:

  1. In Arria NLG Studio, publish the project you created and generate its API key.
    • Click Publish > Run Project.
    • Make a note of the published project URL.
    • Click Publish > API.
    • Make a note of the API key.
  2. In UiPath, select the Arria NLG Application Scope, then from the Properties pane, copy/paste in the published project URL and the API key. Note: Both strings of text must be wrapped in quotation marks when you enter them in the Properties pane.

 

To configure the calling of the NLG service:

  1. In the outermost sequence, create a variable.
    • Give it the name outputNarrative.
    • Specify the variable type as String.
  2. In the activity, select the Call NLG Service Table activity.
  3. In the Properties pane, assign both inputData and outNarrative variables.

To output the narrative using a Message Box activity:

  1. Add a Message Box activity to the sequence and assign the outputNarrative variable to the Text attribute.
    • In the Activities pane, click the arrows beside System > Dialog to find the Message Box activity.
    • In the Sequence pane, assign the outputNarrative variable in the Text attribute.

    The completed sequence should look like this:

  2. Click Save. Now you’re ready to run the sequence.
  3. Click Run to start the process. The narrative is displayed in the Message Box.
  4. Try changing the Output Type in the Arria NLG Application Scope, and see how the narrative changes.

Here you can create the content that will be used within the module.