Free cookie consent management tool by TermsFeed

Use Models in a Process

On This Page
The capabilities described on this page are included in Appian's advanced and premium capability tiers. Usage limits may apply.

This page describes how to integrate an AI-powered document extraction model into another process model within your Appian application.

Integrate extraction into your process model

Once you've built and tested a document extraction model, you can integrate it into an existing process model.

At a high level, you'll complete the following steps:

  1. Set up record types.
  2. Create or update your process model.
  3. Integrate reconciliation tasks.
  4. Add a trigger to your DocCenter extraction model.
  5. Test and deploy.

Step 1: Set up your record types

To be useful, extraction results must be saved to your data fabric. To do this, set up record types to save those results from DocCenter. These record types also serve as the basis of reconciliation tasks, so it is essential to structure data in logical ways.

Tip:  Throughout these instructions, we use passports as an example of documents you'll want to extract data from. The record type names and fields below are suggestions, which you can adapt to your own application or use case as needed.

First, you create two record types:

  1. Record type to store your document, fields, and the associated extraction instance (e.g. ABC Passport Document), containing these fields:
    • id Primary key; Number (Integer)
    • appianDocumentId Number (Integer)
    • extractionInstanceId Number (Integer)
    • firstName Text
    • lastName Text
    • dateOfBirth Date
    • gender Text
    • nationality Text
    • documentNumber Number (Integer)
    • issueDate Date
    • expirationDate Date
    • issuingCountry Text
  2. Record type to store visa data (e.g. ABC Passport Visas), containing these fields:
    • id Primary key; Number (Integer)
    • passportId Number (Integer)
    • country Text
    • date Date

You'll add record type relationships to show connections between record types, and make it easier to reference the data in those related record types. You can add relationships when you set up your data model or afterward.

Tip:  If your application manages documents in the context of cases or other record types, consider creating additional fields and relationships to associate those record types with these new record types.

You may need to create additional record types if your documents contain tables.

Create the following record type relationships. These instructions use the example record type names listed above. Replace these names with the ones you've chosen for your new record types:

  1. In the document record type (ABC Passport Document), add two relationships:
    1. Add a relationship with AIA Extraction Instance (a record type within the DocCenter application):
      • Relationship Type: Many-to-one
      • ABC Passport Document - extractionInstanceId
      • AIA Extraction Instance - id
    2. Add a relationship with ABC Passport Visas:
      • Relationship Type: One-to-many
      • ABC Passport Document: id
      • ABC Passport Visas: passportId
      • Allow this record type to write and delete related records
  2. In the extracted fields record type (ABC Passport Visas), add one relationship:
    1. Add a relationship with ABC Passport Document:
      • Relationship Type: Many-to-one
      • ABC Passport Visas: passportId
      • ABC Passport Document: id

Tip:  Although ABC Passport Document has a relationship to AIA Extraction Instance, you don't need to create the same relationship in the AIA Extraction Instance record type. We recommend you don't edit AIA Extraction Instance record type at all.

Your data model should resemble this diagram:

Data Model

Step 2: Create or update your process model

Now that you've created some supporting design objects, you're ready to put them together in a process model. After you work through the steps in this section, your process model will look something like this:

Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to closeExtraction process model

This section walks you through how to:

To begin, create a new process model or open an existing process model where you want to integrate extraction.

Create process variables

Once you create a process model, you'll need to create process variables to pass data.

Variable name Type Value Parameter? Required? Multiple? Hidden?
cancel Boolean - Yes No No No
document Document - Yes Yes No No
extractionInstance AIA Extraction Instance (Record Type) - No N/A Yes No
passportDocument ABC Passport Document (Record Type) - No N/A No No

Configure a start form

In this example, documents are passed into the process model through a start form. Regardless of how you configure document ingestion, pass the document ID to the process model and map it to pv!document.

Add extraction as a subprocess

  1. In the palette, find the subprocess node.
  2. Drag the node to the canvas and drop it after the Start Node.
  3. Open the subprocess properties.
  4. Click the Setup tab.
  5. In the Run this process model field, select the AIA Extraction Run Model Version process model.
  6. Configure the Input Variables as follows:

    Variable Description Required?
    document (Document) Map with pv!document

    If running a multi-instance node, append [tp!instanceIndex] to the process variable.
    Yes
    input (Text) Leave empty. No
    isDocumentTestCase (Boolean) Leave empty. No
    modelKey (Text) Key for extraction model Yes – this value is set when you create an extraction model. For example: "passportExtraction". You can also view the model key on the Update Details screen.
    modelSuiteId (Number (Integer)) Leave empty. Used only when triggering test runs of the model. No
    modelVersionId (Number (Integer)) Leave empty. Version ID for extraction model. No
    testRunProcessId (Number (Integer)) Leave empty. Used to manually choose which version of the model to run. When left blank, uses the latest published version. No
  7. Click OK.

Create a subprocess to map extracted data

To help keep the parent process tidy, we recommend creating a new process model for the next few steps. This process model will be added as a subprocess to the overall process model you worked on in the previous steps. For demonstration purposes, we'll call this second process ABC Map Extracted Data.

Create process variables

Create the following process variables to pass data to and from the parent process:

Variable name Type Value Parameter? Required? Multiple? Hidden?
extractionInstance AIA Extraction Instance (Record Type) - No N/A Yes No
passportDocument ABC Passport Document (Record Type) - No N/A No No

Map extracted data

In your process, add a script task to cast the extracted data to your record fields. You'll leverage the expression rule rule!AIA_API_Extraction_ConvertInstanceIdToMap, which is included with the DocCenter application.

  1. In the palette, find the Script task.
  2. Click the Data tab and select Outputs.
  3. Click New Custom Output. The Expression Properties for the node output display.
  4. For Expression, open the expression editor to create an expression to cast data to the record type:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    
    a!localVariables(
       local!fields: rule!AIA_API_Extraction_ConvertInstanceIdToMap(pv!extractionInstance[recordType!AIA Extraction Instance.id]),
       recordType!ABC Passport Document(
       recordType!ABC Passport Document.id:
       /* The ID field uses logic in this expression so you can use this subprocess to map data during initial extraction or after reconciliation. */
          a!defaultValue(
             /*on initial extraction, passportDocument can be passed in directly from parent process*/
             value: pv!passportDocument[recordType!ABC Passport Document.id],
             /*on trigger, query for existing record using the Appian document id*/
             default: rule!SHRD_UTIL_QueryRecord(
             recordType: recordType!ABC Passport Document,
             returnType: "SINGLE_OBJECT",
             filters: a!queryFilter(
                field: recordType!ABC Passport Document.appianDocumentId,
                operator: "=",
                value: pv!extractionInstance[recordType!AIA Extraction Instance.documentId]
                )
             )[recordType!ABC Passport Document.id]
          ),
          recordType!ABC Passport Document.extractionInstanceId: pv!extractionInstance[recordType!AIA Extraction Instance.id]
          recordType!ABC Passport Document.appianDocumentId: pv!extractionInstance[recordType!AIA Extraction Instance.documentId],
          recordType!ABC Passport Document.firstName: local!fields.firstName,
          recordType!ABC Passport Document.lastName: local!fields.lastName,
          recordType!ABC Passport Document.dateOfBirth: local!fields.dateOfBirth,
          recordType!ABC Passport Document.gender: local!fields.gender,
          recordType!ABC Passport Document.nationality: local!fields.nationality,
          recordType!ABC Passport Document.documentNumber: local!fields.documentNumber,
          recordType!ABC Passport Document.issueDate: local!fields.issueDate,
          recordType!ABC Passport Document.expirationDate: local!fields.expirationDate,
          recordType!ABC Passport Document.issuingCountry: local!fields.issuingCountry,
       )
    )
    
  5. Click SAVE AND CLOSE.
  6. In the Target field, select the passportDocument process variable.
  7. Click OK.
  8. Save and publish the process model.

Call the subprocess from the parent process model

After you save and publish the subprocess to map extracted data, you need to call it from the parent process.

  1. Return to the parent process which you began editing in step 1.
  2. In the palette, find the subprocess node.
  3. Drag the node to the canvas and drop it after the Start Node.
  4. Open the subprocess properties.
  5. Click the Setup tab.
  6. In the Run this process model field, select the process model you created in the previous step (ABC Map Extracted Data).
  7. Configure the Input Variables as follows:

    Variable Process variable
    extractionInstance pv!extractionInstance
    passportDocument pv!passportDocument
  8. Click OK.

Step 3: Determine when and how you want to reconcile results

To help ensure accuracy, you may want to build reconciliation tasks into your document extraction workflow. After reconciliation, model accuracy and other performance metrics are updated at a field, document, and model version level.

Reconciliation is only needed if an extraction instance has a status of Extracted with Errors, or if a user identifies incorrect data during downstream processing.

DocCenter includes a Reconcile Fields related action on the AIA Extraction Instance record type to reconcile results. You can launch this action as a related action on the instance within DocCenter. If you prefer, you could also add the related action to any interface you choose. For example, you might find it useful to create an interface that shows only instances that contain errors in their extractions. A separate interface could be useful to help surface extraction instances requiring reconciliation within the application or workflow reviewers are completing work.

Step 4: Add a trigger to map reconciled fields

Finally, you'll add a trigger to automatically map and write the reconciled values to the ABC Passport Document record type.

  1. In DocCenter, go to Extraction > Models.
  2. Select the model you're using to extract data.
  3. Got to the Triggers tab.
  4. Click CREATE TRIGGER.
  5. In the Run this process model field, select the process model that maps reconciled data and writes to your record type. For example, your process model might use the Write Records smart service.

If you want to initiate other downstream workflows following reconciliation, you can add additional triggers. Triggers are useful to start other processes that rely on the reconciled data, such as sending the information to the finance or legal departments for specific processes.

Optional step: Add downstream processes

Document processing often fits in the context of a broader process model. For example, after data is extracted from a passport, that data may be used to start related processes, like creating a user profile, comparing and validating data with an external system, or having a person in the HR department review an application.

How you integrate a downstream process is unique to your business. You can integrate additional processes as subprocesses, especially if you want to use unreconciled data. If you plan to leverage reconciled data in a downstream process, use additional triggers to easily and automatically start a process after the reconciliation task is complete.

Step 5: Test and deploy

Remember to test your process model thoroughly before deployment to ensure it works as expected.

Once finished, deploy your models to higher environments.

Feedback