Using an Document AI Processor

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

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.

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

Last updated