ad
ad
Topview AI logo

Process Invoice Document without Setting up Custom AI Builder Model

Science & Technology


Introduction

In today's world, automating business processes is crucial for efficiency and productivity. One innovative way to streamline document processing, especially for invoices, is by utilizing custom prompts in AI tools. In this article, we will explore how to extract invoice data from documents without the need for a pre-trained model.

Introduction

We demonstrate the powerful capabilities of custom prompts to extract fields from documents. The focus will be on extracting invoice data from email attachments. This approach significantly reduces the time and effort spent on preparing and fine-tuning custom models for document processing.

Understanding the Sample Invoice

Before diving into extraction, let’s examine the sample invoice PDF file. The PDF contains essential information, including:

  • Invoice Number
  • Date
  • Account Information: Account name and address
  • Line Items: Three line items specifying quantity, description, unit price, and line total
  • Tax and Total Amount

We will utilize a custom GPT prompt to extract all this information and store it in a database table.

Setting Up the Database

In our implementation, we have two custom tables:

  1. Invoice Table: This acts as the parent table that holds the invoice details.
  2. Invoice Item Table: This child table holds line item records associated with each invoice.

A one-to-many relationship is established between the invoice table and the invoice item table. The invoice item table includes a lookup column that references the parent invoice record.

Creating a Custom GPT Prompt

With the database structure in place, we proceed to create a custom GPT prompt. We enter instructions that define what data we want to extract from the invoice PDF file.

  1. Input Parameter: We add an image or document input parameter for the AI to extract data from the provided PDF file.
  2. File Upload: Name the parameter as "input file" or "invoice file" and upload the sample invoice file.
  3. Output Format: Set the output format to JSON.

After setting up the prompt, we test it, and the model generates an output in JSON format where spaces in column names are replaced by underscores.

Automating Data Extraction with Cloud Flow

To automate the invoice data extraction, we create a cloud flow with an email trigger. The flow works as outlined below:

  1. Trigger Setup: Set a trigger for email arrival and filter the subject accordingly.
  2. Attachment Handling: Use the “apply to each” action to loop through attachments in the email.
  3. Get Attachment: Add an action to retrieve the bytes of the email attachment.
  4. GPT Prompt Trigger: Call the custom GPT prompt action to extract data from the invoice.
  5. Parse JSON: Add an expression to convert the prompt’s response into a JSON structure.
  6. Data Storage: Use the parsed data to populate the invoice and invoice item tables.

After saving the flow, it is validated and then tested by triggering an email with an appropriate subject and an invoice PDF attachment.

Testing the Implementation

Upon successful execution of the flow, we can check the invoice PDF attachment, which should display fields such as the invoice number (e.g., 1802) along with all the relevant details and line items. By refreshing the invoice table, we can see that, indeed, the invoice records have been created along with the corresponding line items in the invoice item table.

Conclusion

This approach allows us to leverage custom prompts with file input parameters to effectively extract data from documents using a cloud flow. This methodology not only simplifies document processing but also enhances overall operational efficiency.

For more updates on features and use cases, please consider liking and subscribing to my channel!


Keywords

  • Custom prompt
  • Invoice extraction
  • Document processing
  • Cloud flow
  • JSON output
  • Invoice table
  • Data automation

FAQ

Q1: What is a custom GPT prompt?
A: A custom GPT prompt is a tailored instruction set used to guide the AI in extracting specific information from documents or data inputs.

Q2: What data can be extracted from invoices?
A: You can extract various data points, including invoice numbers, account details, line item descriptions, quantities, prices, tax, and total amounts.

Q3: Is it necessary to set up a pre-trained model for document processing?
A: No, this method allows you to extract invoice data without the need for a pre-trained model, significantly reducing preparation time.

Q4: How do you automate the data extraction process?
A: The automation process is set up using a cloud flow that triggers upon email arrival, processes the attachments, and uses a custom prompt to extract and store the invoice data.

Q5: Can this method be used for other types of documents?
A: Yes, custom prompts can be tailored to extract information from various document types, not just invoices.

ad

Share

linkedin icon
twitter icon
facebook icon
email icon
ad