Invoice Processing with AI Builder and Power Automate

Jul 19, 2024

Invoice Processing with AI Builder and Power Automate

Client Overview

  • Client: Burger company
  • Task: Automated invoice data extraction from email attachments to Excel
  • Why Excel: Simplified for this example, could extend to databases later

Steps Overview

  1. Collect input data (download invoices)
  2. Create an AI model using AI Builder
  3. Train the model using sample invoices
  4. Implement the model in a Power Automate flow
  5. Test the flow with an email containing an invoice attachment

Step-by-Step Breakdown

1. Collecting Input Data

  • Download 6 sample invoices (provided in description)
  • Save invoices locally on desktop

2. Using AI Builder

  • Open Power Automate and navigate to AI Builder
  • Create a new model named "Invoice Processing"
  • Form Type: Structured data
  • Field Specifications: Invoice number, date, total, and table data (single page)
    • Add fields: Invoice number, Date, Total
    • Add table: Name columns as Item, Quantity, Rate, Amount
  • Upload documents for training
    • Select first five invoices to train model (1-5)
    • Use the last one (6) to test model

3. Training the Model

  • Tag documents with required fields
    • Invoice number, date, total, and table rows/columns
  • Tagging Process (repeated for each invoice):
    1. Invoice number
    2. Date
    3. Total
    4. Table (Ctrl + drag to define columns)
      • Item, Quantity, Rate, Amount
  • Training: Wait for model to be trained and published

4. Creating Power Automate Flow

  • Trigger: Automated cloud flow when a new email with attachment arrives
  • Conditions: Email subject contains "invoice"
  • Loop through Attachments
  • Save excel workbook in OneDrive named book.xlsx
    • Define table with headers: Invoice number, date, total, items

5. Implement Model to Flow

  • Action: Extract information from forms (using AI Model)
    • Select AI Model (Invoice Processing)
    • Form type: PDF
    • Attachment content
  • Save Data to Excel
    • Excel: Invoice data table
    • Map fields: Invoice number, Date, Total, Items

6. Testing the Flow

  • Send email with invoice attached
  • Check OneDrive for processed data in Excel
    • Correct invoice details and formatted data

Additional Notes

  • Ensure local currency formatted correctly in Excel
  • Future work: Separate columns for table data in Excel, unstructured data handling