
Building a Chatbot API From Scratch: 13 PRs, a Lot of Broken Things, and a Context Window That Actually Works
Part 3 of building a retail inventory API and then giving it a brain. In Part 1 I explained why I archived my first API and started over. In Part 2 I restructured it properly, migrated to Supabase, and got to 97% test coverage. The retail API is solid now. Working in production. Tests passing. Architecture I can explain. So I started the next thing: a chatbot API. Same stack, new layer. The goal: a conversational AI service that remembers what you said, manages long conversations intelligently, and eventually connects to the retail inventory data. This is what the last few weeks looked like. Why Build the API at All I could use a ready-made chatbot SDK. Drop in a library, wrap the OpenAI call, done in an afternoon. The problem is the same one I had with the retail API the first time. I could make it work without understanding any of it. I wanted to know what happens when a conversation gets too long for the context window. How tokens get counted. Why the response structure changed betw
Continue reading on Dev.to Python
Opens in a new tab



