Skip to main content

Workflows & AI Parsers

1. Introducing Workflows

A Workflow in DocumentPro is a set of stages for automating your document tasks. It covers everything from how documents are collected (via email, uploads, APIs, etc.) to how their data is parsed, what actions are taken with the data and how the data is exported.

Within these stages, the AI Parser is the step responsible for extracting structured data from documents. All references below to “parser” or “template schema” describe the data extraction phase of a Workflow.


2. What is an AI Parser?

An AI parser in DocumentPro (i.e., the parsing step of a Workflow) extracts structured information from documents. It combines OCR (Optical Character Recognition) technology with advanced LLM (Large Language Models) models to interpret and extract relevant data from a variety of formats.

A key feature of the AI parser is its ability to understand context—it doesn’t just look for an exact label match. Instead, it uses field names and descriptions to locate the right data, even if the document uses different terminology or layouts.

For example, if you define a field named "invoice_number" with a description "Unique identifier for the invoice", DocumentPro’s AI can find that number even if the document labels it as "Invoice #" or "Reference Number", or if it appears in an unlabeled area.


3. Workflow Attributes

Here are the key attributes that make up a Workflow:

  • template_id: Unique identifier for the Workflow (auto-generated).
  • template_title: A user-defined title for the Workflow (must be unique in your account).
  • template_type: The type of document this parser is designed for (invoice, purchase order, receipt, etc.).
  • template_schema: Defines the structure of data to be extracted (see below). This is the AI Parsing part
  • email_id: Auto-generated email address for forwarding documents to this parser step.
  • webhook_url: An optional URL where DocumentPro sends parsed data in real time.
  • parser_config: Settings for OCR, query processing, and other AI-extraction parameters.
  • post_processing_config: Settings for post processing actions.
  • email_export_config: Settings for sending document extracts to Email.

4. Template Schema (AI Document Parsing)

The template_schema remains the core of your AI document parser step—defining the fields, tables, and repeated data structures the AI should extract from your document.

Field Attributes

  • name: Identifies the field (max 50 characters, lowercase letters, numbers, underscores).
  • type: Data type (text, number, date, table, etc.).
  • description: (Optional) Extra context for the AI, crucial for accurate extraction.
  • default_value: (Optional) Default value for this field.

The AI relies on the combination of name and description to interpret the document, meaning it can find data even when labels differ (e.g., "Invoice #" vs. "Reference Number").

Field Types

  1. Text: Extracts string data.
  2. Number: Extracts numeric data.
  3. Date: Extracts date information (apply formats like "%Y-%m-%d").
  4. Table: Extracts repeating/tabular data (requires subFields).

Example 1: Extracting Facts and Tables (Key-Value Pairs)

{
"fields": [
{
"name": "invoice_number",
"type": "text",
"description": "Unique identifier for the invoice, usually at the top",
"required": true
},
{
"name": "issue_date",
"type": "date",
"description": "Date when the invoice was issued, often near the invoice number"
},
{
"name": "line_items",
"type": "table",
"description": "Individual items or services listed on the invoice",
"subFields": [
{
"name": "item_description",
"type": "text",
"description": "Description of the item or service provided"
},
{
"name": "quantity",
"type": "number",
"description": "Number of units of the item"
},
{
"name": "unit_price",
"type": "number",
"description": "Price per unit of the item"
}
]
}
]
}

5. Parser Configurations (Additional Settings for AI Document Parsing)

Parser Configurations have additional settings that control how the AI extracts data from your documents.

Query Configs

The query configurations control settings related to the AI model used by the document workflow. Here are the key attributes:

  • query_model: LLM model used by the Workflow for document parsing.
  • max_tokens: Maximum number of tokens the LLM model is allowed to return.
  • selected_language: The language content of the documents sent to this workflow.
  • page_ranges: Which page ranges should be filtered in the document e.g. 1-3 or 1,3,9
  • start_regex: Only select document text that starts with this regex pattern
  • end_regex: Only select document text that ends with this regex pattern. Should be used with start_regex.
  • split_regex: Split the document text by this regex pattern.
  • use_all_matches: For start_regex and end_regex, or split_regex use all the text sections that match the pattern or only the first.
  • chunk_by_pages: Use this setting to split the document into page chunks for processing of long documents.
  • rolling_window: Determines the overlap between pages if chunk_by_pages is used.
  • merge_chunks: Automatically merge the results of the processed chunks or return them as a list of results for each chunk.

OCR Configs

The query configurations control settings related to the AI model used by the document workflow. Here are the key attributes:

  • use_ocr: Whether to use Optical Character Recognition on the document. If not enabled, the AI parsing will use the LLM's Vision Model.
  • detect_layout: Extracts the document text in reading order with the same layout as in the document. Recommended for more accurate parsing.
  • detect_tables: Extracts properly formatted table content along with column and row spacing. Table content is detected if this is disabled but not as well.
  • detect_checkboxes: Detects the crosses and ticks in checkboxes.
  • remove_headers: Remove header texts from document pages if they contain irrelevant information. Only applies if detect_layout is enabled.
  • remove_footers: Remove footer texts from the document pages if they contain irrelevant information. Only applies if detect_layout is enabled.
  • remove_tables: Remove tables from the document pages if they contain irrelevant information. Only applies if detect_tables is enabled.

6. Post Processing Steps (Actions taken after AI Document Parsing)

After DocumentPro extracts data, you can define Post-Processing steps to clean, transform, or enrich that data before final output. Examples include:

  • Data Validation: Checking if certain fields match expected patterns or fall within ranges.
  • Field Transformations: Converting currency formats, normalizing addresses, etc.
  • Business Logic: Marking high-value invoices for manager approval, etc.

For example:

  • Use the extracted data to create a new Bill in QuickBooks Online
  • Use the extracted data to get the lookup value from a table
  • Format the dates on the extracted data to be a required date format

Post processing steps on a Workflow can only be configured through the DocumentPro app.

7. Exporting Data

Finally, you’ll send or store the processed data:

  • Webhook: Post extracted data (JSON) to a specified URL (webhook_url).
  • Email Export: Send data in CSV or JSON to configured email addresses.
  • API: Get results of the Workflow using our API
  • Cloud Storage: Store documents and results in Cloud Storage Apps (Coming Soon)