Back to Projects
AI Invoice Automation Bot

AI Invoice Automation Bot

Overview

I built this bot for our family business to make issuing invoices quick and painless. Instead of having to sit down at a computer or fight with spreadsheet cells, anyone on our team can just send a normal text message in Discord. The bot reads what needs to be billed and drops a ready-to-use PDF invoice straight into the chat in a few seconds.

The Problem

Issuing an invoice used to mean breaking your workflow. You either had to struggle through small cells on your phone screen or get up, go find your laptop, wait for it to boot, and type everything in manually. Doing that every couple of days was annoying and often led to mistakes like typos or lost leading zeros in invoice numbers. We just wanted a simple way to get it done from a pocket in ten seconds, no matter where you are.

How It Works

  • Uses Discord as a simple mobile and desktop app so nobody has to install anything new.
  • Checks Discord user IDs against a list in the config file so only our family can use it.
  • Sends the raw text message to Gemini, which pulls out the invoice number, dates, and all items with their units and prices.
  • Writes those values into our Google Sheets template through the API, keeping text formatting so zeros don't disappear.
  • Fills up to four items, clears out any leftover empty rows, exports the sheet to PDF in the background, and drops the file into chat.

Reliability & Hosting

  • Runs as a background service directly on my laptop for now, but the code is set up so I can push it to Railway or a Docker VPS whenever we want it online 24/7.
  • If Google's API throws an error or gets busy, the bot automatically retries and shows a live countdown in Discord so you know it didn't just crash.
  • If the outage lasts too long, it shows simple retry and cancel buttons so you can try again with one tap.
  • Everything runs asynchronously with asyncio, so waiting on APIs doesn't freeze the bot.

How I Built It

  • I came up with the system logic, how data flows between services, and how the bot should behave when something fails.
  • I used AI coding tools like Antigravity, Claude, and Gemini to write the code faster, debug issues, and clean things up.
  • Using AI as a coding assistant helped me turn the idea into a working tool used by my family just in hours.

Planned Features

  • Sending an image preview (JPG) straight to Discord so you can check the invoice without downloading or opening the PDF.
  • Adding a button to email the invoice directly to the client or company with one tap.
  • Moving user IDs from the config file to a small database once more people start using it.

Tech Stack

  • Python, discord.py, asyncio
  • Google Gemini API, Google Sheets API, Google Cloud Console
  • PDF export, JSON
  • Local daemon, ready for Railway / Docker