Step 3 - Create Apex Class (Document AI API Wrapper)

Create a custom Apex class to enable the Document AI flow functionality. This Apex class:

  • Allows the Salesforce flow to invoke the Data 360 Document AI functionality
  • Passes in necessary credentials and document identities
  • Receives a clean JSON output of the extracted bank statement data
  1. Go to the Setup Menu.
  2. From the dropdown menu, select Developer Console.
  3. In the Developer Console, click File > New > Apex Class.
  4. Enter the class name: de_BankStatementExtractor and click OK.
  5. When the code editor opens, paste this code into the editor and save the file.

This is an out-of-the-box class that includes a method invoked by the flow you create on the next step. If you choose to use a different Apex class, make sure it includes such an invocable method. This class also contains a hardcoded override for the LLM model. If you use a different model, update the llmModel string.