# Validating stream results with Communications Mining

> This quickstart guide helps you start validating stream results by adding the Validation Station within UiPath® Action apps, and then sending them out for validation through Action Center as App actions. The tutorial uses UiPath® Studio to automate processing stream results, UiPath® Apps to display the validation station, and Action Center to perform the validation. The document type used in the examples throughout this tutorial is a health insurance form, of type CMS 1500 claim form.

This quickstart guide helps you start validating stream results by adding the Validation Station within UiPath® Action apps, and then sending them out for validation through Action Center as App actions. The tutorial uses UiPath® Studio to automate processing stream results, UiPath® Apps to display the validation station, and Action Center to perform the validation. The document type used in the examples throughout this tutorial is a health insurance form, of type CMS 1500 claim form.

The overview steps of this quickstart guide are:

1. Build the Action app that displays the Validation Control.
2. Use a previously configured app to design the Studio automation that processes the stream results and sends it out for validation in Action Center.
3. Complete the action within Action Center.

## Steps

### 1. Build an Action app

#### Prerequisites

Make sure your tenant:

* Has sufficient Robot units since the app runs using Serverless robots.
* A Serverless robot template is created in Orchestrator and provisioned. For more information on serverless robots and adding them to a tenant, visit [Executing unattended automations with Serverless robots](https://docs.uipath.com/orchestrator/automation-cloud/latest/user-guide/executing-unattended-automations-with-serverless-robots).

#### 1. Create an Action app

:::note
Unlike VB apps available via the Apps service, apps can be accessed through Studio Web.
:::

To create an Action app, follow these steps:

1. Go to Studio Web.
2. Select **Create New**, and then select **App** to create a new project.
3. Within the **Project Explorer** of your app, select **Add pages, workflows, controls, integrations**, and then select **Action**. This step adds an **Action** to your app, and allows you to configure an action schema for it.
4. Expand **Action**, and select **ActionSchema**. Configure the action schema with the In and Out arguments that you want for App actions in Action Center.
   1. For **Outcomes**, add other custom outcomes that you want the action to have.

      For example, you can add the a custom outcome, named `Approve`.
   2. For **Input Properties**, add properties for data that you want to pass into the action. These properties will appear in the [Create App Task](https://docs.uipath.com/activities/other/latest/workflow/create-user-action) activity when this app is selected from the **Apps** dropdown list. Input properties allow you to pass data from your Studio automation to your action.
   3. For **Output Properties**, add properties for arguments that you want to retrieve from the action. These properties will be accessible from the [Wait for App Task and Resume](https://docs.uipath.com/activities/other/latest/workflow/wait-for-user-action-and-resume) activity, through the **Task Object (Output)** variable.
   4. For **Input/Output** properties, add properties that function as In/Out arguments in your Studio automation. These Input/Output properties first appear as properties in the **Create App Task** activity, which you pass to the action. And then, after the action is completed, you can access the same properties that were updated from the **Wait for App Task and Resume** activity, through the **Task Object (Output)** property.

#### 2. Add and customize the Validation Control

A Validation Control incorporates the Validation Station used in processing workflows that contain stream results. To add and customize a Validation Control within an Action app, follow these steps:

1. Open the desired Action app, where you want to incorporate the Validation Station.
2. Select **Open toolbox**.
3. Under **Display**, find the **Validation Control**, and add it to your app.

   Adding the Validation Control to your app automatically creates a `Var<ValidationControl_PageName>` variable under the **App variables** section from the **Project Explorer** of your application.

   :::note
   You can use the Validation Control and the corresponding App Variable to read information from the Validation Control. Use the `Var<ValidationControl_PageName>` App Variable to write information to it.
   :::
4. Prepare the action schema:
   1. In the **Project Explorer**, under **Action**, select **ActionSchema**.
   2. In the **Input Properties**, select **Add property**.
   3. In the property search bar, select **More Options**.
   4. Under **Advanced**, select **ContentValidationData**.

      This is the input property that will display in the **Create App Task** activity. The **ContentValidationData** input property requires a `ContentValidationData` object as input, which can be a single object or an array/list of `ContentValidationData` instances. `ContentValidationData` contains the artifacts of the Validation Station. `ContentValidationData` is created using the [Create Communications Mining Validation Artifacts](https://docs.uipath.com/activities/other/latest/communications-mining/create-communications-mining-validation-artifacts) activity.
5. Configure the Validation Control:
   1. Go to the **Validation Control** properties.
   2. In the **Source** input, select the **Action** input you have defined as a `ContentValidationData` type.
6. Configure the rest of the app with other controls you need.

#### 3. Create events for the Validation Control

You can trigger various events specific to the Validation Control. In the **Project Explorer**, navigate to the Validation Control, and select it. The **Events** panel of the Validation Control allows you to define automations for specific events.

The following table describes the available Validation Control events:

Table 1. Validation Control events

| Event | Description |
| --- | --- |
| **On Ready** | Triggers when the Validation Control is loaded. |
| **Document Type Changed** | Triggers when the user changes the document type from the Validation Control. |
| **Field Selected** | Triggers when the user selects one of the fields, or the value of a field, in the Validation Control. |
| **Field Value Changed** | Triggers when the user adds, removes, or replaces a field value in the Validation Control. |

#### 4. Use dedicated Validation Control activities

You can use specific activities dedicated to working with the Validation Control, from the [AppEvents.Activities](https://docs.uipath.com/activities/other/latest/workflow/about-the-app-events-activities-pack) package:

1. **Set Validation Control Field Focus**: Allows you to focus on a field, based on a configured event.
2. **Save Validation Control State**: Saves the state of the Validation Control. You can use this when you want to revisit and complete the validation later.

#### 5. Publish and deploy the app

After you build your Action app and trigger automations for Controls inside of it, you can publish it. Publishing the app makes it available to use for creating App actions. For more information on publishing apps, visit [Publishing, deploying, and upgrading app projects](https://docs.uipath.com/studio-web/automation-cloud/latest/user-guide/publishing-deploying-upgrading-web-app-projects).

### 2. Create Studio automation

#### Prerequisites

* Install the following activity package versions:
  + CommunicationsMining.Activities version 1.5.1 or higher.
  + Persistence.Activities version 1.5.5 or higher.
  + AppEvents.Activities version 3.12.0 or higher.
* Create a storage bucket in Orchestrator, in the same folder where you want to publish the automation that processes stream results. Data required to load the Validation Control within apps is stored within an Orchestrator storage bucket.
* Add the stream results that you want to process inside the Studio project folder.
* Optionally, if you want to use generative extraction or validation capabilities, then you need AI units. For more information on the **Generative Extraction** feature in Communications Mining™, visit [Generative Extraction](https://docs.uipath.com/communications-mining/automation-cloud/latest/user-guide/overview).

#### 1. Process a file using Communications Mining

Add activities that use Communications Mining™ to process a file. Prepare the stream result for validation in Action Center, through apps, using digitization and extraction.

After adding the activities for processing the file, the following variable should be available:

* Output stream result: The stream result is stored in a variable in the output property, **Results**, of the **Get Stream Results** activity.

#### 2. Send out the validation information to the app

After the stream result is ready to be validated, you can prepare all the information to be sent out to the previously created and deployed app. Follow these steps:

1. Add a **Create Communications Mining Validation Artifacts** activity to create the `Content Validation Data` object, which stores the information necessary for loading the Validation Control within the Action app. In this example, configure the activity using the previously created or outputted variables:
   * **Orchestrator Bucket Folder Path**: The name of the Orchestrator folder that hosts the storage bucket where you want to create the action.
   * **Orchetsrator Bucket**: `storageBucketName`
   * **Orchestrator Bucket Directory Path**: The directory path within the previously inputted storage bucket where you want to store action data
   * **Input Stream Result:** The stream result that you want to validate. Use one of the entries in the output variable of the [Get Stream Results](https://docs.uipath.com/activities/other/latest/communications-mining/get-stream-results) activity, which is a collection of results. Select one of the entries using, for example, `<getStreamResultsOuputVariable>.Results(<index>)`.
   * **Model**: The model corresponding to the input stream result. Use the Model property of the output variable of the [Get Stream Results](https://docs.uipath.com/activities/other/latest/communications-mining/get-stream-results) activity, found under `<getStreamResultsOuputVariable>.Model`.
   * **Timeout (milliseconds)**: Specify waiting time (in milliseconds) for the activity to connect to Orchestrator before an error is thrown.
   * **Content Validation Data**: The output variable where all the information about the processed stream result and the information on the location of action data is stored. You later use this output variable as input for the **Retrieve Communications Mining Validation Artifacts** activity.
2. Add a [Create App Task](https://docs.uipath.com/activities/other/latest/workflow/create-user-action) activity, so you can bind the object to the previously designed app and then send it out to Action Center for validation. In this example, configure the activity as follows:
   * **Title**: `CVD`
   * **Priority**: `Medium`
   * **Apps**: `Demo.Validation.Control.in.Apps`
   * **App Version**: v2.0.0 After you select the App, and the corresponding version that you want to use for creating the action, the input properties of that app will be shown in the body of the activity.
     + In this example, one of the input properties is **Action_Content_Validation_Data**, which requires the Communications Mining™ validation artifacts previously created: `contentValidationData`.

   Figure 1. The Create App Task activity

   ![The Create App Task activity](https://dev-assets.cms.uipath.com/assets/images/activities/communications-mining-the-create-app-task-activity-526146-c9257ca4-71511c00.webp)
3. Add a [Wait for App Task and Resume](https://docs.uipath.com/activities/other/latest/workflow/wait-for-user-action-and-resume) activity to return the information about the action, and resume the workflow. In the **Created App Task** field, enter the output variable of the **Create App Task** activity.
4. Add a [Retrieve Communications Mining Artifacts](https://docs.uipath.com/activities/other/latest/communications-mining/retrieve-communications-mining-artifacts) activity to return the Communications Mining validation artifacts after the user has performed validation in Action Center. Pass the output variable of the **Create Communications Mining Validation Artifacts** activity as the input of the **Retrieve Communications Mining Artifacts** activity.

### 3. Perform validation in Action Center

1. Open Action Center, and go to **My Actions** or **Manage Actions**.
2. In the **Unassigned** tab, find the action you just created using the previous Studio automation.
3. If you want to assign the action to yourself, select the desired action, and then select **Assign to self**.
4. If you want to assign the action to another user, select **More options** for the desired action. Then select **Assign to user**, and select a user from the dropdown list.
5. Go to the **Pending tab**, and complete the action, so the Studio workflow can be resumed.
