vercel/chat
Universal chat layer for building bots and agents.
Overview
Chat SDK is a TypeScript library from Vercel that lets developers write a single bot implementation and run it on many chat platforms – Slack, Microsoft Teams, Google Chat, Discord, Telegram, GitHub, Linear, WhatsApp, and more. The core package (chat) provides the bot runtime, while separate adapter packages translate the generic SDK calls into the APIs of each platform.
Key Concepts
| Concept | What it means | Why it matters |
|---|---|---|
| Unified Bot Logic | You create a Chat instance, register event handlers (mentions, messages, button clicks, etc.), and the SDK routes those events from any connected platform. |
Write‑once, deploy‑anywhere; reduces duplicated code across Slack, Teams, etc. |
| Adapters | Small npm packages (@chat-adapter/slack, @chat-adapter/teams, …) that implement the platform‑specific webhook handling and API calls. |
Add or remove platforms by installing/uninstalling the corresponding adapter. |
| State Management | The SDK is stateless by default; you can plug in a state store (e.g., Redis via @chat-adapter/state-redis). |
Persist conversation context, user preferences, or any custom data. |
| AI Streaming | Built‑in support for streaming LLM responses back to the chat client (Slack streaming, Telegram draft previews, etc.). | Gives a responsive “typing…” experience when the bot is powered by a language model. |
| Rich UI | JSX‑based cards, modals, slash commands, emoji, file uploads, and ephemeral messages are all abstracted across platforms. | Build interactive experiences without learning each platform’s UI spec. |
| Concurrency Controls | Helpers for handling multiple messages arriving on the same thread (burst, queue, debounce, drop). | Prevents race conditions and duplicate replies. |
Typical Workflow
- Create a project –
npx create-chat-sdk@latest my-botscaffolds a Next.js app with a ready‑to‑useChatconfig, webhook route, and example.env. - Add adapters –
npm i @chat-adapter/slack @chat-adapter/teams(or any others you need). - Write bot logic – Import
Chat, instantiate it, and attach handlers likebot.onNewMentionorbot.onSubscribedMessage. - Deploy – Deploy the Next.js app to Vercel (or any Node host). The adapters expose HTTP endpoints that Vercel’s serverless functions can receive from the chat platforms.
- Optional AI integration – Install an LLM (OpenAI, Claude, etc.) and use the streaming feature to send partial replies as they are generated.
Example Code (from README)
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}`);
});
The same bot object would respond on Teams, Discord, etc., once the corresponding adapters are added.
Ecosystem & Extensibility
- Adapter Catalog (
@chat-adapter/catalog) – a dependency‑free list of every published adapter, their capabilities, and required environment variables. Useful for tooling, CLIs, or UI wizards. - AI Coding Agent Skill – a Vercel‑specific plugin (
npx skills add vercel/chat) that teaches AI assistants (e.g., OpenAI Codex) the SDK’s API surface, enabling them to generate or modify bot code automatically. - Vercel Plugin – bundles the Chat SDK skill with other agent tools, making it easy to add AI‑assisted development to a Vercel project.
Who Might Use It?
- Product teams that need a support bot on multiple internal chat tools without maintaining separate codebases.
- Developers building AI‑powered assistants (e.g., code reviewers, knowledge bases) that should be reachable from Slack, Teams, or Discord.
- Consultants who deliver chatbot solutions for clients with heterogeneous communication stacks.
Documentation & Support
- Full docs: https://chat-sdk.dev/docs
- Adapter list & guides: https://chat-sdk.dev/adapters
- Vercel Knowledge Base article: https://vercel.com/kb/chat-sdk
- Open source MIT license; contribution guide and security policy are included in the repo.
All details above are taken directly from the repository’s README.
Related
- Project
- Project
- Project
- Project
- Project