Skip to content

What is Zhin.js ​

Zhin.js is a TypeScript framework for building chat bots. You write your bot logic once — commands, auto-replies, scheduled pushes, AI chat — and run it on QQ, WeChat, Discord, Telegram, Slack, DingTalk, Lark and 20+ other platforms at the same time.

The one-line difference from calling platform SDKs directly: adapters absorb the platform differences, so your code only ever sees one kind of message.

What it is good for ​

ScenarioExamples
Community / group botsCheck-ins, raffles, mini-games, keyword replies, welcome messages
Personal or team assistantsReminders, calendars, RSS feeds, daily briefings
Multi-platform support / notificationsOne codebase serving a QQ group, WeCom and Telegram together
AI chat assistantsConnect OpenAI / Ollama and let the model call tools you write

It is not an in-editor coding agent like Cursor or Claude Code. Zhin's AI features exist to power bots that live on chat platforms.

What a bot is made of ​

Keep this picture in mind — the rest of the docs zoom into one box at a time:

text
  Chat platform                 Your project (a plugin)                       Chat platform
┌──────────┐   ┌─────────┐   ┌──────────────────────────────────┐   ┌─────────┐
│ QQ / WeCh│──▶│ Adapter │──▶│ Middleware → Command → (opt.) AI │──▶│ Adapter │──▶ reply
│ Discord… │   │         │   │   ↑ tools / components / schedules│   │         │
└──────────┘   └─────────┘   └──────────────────────────────────┘   └─────────┘
                                          ▲
                     Console (browser): logs, config, send test messages
PartWhat it isWhat you do
PluginYour project itself is a plugin; split into child plugins as it growsWrite plugin.ts and add a zhin field to package.json
CommandA function that runs when a user sends /helloWrite defineCommand() in commands/hello/index.ts
MiddlewareAn interceptor every message passes through — keyword replies, filtersWrite defineMiddleware() in middlewares/
AdapterAn npm package that connects one platform, e.g. @zhin.js/adapter-qqPick it and fill in credentials with npx zhin setup --adapters
AI Agent (optional)Messages that match no command go to an LLM, which can call your toolsRun npx zhin setup --ai and write tools in tools/
ConsoleA browser admin UI at console.zhin.devNothing to deploy — enter your bot's address and token

Exact definitions live in Core concepts at a glance.

Three design choices ​

  1. Small by default, add what you need. The IM core alone is under 10MB. AI, image rendering and speech are separate packages. You can build and test everything without a model key.
  2. Capabilities are discovered from folders. Drop a file in commands/, middlewares/, tools/… and it is registered — no long list of registration calls in your entry file.
  3. No restarts while you code. Saving a file hot-reloads the bot. If the new code fails to load, the previous version keeps serving.

Where to start ​

You areRead firstThen
New here and want to see it runQuick start (10 minutes, no accounts or keys)Core concepts
Writing your own featuresFirst pluginCommands · Conventions
Connecting a real platformAdaptersConfiguration
Adding AIAI overviewAI Agent path
Deploying to productionDeployment and recoveryTroubleshooting
Curious about internals or contributingLayered architectureContributing

Don't want to install anything yet? Try the live demo.