# Consuming models from different environments

> When using Document Understanding<sup>TM</sup> modern projects, you need to configure an external application to access models across various tenants and organizations.

When using Document Understanding<sup>TM</sup> modern projects, you need to configure an external application to access models across various tenants and organizations.

This procedure offers a comprehensive overview on how to access models deployed in different environments using external applications. It includes step-by-step instructions on configuring an external application for access rights, setting up the Studio workflow to consume these models, and establishing production workflows.

This functionality also allows you to use models in hybrid deployment environments. In this case, Document Understanding projects are configured on Automation Cloud<sup>TM</sup>, while Orchestrator and Robots are deployed on-premises.

1. Configure an external application
2. Configure UiPath Studio workflow
3. Configure model versions as parameters
4. Document Understanding Process template

## Configure an external application

1. Navigate to your Automation Cloud tenant.
2. Go to the **Administration** page and select your organization.
3. Go to the **External applications** page.

   ![Screenshot of the External applications button.](https://dev-assets.cms.uipath.com/assets/images/document-understanding/document-understanding-screenshot-of-the-external-applications-button-541380-50127114-9a1f19ed.webp)
4. Select **Add Application** from the **External applications** page.
   :::tip
   For more information on adding an external application, check the [Managing external OAuth applications](https://docs.uipath.com/automation-cloud/automation-cloud/latest/admin-guide/managing-external-applications) page from the Automation Cloud admin guide.
   :::
5. Type in a unique name for the application in the **Application Name** field.
6. Select an application type from the **Application type** section:
   * **Confidential application:** suitable for storing the **App Secret** securely. Use this for high-security requirements.
   * **Non-Confidential application:** use this option only when secure storage for the **App Secret** is not required.

     ![Screenshot of the Application type interface.](https://dev-assets.cms.uipath.com/assets/images/document-understanding/document-understanding-screenshot-of-the-application-type-interface-541385-60f503e1-7e973765.webp)
7. Define the access scopes for your external application.
   1. Select **Add Scopes** from the **Resources** section.
   2. Select **Document Understanding** from the **Resource** drop-down list.
   3. Configure **User scope(s)** to grant permissions within a user context.

      Select the checkboxes corresponding to the logical API permissions you want to grant as per your requirement in the **User scope(s)** tab. If you grant permissions under user scope, it is implied that the external application can access those resources within a user context. Therefore, a user with the corresponding permissions must be logged in.
   4. Configure **Application scope(s)** to provide application-level access for broader automation needs.

      If you are using a confidential application, navigate to the **Application scope(s)** tab to allocate application-level permissions for the chosen resource as required. By delegating permissions under the application scope, the external application can access data across the selected scopes without any user interaction.

      Non-confidential applications cannot access the scope of the application.

   ![Screenshot of the Application scope interface.](https://dev-assets.cms.uipath.com/assets/images/document-understanding/document-understanding-screenshot-of-the-application-scope-interface-541403-b88c71e1-b3c9e6f4.webp)

   5. Select **Save**.
      :::note
      If you have registered the external application with user scopes, add a **Redirect URL**. This URL will receive the authorization response. However, if you selected only application scopes, providing a redirect URL is optional.
      :::

8. Select **Add** to create the registration.

   A confirmation message is displayed. For confidential applications, this message includes the app secret. The registered external application can use this secret to request authorization. Ensure you save the app secret in a secure location, as you will not be able to see it again.

   ![Screenshot of the Application successfully added message.](https://dev-assets.cms.uipath.com/assets/images/document-understanding/document-understanding-screenshot-of-the-application-successfully-added-message-541412-bc5f4da1-09862ee5.webp)

## Configure UiPath Studio workflow

Before you begin, make sure that the following prerequisites are met:

* Use a compatible **Windows Project** version.
* Make sure that the **IntelligentOCR** activity package is installed. The **IntelligentOCR.Activities** package supports the consumption of Document Understanding modern projects starting with [v6.22.1](https://docs.uipath.com/activities/other/latest/document-understanding/release-notes-uipath-intelligent-ocr-activities#v6220).

:::tip
For a more detailed understanding of the differences between the **DocumentUnderstanding.Activities** and **IntelligentOCR.Activities** packages, as well as guidance on when to use each of them, check the [Automations in Document Understanding](https://docs.uipath.com/document-understanding/automation-suite/2.2510/user-guide/automations-in-document-understanding#automations-in-document-understanding%E2%84%A2) page.
:::

1. Open your **UiPath Studio** project.
2. Define the taxonomy.
   1. Open **Taxonomy Manager** to define relevant document types and fields for your automation.

      Your project taxonomy should encompass each document type and the necessary fields. The taxonomy you create in Studio can contain additional document types and fields that are not part of the Document Understanding modern projects. If you wish to use additional extractors like the [Form Extractor](https://docs.uipath.com/activities/other/latest/document-understanding/form-extractor) or the [Regex Extractor](https://docs.uipath.com/activities/other/latest/document-understanding/regex-based-extractor) for various document types, this step will be necessary.

      ![Screenshot of the Document type interface.](https://dev-assets.cms.uipath.com/assets/images/document-understanding/document-understanding-screenshot-of-the-document-type-interface-541581-12b271e2-fea5a80c.webp)
3. Install the **IntelligentOCR.Activities** package to use activities such as [Document Understanding Project Extractor](https://docs.uipath.com/activities/other/latest/document-understanding/du-app-extractor) and [Document Understanding Project Classifier](https://docs.uipath.com/activities/other/latest/document-understanding/du-app-classifier).
   1. Add the [Data Extraction Scope](https://docs.uipath.com/activities/other/latest/document-understanding/data-extraction-scope) activity to configure extraction models and include the Document Understanding Project Extractor activity.

      ![Screenshot of the Data Extraction Scope activity.](https://dev-assets.cms.uipath.com/assets/images/document-understanding/document-understanding-screenshot-of-the-data-extraction-scope-activity-541587-260826e4-592cb9c0.webp)
   2. Add the [Classify Document Scope](https://docs.uipath.com/activities/other/latest/document-understanding/classify-document-scope) activity to configure classification models and include the Document Understanding Project Classifier activity.
4. Configure design-time credentials.
   1. Open the **Get Capabilities** wizard from the activity scope.

      The wizard is displayed when you include the **Document Understanding Project** activities within that scope. This wizard allows you to configure design-time credentials needed to map the taxonomy fields of a modern project.
   2. Fill in the following information:
      * **App ID** and **App Secret** from the external application.
      * **Tenant URL** for the target environment.
   3. Select **Get Projects** and choose the needed project and version.
   4. Close the wizard.

      ![Screenshot of the Get Capabilities interface.](https://dev-assets.cms.uipath.com/assets/images/document-understanding/document-understanding-screenshot-of-the-get-capabilities-interface-541594-70accd49-47c11904.webp)
5. Map the taxonomy.
   1. Select **Configure Extractors** within the **Data Extraction Scope** activity.
   2. Create a mapping of the project taxonomy to the model taxonomy for each document type.

      To execute this step, choose a Document Type from the taxonomy and align each field from this Document Type with a corresponding field in the model designed for the Document Understanding Project.

      ![Screenshot of the Configure Extractors interface.](https://dev-assets.cms.uipath.com/assets/images/document-understanding/document-understanding-screenshot-of-the-configure-extractors-interface-541604-5d5a3241-59c9a405.webp)
6. Save the run-time credential as an Orchestrator Asset.
   1. Navigate to your Automation Cloud tenant.
   2. Go to **Orchestrator**.
   3. Choose your automation folder.
   4. Go to the **Assets** tab.
   5. Select **Add asset** and choose **Create a new asset** from the drop-down list.
   6. Type in a name in the **Asset name** field.
   7. Select **Credential** from the **Type** drop-down list.
   8. Use the previously created App ID and App Secret as the **Username** and **Password**.

      ![Screenshot of the Add asset interface.](https://dev-assets.cms.uipath.com/assets/images/document-understanding/document-understanding-screenshot-of-the-add-asset-interface-541616-0e475aba-f9221d58.webp)
7. Configure run-time credentials in Studio.
   1. Navigate to your Studio project.
   2. Go to the Data Extraction Scope activity.
   3. Configure the **Runtime Credentials Asset** property.

      Use this field to access Document Understanding modern project resources while the robot is connected to a local Orchestrator or from a different tenant. You can choose to enter a Credential Asset, for authentication purposes, in one of the following ways:
      * Select the desired credential asset from the Orchestrator to which the robot is connected from the drop-down list.
      * Enter the path to the Orchestrator Credential Asset where you store the external application credentials to access the project. The path format must be as follows: `<OrchestratorFolderName>/<AssetName>`.
   4. Configure the **Runtime Tenant Url** property.

      Use this field together with the **Runtime Credentials Asset** property. Enter the URL of the tenant to which the robot will connect to execute the extraction. The URL must have the following format: `https://<baseURL>/<OrganizationName>/<TenantName>`.

The external application provides access to all Document Understanding projects within the tenant. You do not need to configure access for each project individually.

## Configure model versions as parameters

If you configure project versions as parameters, you can update automation workflows for new project versions without adjusting the workflow code.

1. Navigate to your Automation Cloud tenant.
2. Go to **Orchestrator**.
3. Choose your automation folder.
4. Go to the **Assets** tab.
5. Select **Add asset** and choose **Create a new asset** from the drop-down list.
6. Type in a name in the **Asset name** field.
7. Select **Text** from the **Type** drop-down list.
8. Type in a name in the **Text** field to define a version-specific asset.

   ![Screenshot of the Add Asset interface.](https://dev-assets.cms.uipath.com/assets/images/document-understanding/document-understanding-screenshot-of-the-add-asset-interface-541643-2db44b39-f6046b95.webp)
9. Select **Create**.

   This allows you to update automation workflows for new project versions without changing the workflow code. When the automation is deployed to a specified folder, the model version is set according to the asset in Orchestrator. This process is similar to saving external application credentials as assets.
10. Navigate to your Studio project.
11. Add a [Get Asset](https://docs.uipath.com/activities/other/latest/workflow/get-robot-asset) activity in your workflow to retrieve the version asset.
12. Pass the retrieved value as an input variable to the **Document Understanding Project** activities.

    ![Screenshot of the Get Asset activity in UiPath Studio.](https://dev-assets.cms.uipath.com/assets/images/document-understanding/document-understanding-screenshot-of-the-get-asset-activity-in-uipath-studio-541649-bd514910-798943e7.webp)

## Document Understanding Process template

**Document Understanding Process** is a fully functional UiPath® Studio project template based on a document processing flowchart. You can use it to get started with working on either a demo, or a large-scale implementation of Document Understanding<sup>TM</sup>.

The process provides logging, exception handling, retry mechanisms, and all the methods that should be used in a Document Understanding workflow, out of the box.

For more information, check the [Document Understanding Process template](https://docs.uipath.com/document-understanding/automation-suite/2.2510/user-guide/du-process#document-understanding-process-template) page.
