Never Type in Excel Again: My Serverless GenAI Expense Bot

The Legacy Data Layer: Why Excel Stayed

Keeping track of expenses sounds simple, until the time spent doing it becomes visible. 

 

What began as a neatly structured Excel file slowly turned into an overall ritual of manually typing long receipts, duplicating cell values, and questioning whether all that effort was still justified. This is the story of how that frustration evolved into a fully serverless, GenAI powered expense bot, without abandoning Excel as the source of truth. 

The Legacy Data Layer: Why Excel Stayed

Long before automation entered the stack, there was Excel. It wasn’t a placeholder; it was a battle-tested analytical tool.  

 

The spreadsheet already had everything it needed: 

It worked. And it worked well. The blocker was never storage or analysis, it was ingestion. A big grocery session meant a kilometer long receipt, dozens of items, and entering the same values repeatedly for the expense category and beneficiary. That was a massive tax on my timelong receipt, dozens of items, and repeating the same values over and over again. 

The Core Trade-Off: Solving the Ingestion Problem

Two questions shaped the technical direction of the solution. 

1. Input design: Scheme vs. Natural Language  

Typing “Bread, milk, vegetables, paid with card” felt far more natural than filling multiple spreadsheet columns, if something could reliably interpret it. The goal was to achieve “instant messaging” like speed with highest accuracy.  

2. Storage: Migration vs. Integration

Where should the data be stored? 


The second decision was the data layer. While migrating to a relational database (PostgreSQL/DynamoDB) offered more flexibility, it also introduced significant overhead: 

The conclusion was a classic engineering pivot: Keep Excel as the “Source of Truth,” but build a modern API wrapper around it. 

Why a Chatbot Became the Obvious Interface

If the goal is to reduce friction, the UI must meet the user where they already are. A mobile-first, chat-based interface was the logical conclusion for real-time expense tracking. 

 

The Comparison: Why Telegram Won 

 

I evaluated several “Natural Language” ingestion points before settling on the stack: 

The transition from a “Project Idea” to a live “Echo Bot” took a very small amount of time. While Telegram bots are technically public-facing, this trade-off was easily mitigated through User ID filtering and authentication middleware within the backend logic. 

The Serverless Lifecycle

Once Telegram was selected, serverless architecture followed naturally. 

 

Rather than maintaining an “always-on” EC2 instance or container that sits idle 99% of the day, the bot follows a purely Event-Driven Lifecycle: 

One technical detail: Telegram expects an HTTP 200 OK response. If the backend fails to respond with a successful status, or if it times out, Telegram will retry the request, potentially causing duplicate entries in the spreadsheet. 

The Parsing Engine: Gemini as a Deterministic Logic Layer

Free text only works if something understands it. 

Structured Parsing

The bot uses Google’s Gemini Flash model not for conversation, but for structured parsing. By applying strict “Prompt Discipline,” the model is constrained to a specific execution pipeline: 

Multimodal Ingestion

Because Gemini Flash is natively multimodal, the pipeline isn’t limited to text. By passing the same prompt instructions alongside a raw image byte-stream, the bot can “read” a physical grocery receipt and extract the same structured JSON as it would from a text message. Reliability comes from prompt discipline, not blind trust. 

Designing the Interaction Flow

The first version worked. Once. Each new message was treated as unrelated. There was no concept of follow-up corrections or additions. 

 

To solve this, I redesigned the interaction into a Stateful Validation Loop. The bot no longer assumes its output is correct; instead, it operates on a “Propose and Confirm” model: 

Ambiguous responses are treated as negative, a deliberate safety choice.  

Designing the Interaction Flow

By design, AWS Lambda functions are stateless. Once a request is fulfilled, the execution environment is destroyed. However, human conversation is inherently stateful—especially when a user needs to confirm or edit parsed data before it’s committed to the “Source of Truth”.

 

To preserve context between messages, the system temporarily stores extracted expenses: 

Why Writing to Excel Was the Hardest Part

Ironically, the most complex engineering challenge wasn’t the generative AI or the serverless logic – it was the integration with Microsoft Excel. Because the goal was a professional, hands-off automation, I had to move beyond simple “local file” scripts and interface with the Microsoft Graph API. 

One time set-up:

Programmatic writes required:

long-lived refresh token is stored securely and rotated automatically, allowing Lambda to work without repeated manual authentication. 

Cost Reality Check

After everything was in place, the final question was cost. 

 

In practice: 

The only charge here came from stored Lambda deployment bundles in S3, amounting to just a few cents. 

Engineering Takeaways: Beyond the Bot

This project was never about building a commercial product; it was an exercise in pragmatic engineering. By solving a personal topic, the build demonstrated four key architectural truths: 

True UX design isn’t about the newest tech  it’s about identifying a specific pain point and building the shortest possible path to solve it. 

In this article:
visual-2-Levi9-article_1200x628-modified
Written by:
Cristian Hasna,
Software Engineer
Levi9 Romania
Published:
1 April 2026

Related posts

Amanda Andriesanu

Delivery Director

Amanda Andriesanu brings over 20 years of experience in software service delivery across diverse industries, including telecom, banking, automotive, and education. With a proven track record of building strong client relationships and leading technology teams in complex business environments, Amanda excels at finding clarity in complexity. She strives to balance just the right amount of ambiguity with predictability, ensuring people and actions align with a meaningful purpose.

Anca Dana Gafiteanu

Delivery Centre Director

Anca Gafiteanu is the Delivery Centre Director at Levi9, overseeing operations in Romania.

With over 15 years of experience in IT and leadership, Anca specializes in managing large-scale delivery teams, driving operational excellence, and fostering collaborative cultures. Anca’s commitment to innovation and her passion for developing talent make her our invaluable leader at Levi9.