๐ค TypeScript ยท AIML 1.0 + 2.0
Build chatbots with
AIML in TypeScript
Full-featured AIML parser, validator, and runtime โ Node.js and the browser.
$
npm install aiml.jsEverything you need
From file parsing to a production-ready API server.
AIML 1.0 & 2.0
All standard tags for both versions โ wildcards, conditions, transforms, triple store, and more.
Isomorphic
Node.js โฅ 18 and modern browsers. ESM + CJS dual build with zero mandatory runtime deps.
Sessions
Per-user predicates, history, topics, and AIML 2.0 triple store with full serialisation.
Validation CLI
aiml-validate lints AIML files before deployment โ exits 1 on errors, ideal for CI.
ChatGPT API
aiml-serve exposes any bot as a ChatGPT-compatible REST API with streaming and Swagger UI.
Data Formats
Properties, substitutions, sets, maps โ text, JSON, or Pandorabots array-of-arrays format.
Opt-in Features
<system> and <javascript> tags are disabled by default; enable them per-bot for trusted AIML.
Full docs
JSDoc on every public symbol, auto-generated API reference, and real-world examples.
Simple, powerful API
Load any AIML knowledge base and start chatting in a few lines. Sessions persist predicates, history, and topics across turns.
- Auto-detects AIML 1.0 / 2.0 per file
- Load from disk, File API, or inline string
- Pandorabots data formats supported
- Drop-in ChatGPT API with
aiml-serve
import { AIML2Bot } from 'aiml.js';
const bot = new AIML2Bot({
properties: { name: 'Alice' },
maps: { capitals: { france: 'Paris' } },
maxRecursionDepth: 200,
});
await bot.loadDirectory('./aiml');
// Single-turn
const { response, sessionId } = await bot.talk('hello');
// Multi-turn โ predicates persist per session
await bot.talk('my name is Bob', sessionId);
const r = await bot.talk('what is my name?', sessionId);
console.log(r.response); // "Your name is Bob."
// Serialise โ store โ restore
const saved = bot.serializeSession(sessionId);
const id = bot.loadSerializedSession(saved);2
AIML versions
50+
Template tags
234
Unit tests