Invoice Processing Quickstart

Let's walk through how to build an invoice processing automation using Kognitos


This Quickstart Guide walks through the process of building an automation that extracts fields and tables from an invoice! This guide also introduces different screens in Kognitos and how to navigate them. If you would like to just view the completed automation, we include the full, ready-to-run automation at the end of this guide.

Steps to Automate

  1. Retrieve an invoice attached to an email
  2. Extract the invoice number
  3. Extract the line items table
  4. Find the prescription details the doctor prescribed
  5. Send the line items as an attached Excel sheet to an email address
    1. In the body of the email, include a message that notes the invoice number and the prescription information as well as instructions on how to administer the medication

Document To Use

Download this invoice and keep it handy, we’ll be using it for the walkthrough and extracting data from them.

Installing Books

For this first automation we will need to install the books of the applications we need: Excel and Document Processing. Think of Books as packages that allow us to automate with more functionality! Check out this page for more info on Books!

Creating a New Automation

Let’s get your environment ready to build!

  1. Start by navigating to the Playground tab

Writing Your Automation

Step 1 - Retrieving invoice to process

When promoting an automation to a Process, you can have the automation triggered via email. In the Playground we can't test via email, so we can mimic by uploading our own document to playground to use.

To upload files to the automation we can use:

get files

When you write a line in the Playground, you can immediately test it by clicking the Run button:

Let's go ahead and click the Run button, and you'll notice the line turns red to the left of the sentence:

This means that the automation needs some help moving forward with the automation! Clicking on the line, you'll see the Questions tab pop open. You'll be prompted to upload your files like so:

Open Questions tab where you can upload files to be used in the Playground automation

Open Questions tab where you can upload files to be used in the Playground automation

Once you have uploaded your files, you'll be able to view them in the right hand sidebar labeled Facts. Facts represent the different objects you'll work with in your automation. You can click on each fact to expand the specific fact to view more details.

Step 2 - Getting Document's Fields

Once we have retrieved the documents, the next step is to extract the fields we care about from our document. Kognitos makes it easy to extract all the individual fields from your document in one sentence:

get the file's fields

When you run this line, you can take a look at all of the fields extracted under the Facts tab. You'll see all the extracted fields represented as a table in the Facts tab:

Viewing the extracted fields

Viewing the extracted fields

Extracting One Specific Field

The next sentence we'll write demonstrates how you can extract a single field from a document. Once you have read in the document, you can write a line like this:

get the files's XXXXXX as the XXXXXX

So for example you could write the following to get the document's invoice number:

get the files's invoice number as the invoice number

What this line says is: "extract the invoice number from the document, and for the rest of the automation we will refer to it as the invoice number".

Kognito's allows you to request for specific fields inutitively. For example, if you want to extract a PO Number, Invoice Date, or Vendor Name, you can write those field names like you would expect them to be named in the document, and the automation is smart enough to know which field you are referring to.

get the document's PO Number 
get the document's invoice date
get the document's vendor name

As long as the field name you provide is reasonable. For example, if you write:

get the document's fishtank

You may be prompted by the automation on how to proceed, as fishtank is not a value that would normally show up on a document.

Step 3 - Getting the Document's Tables

At this point, we have extracted specific fields from the document, now we are going to extract the tables in the document.

To extract all the tables present in a document, you would write:

get the document's tables

When you run this command, you can click on the line to see the Facts that are returned:

There are a few ways to get a specific table in the document returned back to you.

For example a couple ways you can request a table by are:

  • Ordering
    • First table, second table, last table etc
  • Column Names

The next line we will write is

get the file's first table as the main table

What this line is saying is, "within the file, retrieve the first table found, and we will refer to it as the main table when we want to use it in the automation".

We can also write:

get the document's table whose columns contain "Item Description"

This reads "within the file, retrieve the table that contains a column with the name 'Item Description'."

We can view both of these values in the Facts tab of the playground once the lines have been run.

Getting Specific Lines From the Document

We can get the lines of an automation by specifying a specific phrase or key words that we want to capture.

For example I can write:

get the file's first line which contains "MEDICATION"

This statement will cause your automation to search the doc for the word MEDICATION, and in the case there are multiple lines with the word MEDICATION, the automation will use the first instance in the document.

You can also tell the automation to retrieve lines relative to a location. For example, you could write:

get the lines below the above as the medication notes

This line is saying "get all the lines below the first line that contains the word MEDICATION." This allows us to get the doctor's notes we need!

Using Koncierge to Leverage an LLM as Part of Your Automation

In this Quickstart, the lines that follow the word MEDICATION are the veterinarians notes about the animal, how the checkup went, and any prescriptions/medication followups that are necessary.

Since this text can consist of ANYTHING the veterinarian wanted to write, we want to query this section of text to ONLY retrieve details relevant to any prescription the animal may need to follow up with.

For this, we can actually shoot of the large chunk of unstructured text to Koncierge, so we can have this request efficiently handled for us. When you call Koncierge, you're leveraging an LLM to complete your request.

To request Koncierge, you can write the following:

ask koncierge for the VARIABLE NAME YOURE SETTING
  the task is "{THE LINES TO PROCESS} and the rest of the request"

So in this Quickstart use case, it would look something like this:

 ask koncierge for the prescription details
    the task is "{the medication notes} \n -------------- \n Find the veterinarian's notes above. Please return the prescription instructions. Print the answer. No explanation necessary."

Completed Automation Steps

Here is the completed automation that you can copy and paste into your Playground or into a Process if you want to run and test it out!

By no means is this the only way you could have automated this process, and there are some extraneous steps just for the sake of learning included in the below automation.

get files

get the file's fields
get the file's first invoice number as the invoice number

get the file's tables 
get the file's first table as the main table
get the file's table whose columns contain "Item Description"

get the file's first line which contains "MEDICATION"
get the lines below the above as the medication notes
ask koncierge for the prescription details
	the task is "{the medication notes} \n -------------- \n Find the veterinarian's notes above. Please return the prescription instructions. Print the answer. No explanation necessary."

convert the main table to an excel
the message is "Hello! \n Attached you will find the line items of the invoice, {the invoice number}. \nAs well, the doctor recommended the following with regards to the prescription: {the prescription details} \nThank you!"
send the message to "[email protected]" where
  the subject is "Animal Hospital Invoice"
  the attachment is the excel 
  the attachment name is "animal_hospital_line_items.xlsx"