Stepthrough Start free

Build an AI Agent That Categorizes Business Expenses

Practice it step by step

Start the free practice

Take the free module: why it matters, practice and a quick check →

You do every step yourself in a practice copy of n8n. It checks your work as you go, and “Do it for me” finishes any step you get stuck on. Free, about 12 minutes, and nothing touches your real accounts. Open full screen

Free · Live nowAI Automation for Financen8nOpenAIGoogle Sheets~12 min72 stepsIntermediate

Updated . Built against the tool’s current screens and checked step by step. How we check this lesson

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.

At a glance

QuestionAnswer
What you buildBuild an AI agent for Maple Street Bookkeeping that sorts business expenses into categories, writes a short note for each and saves them to Google Sheets — chat trigger, AI Agent, system prompt, model, memory, and the Sheets tool.
Toolsn8n
TimeAbout 12 minutes, 72 steps in 12 parts
LevelIntermediate
CostFree
Ways to learn itPractice it step by step

The 12 parts, in short

  1. Get n8n: Go to n8n.io, Enter your email, Sign up.
  2. API key: Add credit first, Ten dollars is plenty, Now the key, Create a secret key, and 4 more steps.
  3. New workflow: Start a new workflow.
  4. Chat trigger: Add the first step, Trigger on a chat message, Back to the canvas.
  5. AI Agent: Add the next node, Open the AI nodes, Add the AI Agent.
  6. System prompt: Open the options, Add a system message, Write the system prompt, Back to the canvas.
  7. Chat model: Give the agent a brain, Pick OpenAI, Open the credentials, Create a new credential, and 5 more steps.
  8. Memory: Add memory, Simple Memory, Back to the canvas.
  9. Sheets tool: Add a tool, Search for Sheets, Add Google Sheets.
  10. Create the spreadsheet: Back to the canvas, Open Google Sheets, Name the spreadsheet, Type the first column header, and 6 more steps.
  11. Configure Sheets: Add a credential, Create a new credential, Sign in with Google, Choose your account, and 16 more steps.
  12. Test the agent: Open the chat, Send some expenses, Send the message, Save to the sheet, and 1 more step.

Start here first: n8n AI Agent Tutorial: Save Social Media Ideas to Google Sheets. This Finance version follows the same build with its own example business, Maple Street Bookkeeping.

Part of: AI for Accounting & Bookkeeping Firms (step 24 of 41). Next up: Invoices from Your Inbox to Google Sheets, with Approval

Part of: AI for Finance Teams (step 14 of 23). Next up: Invoices from Your Inbox to Google Sheets, with Approval

Watch the 30-second version

A short video from this lesson. Watch, then do it yourself in the free practice copy.

Your expenses log themselves into Sheets (video)0:39

Your expenses log themselves into Sheets

Short · 0:39

For finance and bookkeeping: build an AI agent in n8n that sorts business expenses into categories, writes a short note for each, and saves them to Google Sheets. Build it yourself, free, one click at a time…

Transcript

For finance and bookkeeping: build an AI agent in n8n that sorts business expenses into categories, writes a short note for each, and saves them to Google Sheets. Build it yourself, free, one click at a time: learn.ynteractive.com

n8n AI Agent node with a system message written for Maple Street Bookkeeping
n8n AI Agent node with a system message written for Maple Street Bookkeeping

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.

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.

Try it yourself, free

Reading the steps is a start. Doing them is how it sticks. The interactive module walks you through every click in a practice copy of n8n, checks each step, and never touches your real accounts.

Start “Build an AI Agent That Categorizes Business Expenses”

Step by step: Build an AI Agent That Categorizes Business Expenses

All 72 steps of the interactive module, in order. In the module you watch each one, then do it yourself in a practice copy that checks your work.

1. Get n8n

  1. Go to n8n.io. Start at n8n.io. Click Get started free.

    In the last lesson you built a Custom GPT that writes payment reminders. That is great for one person. But what if the AI sorted every expense into a category and saved it to a spreadsheet you can review? That is what we are building now. First, you need an n8n account.

  2. Enter your email. Type any email address — this is practice, so a fake one is fine.

    This is just practice, so anything works — it won't actually send anything.

  3. Sign up. Click Continue. n8n emails you a code, then asks for a name and password — do that part on your own and come back here.

    In the real n8n, it sends you a six digit code, then asks for a name, a password, and an account name. Go do that in your own browser later, then come back and we will build.

2. API key

  1. Add credit first. Practice only: no card, no charge. Your agent needs a model to think with, and in the real world that is an OpenAI key with a little credit behind it. This is platform.openai.com → Billing. Click Add to credit balance. (Rather not spend anything later? New n8n accounts include free credits: pick Gateway credits on the model step instead of a key.)

    Your agent needs a brain, and that means an API key from OpenAI. Go to platform dot openai dot com — that is the developer side, not ChatGPT, and it bills completely separately. Before you make a key, put some money on the account. A brand new key with a zero balance just returns errors. If you would rather not spend anything yet, n8n gives every new account free credits. In your own n8n, you can pick gateway credits on the model step and skip the key.

  2. Ten dollars is plenty. Ten dollars goes a long way — you pay per request, not per month. Click Continue. In your own account you add a card here.

    Ten dollars goes a very long way. You are charged per request, not per month, and each batch of expenses costs fractions of a cent.

  3. Now the key. Balance sorted. Click API Keys in the left menu.

    Balance sorted. Now go to API keys in the left menu.

  4. Create a secret key. Click + Create new secret key.
  5. Name the key. Name it after what will use it. Type n8n agent.

    Name it after whatever is going to use it. Future you, staring at a list of forty keys, will thank you. I am calling this one n8n agent.

  6. Create it. Leave Project and Permissions alone and click Create secret key.

    Default project, all permissions — that is fine for this. Create the key.

  7. Copy it now. This is the only time OpenAI shows you the key. Click Copy, then paste it somewhere safe.

    Now pay attention, because this is the only time you will ever see this key. Copy it and paste it into n8n, or into your password manager. If you lose it, you do not get it back — you delete it and make another.

  8. Back to n8n. Click Done. Treat that key like a password — never paste it into a chat, a repo, or a screen recording.

    One last warning — this key can spend your money. Never commit it to code, never paste it into a chat, and if it ever shows up on screen while you are recording, revoke it before you publish.

3. New workflow

  1. Start a new workflow. This is your n8n home. Click Create workflow in the top right.

    Now you are inside n8n. This overview page lists every workflow you have. Top right, click create workflow, and you land on an empty canvas.

4. Chat trigger

  1. Add the first step. Every workflow starts with a trigger. Click Add first step…

    Every workflow needs a trigger — the thing that kicks it off. We want a chat trigger so you can hand the agent a batch of expenses.

  2. Trigger on a chat message. The trigger panel opened on the right. Pick On chat message near the bottom.

    A panel slides in with every way a workflow can start — manually, on a schedule, on a webhook. We want on chat message, so we can have a conversation with the agent.

  3. Back to the canvas. n8n opens the node so you can configure it. Nothing to change here — click the × in the top right.

    n8n opens the node so you can configure it. There is nothing we need to change here, so close it with the X in the top right and get back to the canvas.

5. AI Agent

  1. Add the next node. Click the + on the right edge of the trigger node.

    Now we decide what happens when a message comes in.

  2. Open the AI nodes. The What happens next? panel opens with categories. Click AI at the top.

    A panel opens and asks what happens next. The agent lives under AI, right at the top.

  3. Add the AI Agent. In AI Nodes, click AI Agent — it makes a plan and carries it out using the tools you give it.

    There it is — AI Agent. This is the piece that can plan and then carry out actions using whatever tools you give it. You give it a batch of expenses, and it can categorize them and save them to a spreadsheet — all in one step.

6. System prompt

  1. Open the options. The agent has no personality yet. Click + Add Option under Options.

    Right now this agent has no personality and no orders. It does not know it works for Maple Street Bookkeeping.

  2. Add a system message. Choose System Message. This is the standing instruction the agent follows every time.

    Pick system message. This is the standing instruction the agent reads before every request. It is where we tell it who Maple Street is, which categories to use, and how to format each expense.

  3. Write the system prompt. The box starts with You are a helpful assistant. Replace it with the standing instruction: it is long, so just Paste in the system prompt on the box.

    Here is the actual prompt. It describes Maple Street Bookkeeping, lists the only categories allowed, and tells the agent what to return: date, vendor, amount, category, and a note. Anything unclear goes to needs review. It also tells the agent to use the Google Sheets tool when you ask it to save.

    You are the expense categorizing assistant for Maple Street Bookkeeping.
    
    Maple Street Bookkeeping is a small bookkeeping firm. It keeps the books for about 60 small businesses and for itself.
    
    The audience is the bookkeeper who reviews every entry before it is posted.
    
    The tone should be plain, brief and factual.
    
    Your job is to sort each expense the user gives you into one category and write a short note about it.
    
    Use only these categories:
    - Office Supplies
    - Software & Subscriptions
    - Meals
    - Travel
    - Utilities
    - Needs Review
    
    For each expense, return:
    - Date
    - Vendor
    - Amount
    - Category
    - Note (one sentence: what it was for, and anything the bookkeeper should check, like a missing receipt)
    
    If an expense could fit more than one category, or the details are unclear, use Needs Review and say why.
    
    When the user asks you to save the expenses, use the Google Sheets tool to store each one.
    
    Do not give tax advice. Do not change amounts or invent details.
  4. Back to the canvas. That tells the agent who it works for and how to categorize expenses. Close the node with the ×.

    That gives the agent everything it needs to know about Maple Street. Close the node.

7. Chat model

  1. Give the agent a brain. The agent has a red warning: it has no model. Click the + under Chat Model.

    See that red triangle on the agent? It is complaining because it has no model. An agent can plan, but it cannot think without a language model underneath it.

  2. Pick OpenAI. Click OpenAI Chat Model.

    OpenAI chat model. This is where that API key finally gets used.

  3. Open the credentials. Here is where that key goes. Click the Credential dropdown.

    And here is where that key you copied finally goes.

  4. Create a new credential. Click + Create new credential at the bottom of the list. (Free credits instead? Pick Gateway credits in your own n8n.)

    You want create new credential, right at the bottom. In your own n8n, if you skipped the key, you would pick gateway credits here instead.

  5. Paste the key. Paste in the API key on the field to drop in the key you copied from OpenAI.

    This is the one moment it matters that you copied it — remember, OpenAI never shows it to you again.

  6. Save the credential. Click Save. n8n tests the connection and stores the key for every future node.

    n8n tests the connection straight away, and from now on this credential is available to every node in every workflow — you only do this once.

  7. Open the model list. A new credential leaves Model on Select a model.... Click the Model dropdown.

    Now the model dropdown.

  8. Choose the model. Pick gpt-5-mini — fast and cheap, plenty for this. (The list is long: type gpt-5-mini in Search... to find it.)

    GPT five mini. Fast, cheap, and plenty for sorting expenses. Do not reach for the expensive model until you have a reason.

  9. Back to the canvas. The model is wired up. Close the node with the ×.

    That is the brain wired in. Close it up.

8. Memory

  1. Add memory. Without memory the agent forgets each message. Click the + under Memory.

    Next, memory. Without this, every message starts from nothing — you could not say save those expenses, because it would not remember which ones you meant.

  2. Simple Memory. Pick Simple Memory. It keeps the recent conversation in n8n itself.

    Simple memory is fine here — it keeps the recent conversation inside n8n, no database, no extra credentials.

  3. Back to the canvas. n8n opens Simple Memory so you can set it up. The defaults are fine (it keeps the last 5 messages). Close it with the ×.

    n8n opens simple memory so you can set it up. The defaults are fine. It keeps the last five messages. Close it with the X.

9. Sheets tool

  1. Add a tool. Tools are how the agent acts on the world. Click the + under Tool.

    And now the good part — tools. This is what separates an agent from a chatbot. A chatbot just talks. An agent does things. We are going to give it Google Sheets so it can save every expense into a spreadsheet you can review.

  2. Search for Sheets. Google Sheets is not in Recommended Tools. In Search nodes..., type sheets.

    Google Sheets is not in the recommended tools, so search for it.

  3. Add Google Sheets. Click Google Sheets Tool — read, update and write data to Google Sheets.

    Google Sheets tool. Now the agent can write rows into a real spreadsheet, with columns matching what the system prompt tells it to return. When you say save those expenses, each one becomes a row.

10. Create the spreadsheet

  1. Back to the canvas. Before we configure this node, we need a spreadsheet for the agent to write to. Close the node — we will come back.

    Before we set this up, we need to actually create the spreadsheet. Close this node for now — we are going to hop over to Google Sheets and make one.

  2. Open Google Sheets. Click the Google Sheets tab to create a new blank spreadsheet.

    Switch to Google Sheets. You need to create the spreadsheet that this node will write to.

  3. Name the spreadsheet. Click the title and rename it to Expense Log.

    First, name it so you can find it later.

  4. Type the first column header. In cell A1, type Date.

    Now set up the column headers. These need to match what the system prompt tells the agent to return. In A1, type Date.

  5. Vendor. In cell B1, type Vendor.

    B1 — Vendor.

  6. Amount. In cell C1, type Amount.

    C1 — Amount.

  7. Category. In cell D1, type Category.

    D1 — Category.

  8. Note. In cell E1, type Note. That is all five columns — matching the system prompt.

    And E1 — Note. Five columns, matching exactly what the system prompt tells the agent to return. Each expense becomes a row in this sheet.

  9. Back to n8n. The spreadsheet is ready. Click the n8n tab to go back and connect it.

    The spreadsheet is ready. Switch back to n8n and connect the Google Sheets node to it.

  10. Open the Sheets node. Double-click the Google Sheets node (n8n named it Get row(s) in sheet in Google Sheets) to configure it.

    Double click the Google Sheets node to open it back up. Now we can connect it to the spreadsheet we just made.

11. Configure Sheets

  1. Add a credential. The Sheets node needs a Google account. Click the Credential dropdown.

    Now we need to connect this to a real Google account.

  2. Create a new credential. Click + Create new credential to sign in with Google.

    Create new credential — this one uses Google OAuth instead of an API key, so it is going to open a sign-in window.

  3. Sign in with Google. Click Sign in with Google to connect your account.

    This opens the Google account chooser so you can pick which account to connect.

  4. Choose your account. Click your Google account to continue.

    Pick the Google account you want n8n to use. This is the account that owns the spreadsheet.

  5. Allow Sheets access. Google needs permission. Check See, edit, create, and delete all your Google Sheets spreadsheets.

    Google is asking what n8n is allowed to do. Check the first box — this lets n8n read and write your spreadsheets.

  6. Allow Drive access. Check See, edit, create, and delete all of your Google Drive files.

    Second box — n8n needs Drive access so it can find your spreadsheets by name.

  7. Allow external service. Check Connect to an external service.

    Last one — this lets Google connect to n8n as an external service. Check it.

  8. Sign in. All three are checked. Click Continue to complete the Google sign-in.

    All three checked.

  9. Pick the operation. Now tell n8n what to do with the sheet. Click the Operation dropdown.

    Now we tell the node what to do. By default it reads rows, but we want to add rows.

  10. Append Row. Pick Append Row — the agent will add a new row for each expense.

    Append row. Every expense the agent sorts gets added as a new row at the bottom of the sheet.

  11. Choose the spreadsheet. Click the Document dropdown to pick which spreadsheet to write to.

    Now pick the spreadsheet.

  12. Expense Log. Click Expense Log — the sheet we set up for Maple Street.

    Expense Log — the sheet we set up with columns for date, vendor, amount, category, and note.

  13. Pick the sheet tab. Click the Sheet dropdown to choose which tab inside the spreadsheet.

    Now pick which tab inside that spreadsheet.

  14. Sheet1. Click Sheet1.

    Sheet one — it is the only tab, so this is simple.

  15. Map the Date column. Under Values to Send, click the ✦ button next to Date — the AI agent will fill this in automatically.

    Now the columns. Each column has a purple button — click it and the AI agent figures out what data goes there.

  16. Map the Vendor column. Click the ✦ button next to Vendor.

    Vendor. Same thing — click the purple button.

  17. Map the Amount column. Click the ✦ button next to Amount.

    Amount.

  18. Map the Category column. Click the ✦ button next to Category.

    Category.

  19. Map the Note column. Click the ✦ button next to Note.

    And note. Each one is now set to defined automatically by the model — the agent reads your column headers and figures out what goes where.

  20. Back to the canvas. Google Sheets is fully configured. Close the node with the ×.

    The sheets tool is fully wired up — credential, operation, spreadsheet, sheet, and column mapping. Close it and let us test this thing.

12. Test the agent

  1. Open the chat. Time to test. Click Open chat at the bottom of the canvas.

    Everything is connected. Time to see if it works.

  2. Send some expenses. Type a prompt — give the agent a batch of expenses to categorize.

    Give it a batch of expenses.

    Categorize these expenses: Sep 22, Corner Office Supply, $64.18, printer paper and toner. Sep 23, CloudLedger, $45.00, monthly accounting software. Sep 24, Harbor Street Cafe, $38.50, lunch with a client.
  3. Send the message. Click the send arrow to talk to the agent.

    Send it off. The agent reads your system prompt and sorts each expense into a category, with a short note, in the exact format you asked for.

  4. Save to the sheet. Now tell the agent to save those expenses to Google Sheets.

    Three expenses — office supplies, software, and a client lunch, each with a category and a short note. Now tell it to save them. This is where the Google Sheets tool kicks in.

  5. Send it. Click the send arrow — the agent will use the Google Sheets tool to write the rows.

    Send it. The agent uses the Google Sheets tool to write each expense as a row — date, vendor, amount, category, and note.

All free Stepthrough videos

Screenshots

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.

Start this module free

More in AI Automation for Finance

All 4 modules in AI Automation for Finance

More n8n tutorials

From the blog

All blog posts

Visual guides

This lesson’s key ideas as quick visual guides: swipe through the slides, or read the same guide as text.

All visual guides

Free cheat sheets

Print it or save the PDF: the key steps and checks from this lesson on one page, free.

All free printable cheat sheets

Plain-English definitions, each with an example from a free lesson.

A/B testingAI agentAI evalsAPI keyAppend rowBudget varianceBuyer personaChain-of-thought prompting

The full AI glossary

  • AI pilot plan prompt: Plan a small, time-boxed trial of an AI tool: one task, a few people, success criteria you choose up front, how you'll measure…
  • Case study interview questions prompt: Plan a client interview that gets a case study's before, during and after story in their own words, with follow-up probes and…
  • Duplicate invoice check prompt: Scan the bills in a payment run for likely duplicates: same vendor and amount, near-matching invoice numbers and bills already…
  • Email subject lines prompt: Get ten honest subject lines for a finished email, each with preview text and a character count, grouped by approach so you can…

All free prompt templates

More terms on this topic

Gross marginMachine learningMulti-factor authentication (MFA)Reasoning modelSynthetic dataTrial balanceUtilization rate

More prompts on this topic

Browse related tutorials