githubEdit

Bank Statement Cross-checker Agent

In this guide we will create a Bank statement cross-checker agent. This agent will:

  • Fetch a bank statement and receipts from Google Drive

  • Performs cross-checking and creates a summary using Chat Complete API

  • Updates a Google Document with the summary

We make use of libraries like google-drive, google-docs, mistral and open-ai provided in Midio to achieve this.

circle-info

This workflow is available as a ready-to-use template in Midio.

Prerequisites

Setting up Google Drive

This is the structure in Google Drive the workflow assumes:

  • A folder containing bank statements in PDF.

  • A folder containing all receipts in PDF.

  • A document containing result of the cross-checking

High-level view

The workflow is split into four parts:

  1. Fetching the relevant documents from Google Drive

  2. Feed the documents to Chat Complete to perform the cross-checking

  3. Creating a Markdown summary of the cross-checking using Chat Complete

  4. Updating the Google Document

A screenshot of the entire workflow
The entire workflow

1. Fetching from Google Drive

First, the relevant documents are fetched from Google using Get Files in Folder, which is provided by the google-docs library. Since we only want the PDF files in the folders, we also use a Filter function from the Midio standard library, and filter out using mimeType which is provided in the data returned from the Google API call. This functionality is packed away in the function Get PDF Files in Folder.

Next we transform the PDF to markdown by using OCR on File, provided by the mistral library. For each receipt in the folder, a new process is spawned to transform the PDF. This was not necessary for the bank statement, since the workflow only fetches the first file returned by Get PDF Files in Folder. The first file will be the newest file crated, because the call to Get Files in Folder sorts the documents by the creation time descendingly.

A screenshot of `Get documents` node
Content of `Get documents` node

2. Cross-check bank statement

To perform the cross-checking, we provide this system prompt to the Chat Complete node. It includes formats for successful matches, missing receipts and unmatched receipts. This standardization helps downstream nodes generate a consistent Markdown summary.

The user message follows this format (written in Midio expression language):

where ${bankStatement} is the Markdown content of the PDF file and ${receipts} follows this format:

The mapping of the list of receipts is done using the Map function from the Midio standard library.

circle-info

We recommend using gpt-4.1 for optimal cross-checking accuracy

A screenshot of `Cross-check bank statement` node
Content of `Cross-check bank statment`

3. Creating Markdown summary

Another Chat Complete node receives a JSON list of objects representing the cross-checking of each entry in the bank statement and the receipts, and is prompted to use this to create a summary:

4. Updating Google Document

The last node is provided the summary content and a document id to add the content to. To achieve this we use the Update Google Document node in the google-docs library.

A screenshot of `Create content in Google Document`
Content of `Create content in Google Document`

Next steps and enhancements

This agent is available as a template. Insert your ids for folders and summary document, and click the Play button in the toolbar at the bottom. As you build upon this agent, here are some enhancements you can consider:

  • Support multiple bank statements by modifying the workflow to only select receipts that would be relevant for a given bank statement. You might have to change the structure the Google Drive setup to achieve this.

  • Expose this workflow as a REST API by attaching an Endpoint event node from the Midio standard library. You can find an example of this in the guide Concurrent Research Agent#exposing-the-agent-as-a-rest-apiarrow-up-right

  • Add Slack bot to notify users if mismatches are found. This can be done using Send Slack message to Channel or User node in the slack library. See the guide Slack Bot That Summarizes Articlearrow-up-right for an example of how to integrate with Slack.

Last updated

Was this helpful?