Most games that want AI dialogue start the same way: call an LLM provider straight from the game client, get something working in an afternoon, then hit four walls in a row. This is about the server that removes all four, and why it is much smaller than you would expect.
Why The Direct Wire Up Breaks
The first wall is memory. The provider API is stateless, so unless you build storage yourself, every player starts each session as a stranger. The elf ranger who betrayed the innkeeper in chapter one is a blank slate by chapter nine.
The second is grounding. The model has never read your world. Ask it about a faction you invented and it will confidently invent a different one, because filling gaps is what it is built to do.
The third is shared play. One HTTP call is one conversation. A table of five players making moves in turn is not something a raw chat endpoint models at all.
The fourth is the key. Anything calling the provider from a browser or an app binary is shipping a credential to a machine you do not control, and rate limits mean you get to find out the hard way.
AbraTabia AI Storyteller is one small PHP application with a single SQLite file that answers all four. You bring your own LLM key, either Anthropic directly or any OpenAI compatible endpoint, which covers OpenAI, OpenRouter and local runners like Ollama and LM Studio. Anything that can make an HTTPS call can be the client: a web game, Unity, mobile, whatever you are already building in.
Three Bot Types, One Endpoint
Everything talks to one chat endpoint, and the bot type decides the behavior.
A storyteller bot is an immersive narrator. It treats your knowledge base as canonical lore, stays in character, and tracks each player's personal journey. Every response carries an action field so your UI knows what just happened: choice at a real decision point, chapter at a scene break, encounter when something important shows up. Your client renders those however it wants, a choice overlay, a chapter card, a combat transition.
A gamehost bot is a turn based game master for 1 to 10 players. It collects secret setup data from each player before the game starts, tracks whose turn it is, tells you when everyone has submitted, and applies whatever rules you send it as plain text. You can define custom actions per request, so the bot signals the events your game actually cares about.
An assistant bot just answers questions from your knowledge base. In game help, an FAQ NPC, a tutorial guide. It raises an angry action when it detects a frustrated user, which is a surprisingly practical escalation hook.
Memory That Survives The Session
The knowledge base takes content three ways: paste it in the admin area, push it through the API, or point the built in crawler at a website. Content gets chunked and embedded, and the relevant pieces are retrieved into every prompt automatically. Embeddings come from OpenAI stored locally in SQLite, or from Upstash Vector, or you can switch retrieval off entirely and run bots from rules alone.
Per player memories are separate from that. Give each player a memory tag and the bot saves key facts after each response, then recalls the relevant ones in later sessions, per player, without you writing any of that plumbing.
Long sessions are handled by distilled bullet summaries returned with each reply and used as compact history. The model can also trigger a cleanup that collapses a drifting conversation down to its important facts, which is what keeps token costs flat instead of climbing with every turn.
What It Actually Needs To Run
PHP 8.1 or newer with curl, pdo_sqlite and dom, all standard. No framework, no dependency install, one SQLite file. That means shared hosting, a VPS, a Docker container or your laptop all work, and there is a browser admin area for creating and tuning bots plus a demo chat page so you can talk to a bot before writing a line of game code.
The whole thing is MIT licensed and free. If you have been putting off AI dialogue because the server side looked like a project of its own, it is worth an hour to find out that it is not.
Top comments (0)