$npx -y skills add vercel-labs/open-agents --skill chat-sdkBuild multi-platform chat bots with Chat SDK (chat npm package). Use when developers want to (1) Build a Slack, Teams, Google Chat, Discord, Telegram, GitHub, Linear, or WhatsApp bot, (2) Use Chat SDK to handle mentions, direct messages, subscribed threads, reactions, slash com
| 1 | # Chat SDK |
| 2 | |
| 3 | Unified TypeScript SDK for building chat bots across Slack, Teams, Google Chat, Discord, Telegram, GitHub, Linear, and WhatsApp. Write bot logic once, deploy everywhere. |
| 4 | |
| 5 | ## Start with published sources |
| 6 | |
| 7 | When Chat SDK is installed in a user project, inspect the published files that ship in `node_modules`: |
| 8 | |
| 9 | ``` |
| 10 | node_modules/chat/docs/ # bundled docs |
| 11 | node_modules/chat/dist/index.d.ts # core API types |
| 12 | node_modules/chat/dist/jsx-runtime.d.ts # JSX runtime types |
| 13 | node_modules/chat/docs/contributing/ # adapter-authoring docs |
| 14 | node_modules/chat/docs/guides/ # framework/platform guides |
| 15 | ``` |
| 16 | |
| 17 | If one of the paths below does not exist, that package is not installed in the project yet. |
| 18 | |
| 19 | Read these before writing code: |
| 20 | - `node_modules/chat/docs/getting-started.mdx` — install and setup |
| 21 | - `node_modules/chat/docs/usage.mdx` — `Chat` config and lifecycle |
| 22 | - `node_modules/chat/docs/handling-events.mdx` — event routing and handlers |
| 23 | - `node_modules/chat/docs/threads-messages-channels.mdx` — thread/channel/message model |
| 24 | - `node_modules/chat/docs/posting-messages.mdx` — post, edit, delete, schedule |
| 25 | - `node_modules/chat/docs/streaming.mdx` — AI SDK integration and streaming semantics |
| 26 | - `node_modules/chat/docs/cards.mdx` — JSX cards |
| 27 | - `node_modules/chat/docs/actions.mdx` — button/select interactions |
| 28 | - `node_modules/chat/docs/modals.mdx` — modal submit/close flows |
| 29 | - `node_modules/chat/docs/slash-commands.mdx` — slash command routing |
| 30 | - `node_modules/chat/docs/direct-messages.mdx` — DM behavior and `openDM()` |
| 31 | - `node_modules/chat/docs/files.mdx` — attachments/uploads |
| 32 | - `node_modules/chat/docs/state.mdx` — persistence, locking, dedupe |
| 33 | - `node_modules/chat/docs/adapters.mdx` — cross-platform feature matrix |
| 34 | - `node_modules/chat/docs/api/chat.mdx` — exact `Chat` API |
| 35 | - `node_modules/chat/docs/api/thread.mdx` — exact `Thread` API |
| 36 | - `node_modules/chat/docs/api/message.mdx` — exact `Message` API |
| 37 | - `node_modules/chat/docs/api/modals.mdx` — modal element and event details |
| 38 | |
| 39 | For the specific adapter or state package you are using, inspect that installed package's `dist/index.d.ts` export surface in `node_modules`. |
| 40 | |
| 41 | ## Quick start |
| 42 | |
| 43 | ```typescript |
| 44 | import { Chat } from "chat"; |
| 45 | import { createSlackAdapter } from "@chat-adapter/slack"; |
| 46 | import { createRedisState } from "@chat-adapter/state-redis"; |
| 47 | |
| 48 | const bot = new Chat({ |
| 49 | userName: "mybot", |
| 50 | adapters: { |
| 51 | slack: createSlackAdapter(), |
| 52 | }, |
| 53 | state: createRedisState(), |
| 54 | dedupeTtlMs: 600_000, |
| 55 | }); |
| 56 | |
| 57 | bot.onNewMention(async (thread) => { |
| 58 | await thread.subscribe(); |
| 59 | await thread.post("Hello! I'm listening to this thread."); |
| 60 | }); |
| 61 | |
| 62 | bot.onSubscribedMessage(async (thread, message) => { |
| 63 | await thread.post(`You said: ${message.text}`); |
| 64 | }); |
| 65 | ``` |
| 66 | |
| 67 | ## Core concepts |
| 68 | |
| 69 | - **Chat** — main entry point; coordinates adapters, routing, locks, and state |
| 70 | - **Adapters** — platform-specific integrations for Slack, Teams, Google Chat, Discord, Telegram, GitHub, Linear, and WhatsApp |
| 71 | - **State adapters** — persistence for subscriptions, locks, dedupe, and thread state |
| 72 | - **Thread** — conversation context with `post()`, `stream()`, `subscribe()`, `setState()`, `startTyping()` |
| 73 | - **Message** — normalized content with `text`, `formatted`, attachments, author info, and platform `raw` |
| 74 | - **Channel** — container for threads and top-level posts |
| 75 | |
| 76 | ## Event handlers |
| 77 | |
| 78 | | Handler | Trigger | |
| 79 | |---------|---------| |
| 80 | | `onNewMention` | Bot @-mentioned in an unsubscribed thread | |
| 81 | | `onDirectMessage` | New DM in an unsubscribed DM thread | |
| 82 | | `onSubscribedMessage` | Any message in a subscribed thread | |
| 83 | | `onNewMessage(regex)` | Regex match in an unsubscribed thread | |
| 84 | | `onReaction(emojis?)` | Emoji added or removed | |
| 85 | | `onAction(actionIds?)` | Button clicks and select/radio interactions | |
| 86 | | `onModalSubmit(callbackId?)` | Modal form submitted | |
| 87 | | `onModalClose(callbackId?)` | Modal dismissed/cancelled | |
| 88 | | `onSlashCommand(commands?)` | Slash command invocation | |
| 89 | | `onAssistantThreadStarted` | Slack assistant thread opened | |
| 90 | | `onAssistantContextChanged` | Slack assistant context changed | |
| 91 | | `onAppHomeOpened` | Slack App Home opened | |
| 92 | | `onMemberJoinedChannel` | Slack member joi |