Foil Engine
AI-powered NPC conversation platform where state machines meet language models.
Foil Engine is a developer platform for building interactive NPCs without scripted dialogue trees. You define character personas and model conversations as state machines. The AI generates natural language responses while following your defined flow, keeping characters in persona across multi-turn conversations.
The system separates concerns cleanly: personas define who the character is, scenarios define conversation structure, states define phases, and transitions define the rules that move between them. Each interaction is evaluated by the AI as one of four decisions (pass, redirect, reject, or kick out), creating structured yet dynamic conversations.
Key Capabilities
- State machine conversations Structured flows with AI-evaluated transitions, not free-form chat
- RAG-enhanced knowledge Real-world facts retrieved via Perplexity and filtered through persona context
- Vendor-agnostic multi-model pipeline Configurable models per service (evaluation, response, summarization) via LiteLLM. Swap providers without code changes
- Visual editor Drag-and-drop state machine builder with live chat preview
- Game-ready SDKs Python, TypeScript, and Unity with full type support and async patterns
- Multi-scenario progression Linked conversation machines with cross-scenario variable passing
Tech Stack
Origin
Foil Engine grew out of the dialogue system originally built for Sexy Unique RPG. After shipping an AI-driven game with custom NPC conversations, I extracted the core engine and rebuilt it as a standalone platform, complete with a visual editor, REST API, and native SDKs for game developers and educators.