๐Ÿค– 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.js

Everything 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
Read the docs โ†’
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