mirror of
https://github.com/vercel/chat.git
synced 2026-09-14 18:32:29 +08:00
b75eedbb5f
## summary adds an opt-in `burst` concurrency strategy for #414 when a thread is idle, the first message waits for `debounceMs`, messages that arrive during that window are queued, and the handler runs once with the latest message plus earlier burst messages in `context.skipped` after the handler finishes, messages that arrived while it was running are drained like `queue`, so the latest queued message is processed with earlier queued messages in `context.skipped` keeps existing `drop`, `queue`, `debounce`, and `concurrent` behavior unchanged updates docs to cover `burst`, explain when to choose it over `debounce`, and document the related `MessageContext` behavior
3.4 KiB
3.4 KiB
Chat SDK
A unified TypeScript SDK for building chat bots across Slack, Microsoft Teams, Google Chat, Discord, Telegram, GitHub, Linear, and WhatsApp. Write your bot logic once, deploy everywhere.
Installation
npm install chat
Install adapters for your platforms:
npm install @chat-adapter/slack @chat-adapter/teams @chat-adapter/gchat @chat-adapter/discord @chat-adapter/telegram
Usage
import { Chat } from "chat";
import { createSlackAdapter } from "@chat-adapter/slack";
import { createRedisState } from "@chat-adapter/state-redis";
const bot = new Chat({
userName: "mybot",
adapters: {
slack: createSlackAdapter(),
},
state: createRedisState(),
});
bot.onNewMention(async (thread) => {
await thread.subscribe();
await thread.post("Hello! I'm listening to this thread.");
});
bot.onSubscribedMessage(async (thread, message) => {
await thread.post(`You said: ${message.text}`);
});
See the Getting Started guide for a full walkthrough.
Adapters
Browse official, vendor-official, and community adapters on chat-sdk.dev/adapters. A cross-platform feature matrix is available at chat-sdk.dev/docs/adapters.
Features
- Event handlers — mentions, messages, reactions, button clicks, slash commands, modals
- AI streaming — stream LLM responses with native Slack streaming and post+edit fallback
- Cards — JSX-based interactive cards (Block Kit, Adaptive Cards, Google Chat Cards)
- Actions — handle button clicks and dropdown selections
- Modals — form dialogs with text inputs, dropdowns, and validation
- Slash commands — handle
/commandinvocations - Emoji — type-safe, cross-platform emoji with custom emoji support
- File uploads — send and receive file attachments
- Direct messages — initiate DMs programmatically
- Ephemeral messages — user-only visible messages with DM fallback
- Overlapping messages - burst, queue, debounce, drop, or process concurrent messages on the same thread
AI coding agent support
If you use an AI coding agent like Claude Code, you can teach it about Chat SDK:
npx skills add vercel/chat
Documentation
Full documentation is available at chat-sdk.dev/docs.
Contributing
See CONTRIBUTING.md for development setup and the release process.
Support
For help or questions, see SUPPORT.md. To report a security vulnerability, see SECURITY.md.
License
MIT