> For the complete documentation index, see [llms.txt](https://trillo.gitbook.io/trillo-workbench-lessons/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trillo.gitbook.io/trillo-workbench-lessons/begin-code-lessons/using-an-document-ai-processor.md).

# 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.

<figure><img src="https://lh7-us.googleusercontent.com/Z9LWJFWuBU1ZKioLv7r85quCv4iMxTZLyUYYAFX4BZJ8vhWlFJpg6T-5kDkKhfz5mAM3qEH1_FTXCb7dXFjaCMQYMfOJzC5MH3wjtLqiJ0jCnNJhUAcppqZoAm-0yXd3JzYOSH8zxYyKzkKYL3c8WTg" alt=""><figcaption><p>Configured Processors under Google Cloud Console</p></figcaption></figure>

**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
