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.
This workflow is available as a ready-to-use template in Midio.
Prerequisites
Midio account
Google OAuth provider configured in Midio. Set one up following this guide. Make sure to create an access token called
GOOGLE_WSin the Secrets panel.Mistral API key. You can create one for free at https://mistral.ai. Store it as a secret with the name
MISTRAL_AI_API_KEY.
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:
Fetching the relevant documents from Google Drive
Feed the documents to Chat Complete to perform the cross-checking
Creating a Markdown summary of the cross-checking using Chat Complete
Updating the Google Document


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.


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.
We recommend using gpt-4.1 for optimal cross-checking accuracy


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.


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
Endpointevent 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-apiAdd Slack bot to notify users if mismatches are found. This can be done using
Send Slack message to Channel or Usernode in theslacklibrary. See the guide Slack Bot That Summarizes Article for an example of how to integrate with Slack.
Last updated
Was this helpful?