Skip to content

SYSTEM Cited by 2 sources

Vercel Chat SDK

Chat SDK (chat-sdk.dev) is Vercel's open-source, public-beta TypeScript library for building chat bots that run across multiple messaging platforms from a single codebase. The core chat package handles event routing and application logic; per-platform adapter packages (@chat-adapter/slack, @chat-adapter/discord, @chat-adapter/whatsapp, etc.) implement the platform-specific concerns. Architectural thesis: it is to messaging platforms what the AI SDK is to model providers — a single uniform interface with platform/provider quirks sealed behind swappable adapters.

(Sources: sources/2026-04-21-vercel-build-knowledge-agents-without-embeddings, sources/2026-04-21-vercel-chat-sdk-brings-agents-to-your-users.)

Why it shows up on this wiki

Canonical instance of the multi-platform chat adapter with single shared agent pattern, and composition host for three adjacent patterns: - patterns/platform-adaptive-component-rendering — JSX components (Table, Card, Modal, Button) with native rendering per platform and graceful fallback. - patterns/streaming-markdown-to-native-conversion — the fallback streaming path for non-Slack platforms: per-intermediate-edit markdown-to-native conversion so users never see literal **bold**. - patterns/pluggable-state-backend — Redis / ioredis / Postgres as swappable state adapters (TTL cache + distributed locks + namespaced prefixes).

Canonical adapter shape

import { Chat } from "chat";
import { createSlackAdapter } from "@chat-adapter/slack";
import { createRedisState } from "@chat-adapter/state-redis";

const bot = new Chat({
  adapters: {
    slack: createSlackAdapter(),
  },
  state: createRedisState(),
});

bot.onNewMention(async (thread) => {
  await thread.subscribe();
  await thread.post("Hello! I'm listening to this thread now.");
});

bot.onSubscribedMessage(async (thread, message) => {
  await thread.post(`You said: ${message.text}`);
});

The contract: event-handler callbacks + thread-scoped helpers are defined once, adapter set is changed via constructor. "Each adapter auto-detects credentials from environment variables, so you can get started without any additional configuration. Switching from Slack to Discord means swapping the adapter, not rewriting the bot."

Supported platforms (2026-04-21 disclosure)

From the 2026-04-21 launch post:

"Chat SDK is a TypeScript library for building bots that work across Slack, Microsoft Teams, Google Chat, Discord, Telegram, GitHub, and Linear from a single codebase."

Subsequently also: - WhatsApp (via @chat-adapter/whatsapp; community PR #102 by @ghellach) — constrained by [[concepts/messaging-platform-24-hour-response-window|24-hour messaging window]]; adapter supports messages, reactions, auto-chunking, read receipts, multi-media downloads (images, voice messages, stickers), and location sharing with Google Maps URLs; does not support message history, editing, or deletion. Cards render as interactive reply buttons with up to three options, falling back to formatted text.

Prior wiki appearance also named GitHub and Discord as the adapter set shipping with the Knowledge Agent Template.

Plus a public adapter directory for official + community adapters.

Streaming model

Two explicit streaming paths:

  • Native streaming path (Slack). "Slack has a native streaming path that renders bold, italic, lists, and other formatting in real time as the response arrives." Even here, Chat SDK runs a standard-markdown-to-Slack-mrkdwn conversion on the append-only stream, so the model's generic markdown output renders correctly in Slack's variant.
  • Fallback streaming path (Discord / Teams / others). Streamed text "passes through each adapter's markdown-to-native conversion pipeline at each intermediate edit." Before this pipeline existed, users saw literal **bold** mid-stream; now it's converted per intermediate edit. Canonical instance of patterns/streaming-markdown-to-native-conversion.

AI-SDK text-stream integration

const result = await streamText({
  model: "anthropic/claude-sonnet-4",
  prompt: "Summarize what's happening in this thread.",
});
await thread.post(result.textStream);

thread.post() accepts AI-SDK textStream values directly — one line pipes a streaming LLM into the adapter-rendered thread. This is the composition join-point between AI SDK and Chat SDK.

Component rendering

JSX primitives rendered natively per platform — see patterns/platform-adaptive-component-rendering:

<Table
  headers={["Name", "Status", "Region"]}
  rows={[
    ["api-prod", "healthy", "iad1"],
    ["api-staging", "degraded", "sfo1"],
  ]}
/>

Native per-platform rendering:

Platform <Table> rendering
Slack Block Kit table blocks
Microsoft Teams GFM markdown tables
Discord GFM markdown tables
Google Chat Monospace text widgets
Telegram Code blocks
GitHub, Linear Existing markdown pipelines

"Cards, modals, and buttons work similarly. You write the element once using JSX, and each adapter renders them in whatever format the platform supports natively. If a platform doesn't support a given element, it will fall back gracefully."

State adapters

Pluggable backend — see patterns/pluggable-state-backend:

Backend Package Status
Redis @chat-adapter/state-redis Launch
ioredis (implicit in post) Launch
PostgreSQL @chat-adapter/state-postgres Production-ready as of 2026-04-21; community PR #154 by @bai

The Postgres adapter "uses pg (node-postgres) with raw SQL and automatically creates the required tables on first connect. It supports TTL-based caching, distributed locking across multiple instances, and namespaced state via a configurable key prefix."

State layer backs: thread subscriptions, distributed locks, key-value cache.

Single-platform value (e.g. Slack-only)

The SDK is worth adopting even on a single platform because:

  • Clear-text name resolution is bidirectional: inbound <@UXXX>@alice for prompt context; outbound @alice<@UXXX> so the mention notification actually fires.
  • Automatic context enrichment: "Chat SDK automatically includes link preview content, referenced posts, and images directly in agent prompts."
  • Markdown-dialect conversion: standard markdown → Slack mrkdwn in real time, even over the append-only streaming API.

Coding-agent onboarding

"To augment your coding agents, install the Chat skill: npx skills add vercel/chat."

The SDK also ships a canned migration prompt for consolidating platform-scattered bot code "into a single unified implementation where core behavior is defined once and adapters handle platform differences." Parallel shape to the read-only curated example filesystem v0 uses for the AI SDK.

Docs + sample apps

Chat SDK documentation covers getting started, platform adapter setup, state configuration, and guides for: - Slack bot with Next.js and Redis - Discord support bot with Nuxt - GitHub code review bot with Hono

Relation to AI SDK

The Chat SDK is the distribution surface; the AI SDK is the agent substrate. The composition pattern is single-line — thread.post(result.textStream) — and was explicitly called out in the launch post as the canonical shape.

Seen in

Last updated · 476 distilled / 1,218 read