Trillo Workbench Lessons
  • Introduction
    • Sample Application
  • Introduction to Lessons
    • IDE Lessons
    • Annotated Directory Structure
  • New classes using workbench UI
  • Save many records into tables using the workbench UI
  • New function using Workbench UI
  • Introduction to Code Lessons
    • Anatomy of Trillo Function
  • Begin Code Lessons
    • Paginated list
    • Pagination using SQL Query
    • DataIterator
    • Read file from cloud storage bucket
    • Generating signed URL for a file download
    • Import a CSV file from bucket into BigQuery
    • Query a dataset of BigQuery
    • Using an Document AI Processor
    • Chat using GenAI
    • Function calling another function
    • Accessing Runtime Context
    • Write a workflow (pipeline for data processing)
  • Appendixes
    • ServerlessFunction
    • Map, List and Tree
    • Logs and Audit Logs
    • DataRequest Class
    • DataResponse Class
    • DataIterator Class
    • Result
Powered by GitBook
On this page
  1. Begin Code Lessons

Using an Document AI Processor

This lesson describes how to use a Document AI Processor to process an Invoice

PreviousQuery a dataset of BigQueryNextChat using GenAI

Last updated 1 year ago

In this example, the function code receives a bucketName and a file in the bucket. It assumes that this file is an “Invoice” type. Using type, it retrieves the URL of the Google Document AI processor and processes the invoice (for extraction of data). It returns the response of the processor.

Code: /lessons/Using_a_Document_AI_Processor/DocumentAIProcessor.java

Prerequisite

  1. In this lesson it is assumed that the Invoice-1234567.pdf file exists in the bucket (shown above).

  2. Google Document AI invoice processor is configured as shown in the screenshot below.

Configured Processors under Google Cloud Console

Steps

  1. Create a new function called DocumentAIProcessor.java.

  2. Set parameters in its function details file.

  3. Call DocumentAIProcessor.process method.

  4. Check the result for failure.

  5. Return Result object (if there is failure) else return the response document