ActionStep: Extract data from documents

Extract data from documents – this step launches the process of recognizing the content of attached files using AI OCR. As a result, the system analyzes documents (e.g., invoices, receipts) and automatically fills in the data in the appropriate tables, according to a predefined structure.

Where can you use the action:

Workflow

Parameters:

Data source name (type: text): the data source ID previously entered in the external data source configuration.

Attachments (type: text): the name of the attachment to be processed by OCR.

Table for identifiers (type: text): address of the column where the IDs of the processed files (GUID) will be saved.

Prompt preview address (type: text): cell address indicating the location from which the system retrieves the default prompt (set of instructions) used during document processing.

Prompt override (type: text) (optional argument): cell address allowing you to enter your own prompt to replace the default one. This allows you to customize how OCR works for specific document types or specific business needs.

Example application with data reading from a document

In this application, the user adds an attachment with an invoice, which is automatically processed using OCR technology. The purpose of the application is to automatically extract data from the document and save it in the appropriate tables.

First, we create a list - A1_INVOICE and A2_ITEMS.

A1_Invoice contains columns:

Technical columns:

  • FILE__GUID text type - (type: text) is the identifier of the file from which the data was loaded.
    If one file contains several invoices, all these invoices will have the same FILE_GUID.
  • GUID - (type: text) is a unique identifier of a single record, e.g., a single invoice. Each invoice has its own unique GUID.
  • INPUT_TOKENS_USED (type: number) -  number of tokens used during input processing
  • OUT_TOKENS_USED (type: number) - number of tokens generated at the output
  • STATUS (type: text) - technical status of text reading by OCR

Data columns:

  • SELLER_NAME (type: text)
  • SELLER_ADDRESS (type: text)
  • SELLER_TAX_ID (type: text)
  • BUYER_NAME (type: text)
  • BUYER_ADDRESS (type: text)
  • BUYER_TAX_ID (type: text)
  • SUBTOTAL (type: number)
  • TOTAL_TAX_AMOUNT (type: number)
  • TOTAL (type: number)

A2_ITEMS contains the following columns:

Technical columns:

INVOICE_GUID - (type: list) is used to link each item from the A2_Items table with the corresponding invoice in the A1_Invoice table. It contains the identifier (GUID) of the invoice to which the item belongs - this is exactly the same value that appears in the GUID column in the invoice table. This makes it possible to unambiguously assign items (e.g., products, services) to a specific invoice and logically link detailed data (level 2) with the main invoice data (level 1).

ORDINAL_NUMBER - (type: text) the ordinal number of the item on the invoice. It specifies the order in which a given item appears on the document. For example, the value 1 means the first item, 2 means the second, etc. This makes it easier to maintain consistency with the layout of the original document and to display the data correctly.

Data columns:

  • NAME (type: number)
  • QUANTITY (type: number)
  • UNIT (type: text)
  • NET_PRICE (type: number)
  • TAX_RATE (type: number)
  • GROSS_PRICE (type: number)

In the next step, we create a spreadsheet with an editable cell where the user can add an attachment with the invoice.

Next, we create a single-column table that will store the FILE_GUID identifier returned by OCR—this will be the link between the processed file and the invoice data. We name the header of this table, e.g., FILE_GUID.

Additionally, we create a spreadsheet with one editable cell where the user will be able to see the generated prompt.

To make it easier for the user to work with the document, we also add a widget - “external page,” which displays a preview of the invoice based on its URL. This allows the user to view the original document directly in the application and easily compare it with the data read by OCR.

The next step is to create two tables where the data read from the invoice will be stored. The first one is A1_INVOICE. The second table is A2_ITEMS.

In order for A1_INVOICE to assign the added data to the appropriate processed file, we need to use the lookup function, which will map the FILE_GUID column in the A1_INVOICE table to the GUID value from our first, single-column table. This will allow OCR to assign the data to the correct file.

In turn, in the A2_ITEMS table, the INVOICE_GUID column (i.e., the identifier of a specific invoice) should be mapped to the GUID column from the A1_FAKTURA table. This will assign the invoice items to the appropriate invoice record and create a logical link between the master data and the detailed data.

In the workflow, create an action step called “Extract data from document,” in which you should enter the appropriate parameters:

The end result:

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk