Bot developer docs
Bots are first-class on Zuse: a bot is its own account, listed in channels like anyone else, and signs in with a token. The simplest way to build one is the TypeScript SDK; the protocol underneath is plain JSON over a WebSocket, so any language works.
Get a bot and a token
- Sign in, then open Your bots from the menu at the top right.
- Create a bot (this picks its username) and make a token with the permissions it needs.
- Copy the token straight away. It starts with
zb_, is shown once, and only a fingerprint of it is kept. Treat it like a password: never commit it, and revoke it from the same page if it leaks.
Quick start with the SDK
npm install @zusechat/sdk
import { Bot } from "@zusechat/sdk";
const bot = new Bot({ token: process.env.BOT_TOKEN! });
bot.on("message", async (msg) => {
if (msg.body === "!ping") await msg.reply("pong");
});
bot.on("error", console.error);
await bot.connect();
await bot.join("bots");The SDK reconnects with backoff, rejoins channels, and paces what it sends to the flood limit. Its README lists every event and option.
Permissions
A token carries scopes that apply in every channel the bot joins. Give a bot the least it needs.
- Read (
read): Join channels and receive messages, joins, leaves and role changes. - Say (
say): Send messages and emotes where the bot is allowed to speak. - Whisper (
whisper): Send a private message that only one person in the channel sees (nothing is stored). Good for help replies and hints. - Moderate (
moderate): Kick, ban, mute, set topics and speaking policy, and change roles, as far as the bot's channel role allows. - Manage (
manage): Everything in Moderate, plus managing channel settings. Give this only to bots you fully trust.
A bot with the whisper scope can answer privately: msg.replyPrivately("...") or bot.whisper(channel, user, "...") sends a message that only that person sees, so a help bot does not fill the channel. Nothing is stored, the person can mute the bot, and it is limited per person. Private messages sent to the bot arrive as the whisper event.
Scopes are only half of it: moderation also needs a high enough role in the channel, the same rank rules as for people (an op cannot act on the owner or another op).
Without the SDK
Open a WebSocket to wss://api.zuse.chat/gateway and send your first frame within a few seconds, or the connection is closed. Every frame is JSON shaped { "op": "...", "d": { ... }, "id": "optional" }.
{ "op": "identify", "d": { "protocol": 1, "token": "zb_..." } }
{ "op": "join", "d": { "channel": "bots" } }
{ "op": "say", "d": { "channel": "bots", "body": "hello" } }The gateway answers ready, then channel_state for each join (topic, members, your role, recent history), then streams message, user_join, user_leave and other frames. Errors come aserror frames carrying a code such as muted or read_only, and sending too fast is answered with a rate_limited frame saying how long to wait. The schemas are in the @zusechat/protocol package.
Limits and rules
- Messages are at most 500 characters, and plain text only. Formatting is never interpreted as markup.
- Chat is flood-limited: a burst of 5 messages, then about one per second. The SDK queues for you; raw clients should too.
- A person can own a limited number of bots and a bot a limited number of active tokens.
- Some channels limit who may speak (everyone, trusted users, or ops). A bot that may not speak gets a
read_onlyerror. - Zuse staff can suspend a bot (its connections are dropped and its tokens stop working until it is restored) and can set how fast a bot may send messages; you can lower your own bot’s speed from the Bots page. A channel’s ops can switch bots off in that channel, and a bot that tries to join gets a
forbiddenerror. - Do not answer other bots. Check
msg.author.kind === "bot"and ignore those messages, so two bots cannot set each other off in a loop. Bots do not earn XP, and running a script on a person’s account (self-botting) is not allowed. - Bots follow the Terms like everyone else. Spam, harassment and anything that harms other people gets a bot removed, and its owner is responsible for it.