Build an AI Agent That Categorizes Business Expenses
Sorting a stack of expenses into the right categories is slow, careful work. In this free lesson you build an AI expense categorizer for Maple Street Bookkeeping in n8n: you hand the agent a batch of expenses in a chat, it sorts each one into a category with a short note, and it saves them as rows in a Google Sheet for you to review.
What you will build: an AI expense categorizer agent
You build a small n8n workflow with five parts: a chat trigger so you can talk to the agent, an AI Agent node with a system prompt, an OpenAI chat model, simple memory, and a Google Sheets tool. Then you test it. You paste three expenses: $64.18 of printer paper and toner from Corner Office Supply, a $45.00 monthly accounting software charge from CloudLedger, and a $38.50 client lunch at Harbor Street Cafe.
The agent returns each one with a category and a note. The paper is Office Supplies. The software is Software & Subscriptions, flagged as a recurring charge. The lunch is Meals, with a reminder to write the client's name and the purpose on the receipt. You then type yes, save those expenses to the sheet, and the agent writes three rows into a spreadsheet called Expense Log with the columns Date, Vendor, Amount, Category and Note.
Who this is for
This is for bookkeepers, accounting clerks and small business owners who spend part of every month coding transactions. If you have ever scrolled a bank feed thinking office supplies, software, meals, not sure, this lesson shows you how to hand the first pass to an agent and keep the final say. You do not need to know how to code. It helps to have done the first lesson in this section, but it is not required.
Step by step: what you do in the lesson
- Get n8n: go to n8n.io and sign up for an account.
- API key: add credit to your OpenAI account, create a secret key, name it and copy it.
- Chat trigger: start a new workflow and add a trigger that fires on a chat message.
- AI Agent: add the AI Agent node, open its options, add a system message and paste the Maple Street system prompt.
- Chat model: pick OpenAI, create a credential with your key and choose gpt-5-mini.
- Memory: add Simple Memory so the agent remembers what you just asked.
- Sheets tool: add the Google Sheets tool, then create a spreadsheet named Expense Log with the headers Date, Vendor, Amount, Category and Note.
- Configure Sheets: sign in with Google, pick Append Row, choose Expense Log and Sheet1, and let the model fill each of the five columns.
- Test the agent: open the chat, send the batch of expenses, then tell it to save them to the sheet.
What the system prompt tells the agent
The system prompt is the standing instruction the agent reads before every request. It says who the agent works for, who reads its output (a bookkeeper who reviews every entry before it is posted), and that the tone is plain and factual.
Most important, it gives a fixed list of categories: Office Supplies, Software & Subscriptions, Meals, Travel, Utilities and Needs Review. The agent may only use those. If an expense could fit more than one, or the details are unclear, it has to choose Needs Review and say why. It must not change amounts or invent details, and it must not give tax advice. Swap in your own chart of accounts and the agent follows it.
Why it works
A plain chatbot will happily make up a category name or reword a vendor. A closed list of categories and a Needs Review option keep the agent honest: it sorts what it is sure about and hands you the rest. Memory lets you say save those without repeating the list. The Sheets tool turns the answer into rows, so the output lands where you already work instead of in a chat window you have to copy from.
Common expense categorizing mistakes this avoids
Most coding errors are small and add up by month end. A few lines in the system prompt catch the usual ones.
- Made-up categories. The agent can only use your list, so you never find Misc Business Stuff in the books.
- Guessing on unclear charges. A vague charge goes to Needs Review with a reason, instead of a confident wrong answer.
- Changed amounts. The agent is told never to change an amount, so $64.18 stays $64.18.
- Missing paperwork. The Note column is where the agent flags a missing receipt or a client lunch that needs a name and purpose.
How to use this in your bookkeeping workflow
Use it as a first pass, not a final answer. Paste a week of card charges or receipts, let the agent sort them, then review the Expense Log before anything is posted to your accounting software. Look hardest at Needs Review rows and anything with a note about a missing receipt. Add a column or a category when your own books need it. The sample vendors and amounts in the lesson are made up, and the categories are examples, not tax guidance. Your accountant decides how expenses are treated for tax.
Frequently asked questions
- Can AI categorize business expenses?
- Yes. An AI agent with a fixed list of categories can sort most routine expenses and flag unclear ones as Needs Review. A person should still review every entry before it is posted.
- Is this lesson free?
- Yes, Stepthrough is completely free. To build it for real you need your own n8n account, an OpenAI API key with a small amount of credit, and a Google account. n8n and OpenAI can cost money for real use.
- Does the agent connect to my bank or accounting software?
- Not in this lesson. You paste expenses into a chat and the agent saves them to Google Sheets. You review the sheet and post entries yourself.
- Will it tell me what is tax deductible?
- No. The system prompt tells the agent not to give tax advice. It sorts expenses into your categories and writes a short note. Ask your accountant about tax treatment.
- How does the interactive lesson work?
- Each step is shown to you first on the left (Watch). Then you do it yourself in a practice copy on the right (Your turn), and every click is checked. If you get stuck, press Do it for me. It is a practice copy, so no real accounts are touched.
More in AI Automation for Finance
Build a Custom GPT that follows your collections policy and writes polite, firm payment reminder emails for overdue invoices. Free, step by step, no code.
Free · Live
◷Build an Expense Reimbursement Form With AI Policy ChecksBuild an expense reimbursement form in Lovable with an n8n AI agent that checks each request against your policy, logs it in Sheets and emails the status.
Free · Live