Skip to content

TypeScript · ESM · Plugin Runtime

Zhin.js

Write a chat bot once in TypeScript and run it on QQ, WeChat, Discord, Telegram and 20+ other platforms. A small IM framework by default — add AI when you need it.

IM core <10MBNode ≥20.19MIT
zsh
$ npm create zhin-app my-bot -y
$ cd my-bot && pnpm dev
✔ Bot started — no platform account or model key required

What do you want to do?

You don't need the full architecture first. Pick a goal — each path fits in one sitting.

Why Zhin.js

01

One codebase, 20+ platforms

QQ, WeChat, WeCom, DingTalk, Lark, Discord, Telegram, Slack, KOOK, LINE… Your code sees one kind of message; adapters handle the platform differences.

02

A feature is a file

commands/hello/index.ts is the /hello command. Middleware, components, schedules and AI tools work the same way — no registration boilerplate.

03

No restarts while coding

Save to hot-reload. In-flight messages finish on the old version, and if the new code throws, the old version keeps serving.

04

Develop with zero accounts

The built-in Sandbox is a simulated chat window. Build and test everything without any platform account or model key.

05

Manage it in the browser

Open console.zhin.dev, enter your address and token: send test messages, read logs, edit config, manage plugins. Nothing to deploy.

06

Opt-in AI

The default install is an IM core under 10MB. Run npx zhin setup --ai to add models, tools, memory and MCP.

What a bot looks like

Smallest form: one bot.ts is the whole bot.

ts
import { definePlugin } from 'zhin.js';
import { defineCommand } from 'zhin.js/command';

export default definePlugin({
  name: 'my-bot',
  setup({ addCommand }) {
    addCommand('hello', defineCommand({
      description: 'Say hello',
      execute: () => 'Hello from Zhin!',
    }));
  },
});

As it grows: one file per capability, auto-registered from convention folders.

text
my-bot/
├── plugin.ts                 # entry: definePlugin()
├── commands/hello/index.ts   # the /hello command
├── middlewares/…             # keyword replies, filters
├── tools/…                   # tools the AI can call (optional)
└── zhin.config.yml           # port, platform credentials, models

Running in 10 minutes (no accounts or keys):

bash
npm create zhin-app my-bot -y
cd my-bot && pnpm dev
  1. Open console.zhin.dev
  2. Enter the address printed in the terminal and HTTP_TOKEN from .env
  3. Send /hello in the Sandbox

Next