View this page in the latest version of Appian. Tutorial: Build a Document Extraction Process Share Share via LinkedIn Reddit Email Copy Link Print On This Page Tip: Appian highly recommends you use DocCenter for intelligent document processing use cases. Build highly accurate AI-powered document extraction workflows in minutes! Estimated time to complete this tutorial: 1 hour User experience level: Beginner Overview In this tutorial, you'll build an Appian process model that uses an AI skill to extract data from a document. Then, you'll send a task to someone to reconcile the extracted data, and save it as a new record in a record type. Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close This process model relies on a series of nodes that leverage artificial intelligence (AI) to map fields from a document to fields in a record type. Once the data is extracted, users can confirm or correct the results using a simple task interface. As you test your process model and reconcile results, the extraction will become smarter and more accurate over time. This page walks you through how to create your own document extraction process: Create a document extraction AI skill and define your document structure. Create record types to map and save the document and the extraction results. Create additional design objects, like a start form and group, to use in your process model. Configure a basic document extraction process model. Tip: Check out the Document Classification Tutorial to build a process that classifies documents in addition to extraction. Scenario Acme Logistics is a shipping and receiving company that manages inventory for its customers. In addition to physical items, Acme has to manage and act on documents such as invoices. Acme wants to create a process model to extract data from invoices, which customers and vendors submit through Acme's website. Acme also wants to save this data in a record type, so they can easily build reports and interfaces using this data. Setup Before you start this tutorial, complete the following setup. Create an application First, you need to create an application to contain the design objects you'll create in this tutorial. You can use the Application Building Tutorial to quickly create an application for this exercise. If you have an existing application, you can use that instead. Tip: Objects in this tutorial use the AT prefix. If you're creating objects in an application that uses a different prefix, use your application's prefix in new object names. Download example documents Before the AI skill can serve its purpose, it needs to learn a lot about the documents your business encounters. In your own applications, you'll need to build a complete and representative dataset to train the model. The model can only learn from the documents you provide to it, so it's important to have a large number and variety of realistic examples. For this tutorial, we've provided a set of sample Invoices. Download these files to your computer, since you'll use them to setup and train the AI skill. Unzip the compressed folders, as you'll need to upload the documents individually and not as a ZIP file. System requirements This tutorial is designed to be used with Appian 25.2 and later. Part 1: Create AI skill First, you'll create an AI skill. This AI skill takes a document as input and uses machine learning to extract data from that document. To create a document extraction AI skill: In your application, go to the Build view. In the application toolbar, click NEW > AI Skill. The Create AI Skill dialog displays. Expand the Extraction section and choose Document. Choose Semi or Highly Structured. Configure the following properties: Property Value Name AT_ExtractInvoice Description (Optional) AI skill to extract data from invoices Acme receives. Click CREATE. In the Review AI Skill Security dialog, keep the default settings. The AT Users group should be assigned Viewer permissions. The AT Administrators group should be assigned Administrator permissions. Click SAVE. Create a model and add documents Now, you'll create a model and add examples of a typical invoice. To start creating the model: In your new AI skill, click + CREATE FIRST MODEL. For Document Layout, keep Semi-structured selected. For Documents, click UPLOAD to add all training documents. After the documents finish uploading, click NEXT. Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close Define the invoice structure Next, you'll define the fields you want to extract from the document, and the type of data those fields will contain. You should provide the fields that appear on most invoices. To define which fields to extract: In the Field Name, enter name. Keep the data type as Text. Click Add Field six more times, so you have a total of seven fields. Keep the default data type of Text for all fields. Enter the following field names: email phone address invoiceNumber date total Click Add Field again. For Field Name, enter items and select the data type Table. In the nested table fields that appear below items, add three additional table fields so you have a total of four fields. Keep the default data type of Text for all fields. Enter the following field names: quantity description unitPrice amount Click NEXT. Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close Label field data Once you define which fields to extract, you'll indicate where those fields appear in the sample documents. This process is called labeling and it helps the model learn more about where these fields appear in your documents. To label field data: In the document preview, click and drag your mouse around the company name to create a selection box. In the dropdown that appears, click name. Repeat steps 1 and 2 until you've labeled values for all fields in your invoice structure. As you label values, note that you do not need to capture the field label on the invoice in your selection box. For example, in the image below, we are only labeling the value $2,863.99, not the text Total Due. Note: You won't label the fields in the items table, but that information will still be extracted. Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close Above the document preview, click NEXT to label fields in the other sample documents. You should label all 28 sample invoices to get the most accurate results from this tutorial. Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close Click SAVE. Click REVIEW. Note: Each field will need labels in at least half of the documents you uploaded. If you haven't labeled enough fields in the set of documents you uploaded, you'll see a message encouraging you to add more files and fields. Click TRAIN MODEL. Training may take a few minutes. While you wait, proceed to create the record types you'll use to store extracted data. Part 2: Create record types to store extracted data When extracting data, Appian will identify key-value pairs from the document and map them to the fields of your desired data object (a record type or CDT). In most cases, you'll use a record type. The record type should be constructed to reflect the data available in your documents. If your documents contain a table, like the invoice documents that contains a table of items, you'll ultimately create two record types: A record type that for the document. A record type for the tables in the document. In this step, you'll create two record types to store the extracted data: one record type for the invoice data, and another for the data in the items tables commonly found in invoices Acme receives. Then, you'll create a bi-directional relationship between the record types, so you can write data to both record types in your process model. Create a record type for invoices To create a record type for your invoice data, you'll need to add the fields from your AI skill as fields in your record type. You'll also add a field of type Document to this record type so you can manage the invoice documents uploaded to Appian using the record type. To create a record type for invoices: In your application, go to the Build view. Click NEW > Record Type. In Create Record Type, configure the following properties: Property Value Name AT Invoice Display Name (Plural) Invoices Description Manage invoice data sent to Acme Logistics. Click CREATE. In the Review Record Type Security dialog, keep the default settings. The AT Users group should be assigned Viewer permissions. The AT Administrators group should be assigned Administrator permissions. Click SAVE. The record type opens in a new tab. Click TELL US ABOUT YOUR DATA. The Configure Data Source dialog opens. Click New Data Model. Click NEXT. For Data Source, select the relational database where Appian will create your table. If your environment contains a single relational database, that database is selected and cannot be unselected. Click NEXT. Click X next to the following fields to remove them from the data model: createdBy createdOn modifiedBy modifiedOn Tip: We won't use these fields in this tutorial; however, in your own applications, you should consider keeping these fields so you can easily track when data is created and updated, and by whom. Next to the id field, click Add Multiple Fields. In the Add Multiple Fields dialog, enter 7. Click ADD. In the new fields, configure the following: Name Data Type invoiceNumber Number (Integer) name Text email Text phone Text address Text date Text total Text Note: In this tutorial, we're setting the data type for fields like date and total to Text since the invoices use different date formats and currency. In a real application, you could then use functions to extract and transform these values to use consistent date formats and currency. If the invoices all used the same format for date and currency, you could set these types of fields to type Date and Number (Decimal Precise) instead. Click NEW FIELD and configure the following: Enter document for the field name. Select Document as the data type. For Will This Record Type only Store Documents?, keep Yes selected and click DONE. Click NEXT. Click NEXT again since you won't add any additional relationships. By default, the record type will have a relationship to the Document record type since there is a field set to type Document. Keep the Create Table checkbox checked and click SAVE CHANGES. Click CLOSE. Now that you have your record type for invoices, you'll create a record type for invoice items. Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close Create a record type for invoice items While the AT Invoice record type will store the extracted invoice data, like name, phone number, and invoice number, you need to create another record type to store the values extracted from the tables in an invoice. Since the tables are related to the general invoice data, you will also add a relationship to the Invoice record type. To create a record type for invoice items: In your application, go to the Build view. Click NEW > Record Type. In Create Record Type, configure the following properties: Property Value Name AT Invoice Item Display Name (Plural) Invoice Items Description Stores the table data on invoices sent to Acme Logistics. Click CREATE. In the Review Record Type Security dialog, keep the default settings. The AT Users group should be assigned Viewer permissions. The AT Administrators group should be assigned Administrator permissions. Click SAVE. The record type opens in a new tab. Click TELL US ABOUT YOUR DATA. The Configure Data Source dialog opens. Click New Data Model. Click NEXT. For Data Source, select the relational database where Appian will create your table. If your environment contains a single relational database, that database is selected and cannot be unselected. Click NEXT. Click X next to the following fields to remove them from the data model: createdBy createdOn modifiedBy modifiedOn Next to the id field, click Add Multiple Fields. In the Add Multiple Fields dialog, enter 4. Click ADD. In the new fields, configure the following: Field Data Type quantity Number (Integer) description Text unitPrice Text amount Text Tip: Again, we are setting fields like unitPrice and amount to type Text since the invoices use different currencies for them. Click NEXT. Under Suggested Record Types, click Invoice. This will automatically create an invoiceId field to use as the common field in the relationship. Keep the default relationship configurations and click ADD. This will create a many-to-one relationship from the Invoice Item record type to the Invoice record type. Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close Click NEXT. Keep the Create Table checkbox checked and click SAVE CHANGES. Click CLOSE. Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close Add a relationship between invoices and items Now that you've set up record types for invoices and invoice items, you need to add a relationship between the Invoice record type and the Invoice Item record type. In the last step, you added a relationship from the Invoice Item record type to the Invoice record type. Now, you can use a suggested relationship to easily set up a relationship from Invoice to Invoice Item. To add a relationship between the Invoice record type and the Invoice Item record type: In your application, go to the Build view. In the list of design objects, open the AT Invoice record type. Under Suggested Relationships, click next to AT Invoice Item to automatically add a one-to-many relationship to the record type. Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close Click SAVE. The Invoice record type now has four relationships. Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close Part 3: Create additional design objects Now that you have your record types, you'll create two additional objects to use in the process model: A start form, which will allow users to upload documents. An Analyst group, which will store certain users who will be responsible for reconciling the document extraction. Create a start form You need to create a start form to allow Acme's customers to upload invoices. To create this form: In your application, go to the Build view. Click NEW > Interface. Configure the following fields: Property Value Name AT_IntakeForm Description (Optional) Interface to allow vendors to upload documents. Save In Keep the default folder selection of AT Rules & Constants. Click CREATE. In the interface object, click Expression mode . Open the Rule Inputs pane. Click New Rule Input and configure the following properties: Property Action Name Enter invoice. Type Select the Document data type .Note: Make sure you don't select the Document record type . Click CREATE. In the Interface Definition, copy and paste the following expression: 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 33 34 35 36 a!formLayout( titleBar: a!headerTemplateSimple( title: "Submit to Acme Logistics", secondaryText: "Thank you for contacting Acme! Upload your document and we'll be in touch." ), contents: { a!fileUploadField( label: "File Upload", value: ri!invoice, saveInto: ri!invoice, /* Replace with a reference to the AT Invoice record type in your environment */ target: recordType!AT Invoice, required: true, maxSelections: 1 ) }, buttons: a!buttonLayout( primaryButtons: { a!buttonWidget( label: "Submit", submit: true, loadingIndicator: true, style: "SOLID" ) }, secondaryButtons: { a!buttonWidget( label: "Cancel", value: true, validate: false, submit: true, style: "OUTLINE" ) } ) ) Replace the record type reference with a reference to the AT Invoice record type in your environment. Note: Record type references are specific to each environment, which is why you need to change the references whenever you copy and paste a record type reference from outside the application. Click SAVE. The interface should look like this: Create a constant for the analyst Later, you'll add a node in the process model for the analyst to reconcile the extracted data. To assign that task, you'll first need to create a constant referencing the analyst. To create a constant for the analyst: In your application, go to the Build view. Click NEW > Constant. In Create Constant, configure the following properties: Property Value Create from scratch Leave selected Name AT_ANALYST Description (Optional) Constant pointing to the analyst at Acme Logistics. Type User Value Select your username. Save In Keep the default folder selected. Click CREATE. Part 4: Build the document extraction process With your objects created and configured, you can now start building your end-to-end process. The following instructions walk you through how to configure the process model below. Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close As you build your process, you have the flexibility to incorporate other design objects and decisions that fit your specific business needs. See some additional process configuration options you can add to your own process model. Publish the document extraction model Before you create the process model to extract documents, you'll need to publish your document extraction model. Publishing the model will make it available to use in the Extract from Documents smart service in a process model. To publish the model: Open the AT_ExtractInvoice AI skill. Under Unpublished Models, click PUBLISH. Click SAVE. The model should now appear under Published Models. Create a process model Now that the document extraction model can be called from a smart service, let's build the process that will use the published model in this AI Skill. To create the process model: In the application toolbar, click NEW > Process Model. Configure the following properties: Property Value Name AT Invoice Extraction Description (Optional) Process to extract invoice data from Acme vendors. Save In Keep the default folder selected. Click CREATE. In the Review Process Model Security dialog, keep the default settings. The AT Users group should be assigned Viewer permissions. The AT Administrators group should be assigned Administrator permissions. Click SAVE. From the File menu, click Properties. In the Process Model Properties dialog, go to the Variables tab. Create the following process variables: Name Type Value Parameter? Required? Multiple? cancel Boolean Blank Yes No No docExtractionId Text Blank No No No document Document (Data Type) Blank Yes No No invoice AT Invoice (Record Type) Blank Yes No No Configure the start form Next, you'll configure the start form: In the Process Model Properties dialog, go to the Process Start Form tab. For Interface, enter AT. Select AT_IntakeForm when it displays in the dropdown list. Click No in the Create Process Parameters dialog since you already created all of the variables in the previous step. The cancel and document rule inputs from the interface are automatically mapped to the corresponding process variables. Click OK. In the menu bar, click File > Save & Publish. Configure the Extract from Document smart service After defining your start form and process variables, the first node to add to the process is the Extract from Document smart service. This smart service takes the document as input, extracts the data, and returns the extracted data as output. To configure the smart service: From the palette, drag in a Extract from Document node. Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close Open the Extract from Document node. Go to the Setup tab. Under Select AI Skill, select the AT_ExtractInvoice skill you created earlier. Go to the Data tab. On the Inputs tab, configure the inputs with the following values: Input Action Document For Value, enter pv!document. Confidence Threshold For Value, enter 80 On the Outputs tab, configure the outputs with the following values: Output Action Doc Extraction Id For Target, choose the docExtractionId process variable. Extracted Data For Target, choose the invoice process variable. Confidence Scores Leave the target blank. Click OK. Configure the Reconcile Doc Extraction smart service The next node you will configure is the Reconcile Doc Extraction smart service. This smart service will assign a reconciliation task to a user to confirm or correct the extracted results. To configure the smart service: From the palette, drag in a Reconcile Doc Extraction node and place it after the Extract from Document node. Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close Open the Reconcile Doc Extraction node. Go to the Data tab. On the Inputs tab, configure the following: Input Action Doc Extraction Id For Value, choose the docExtractionId process variable. On the Outputs tab, configure the following values: Output Action Reconciled Data For Target, choose the invoice process variable. Go to the Assignment tab. For Assign to the following, click Edit as Expression. In the expression editor, enter cons!AT_ANALYST. Click SAVE AND CLOSE. Click OK. Assign the invoice document to the record process variable Next, you need to ensure that the invoice document and the reconciled data are both written to the Invoice record type. Before adding a Write Records node, you need to configure a script task to assign the invoice document to the invoice process variable. To save the invoice document to the invoice process variable: From the palette, drag in a Script Task node and place it after the Reconcile Doc Extraction node. Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close Open the Script Task node. For Name, enter Assign Doc to Record. Go to the Data tab. On the Outputs tab, click + New Custom Output. For Expression, click Edit as Expression. Enter pv!document. Click SAVE AND CLOSE. For Target, choose invoice > document. This will appear as invoice.document. Click OK. Write reconciled data to the Invoice record type Finally, you'll add a Write Records node to write the document and reconciled data to the Invoice record type. From the palette, drag in a Write Records node and place it after the Assign Doc to Record node. Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close Open the Write Records node. For Name, enter Write Invoice. Go to the Setup tab. For Record Input, select the invoice process variable. The Record Type field will automatically populate with the AT Invoice record type. Note: Since the record type does not have record events configured, no events will be written. Click OK. Add a cancel flow It's a best practice to include a pathway in your process model in case the user clicks Cancel on the start form. The start form is already configured to pass true to the cancel rule input if a user clicks this button. Now, you just need to add the cancel flow to the process. To add a cancel flow: From the palette, drag in an XOR gateway and place it on the connector between the Start Node and Extract from Document node. Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close Add a connector from the XOR gateway to the End Node. Open the XOR gateway. For Name, enter Cancel?. Go to the Decision tab. Click NEW CONDITION. Click Open the Expression Editor next to the Condition field. In the Expression Editor, enter pv!cancel. Click SAVE AND CLOSE. In the Result field, select End Node. For Else if no rules are TRUE, select Extract from Document in the Results field. Click OK. In the menu bar, click File > Save & Publish. That's it! Your process is set up to extract and write document data. It should look like this: Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close Test your process After creating your process model, run it with a few samples to test the extraction and to see how your auto-extracted results change. To test the document extraction process created above: Go to your process model. From the File menu, click Start Process for Debugging. Use the form to upload an invoice document. After the Extract from Document node completes, you should receive a task to reconcile the extracted data. Note: The Extract from Document node may take a few minutes to complete. Return to the process model monitoring view to observe the results. Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close Go to the AT Invoice record type and verify the data was written correctly. In the Data Preview page, review the extracted data and ensure the document field has a valid document identifier associated with it. In the Documents page, view or download the invoice associated with the row of data. Scroll or drag to pan · ⌘+/⌘− to zoom · Esc to close As you test, Appian uses the field names from the data type to find a match. Over time, Appian learns how to map your data to your data type fields from the user interactions with the reconcile interface. Appian deletes document extraction runs after 30 days, or when the total amount of data surpasses 10 GB. If you attempt to access a run that has been deleted, you will see an error. Appian will not delete the documents you uploaded. Learn more about your document's security. Additional process configuration options The process model detailed above provides the basic nodes needed to create an extraction process, but you aren't bound to this model. In fact, the major benefit of creating your own document extraction process is the flexibility to add additional rules or decisions that are specific to your business needs. There a few ways you can enhance or modify this process, for example: Dynamically skip reconciliation: After the Extract from Document smart service, you can use a Script Task to evaluate the extracted data. For example, you may want to validate that all fields were extracted, or that the extracted data meets your business validations. If your validations are met, you can use an XOR node to skip the Reconcile Doc Extraction smart service and write the extracted data directly to your record type, without any human review. Use the two optional outputs in the Reconcile Doc Extraction smart service to route the process model after reconciliation: isSubmit is true when the user selects the Submit button on the reconciliation task. Add logic after this smart service to use isSubmit=true() to trigger an email notification or a confirmation dialog. isException is true when the user selects the Mark as Invalid button on the reconciliation task. Add logic after this smart service to use isException=true() to route to a chained user input task, where the user provides more information. Add conditionality to the Reconcile Doc Extraction smart service to determine who should be assigned the reconciliation task based on certain business criteria or rules. Feedback Was this page helpful? SHARE FEEDBACK Loading...