翻篇收录说明
翻篇网页快照

Introduction | Chat SDK

https://chat-sdk.dev/docs

最近抓取:2026-12-01 23:43:16(北京时间)

最近内容变化:2026-12-01 23:43:05(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

A unified SDK for building chat bots across Slack, Microsoft Teams, Google Chat, Discord, Telegram, and more.

正文摘录

MenuIntroductionChat SDK is a TypeScript library for building chat bots that run on multiple platforms from one codebase. You write the bot logic once and deploy it to any platform that has an adapter. Why Chat SDK? Each chat platform has its own API, webhook format, and quirks, so supporting several of them usually means maintaining separate code for each. Chat SDK puts those differences behind adapters and gives you one interface for: Typed event handlers for mentions, messages, reactions, button clicks, slash commands, and modals Thread subscriptions for multi-turn conversations Cards, buttons, and modals written in JSX that render natively on each platform Streaming LLM responses into a message Serverless deployments, with distributed state in Redis and message deduplication How it works Chat SDK has three core concepts: Chat coordinates your adapters and routes incoming events to your handlers. Adapters handle the platform-specific work: parsing webhooks, formatting messages, and calling the platform's API. State is a pluggable persistence layer for thread subscriptions and distributed locking. lib/bot.tsimport { 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."); }); Adapter and state factories read their credentials from environment variables such as SLACK_BOT_TOKEN, SLACK_SIGNING_SECRET, and REDIS_URL, so the example above passes no options. Pass explicit values to override them. Adapters Install only the adapters you need. Browse the full catalog on the Adapters page, and compare official platform features on Platform Adapters. Adapter CatalogList every adapter with its capabilities and setup requirements from one dependency-free package.Platform AdaptersConnect your bot to messaging platforms with webhook verification, parsing, and native formatting.State AdaptersPersist thread subscriptions, distributed locks, and caches across restarts. AI coding agents If you use an AI coding agent such as OpenAI Codex, Claude Code, or Cursor, install the Chat SDK skill so it knows the SDK's APIs, adapter patterns, and project conventions before it writes code. npx skills add vercel/chat The skill references bundled documentation in node_modules/chat/docs, plus adapter guides and starter templates in the published package. You can also install the Vercel Plugin for a broader agent toolkit. It includes the Chat SDK skill along with specialist agents and slash commands: npx plugins add vercel/vercel-plugin For agent-readable documentation, see llms.txt (page index) or llms-full.txt (full text). Contributing Ship an adapter for a new platform, or list a vendor-maintained one in the catalog. Build an adapterImplement the Adapter interface for any messaging platform or state backend.List a vendor-official adapterHow platform vendors qualify and list a maintained adapter in the Vendor Official tier.Read moreGetting StartedPick a guide to start building with Chat SDK.Creating a Chat InstanceInitialize the Chat class with adapters, state, and configuration options.OverviewAPI reference for the Chat SDK core package.OverviewAI utilities that ship with Chat SDK, including agent tools, message conversion, and supporting types.NextGetting Started