Files
Ben Sabic 9b8d8c4518 Discoverability lift: link KB guides, broaden npm keywords, mirror to AGENTS.md (#560)
Broad SEO/AEO pass across the docs site, adapter READMEs and AGENTS.md
files, and npm package metadata so Chat SDK content shows up better in
search engines, in LLM-driven package recommendations, and in
IDE/coding-agent context.

**Docs site**

- Adds a `## Resources` section to the Getting Started and AI overview
pages and to the Slack, Discord, GitHub, Liveblocks, and Sendblue
adapter pages, each linking to applicable guides/templates with
descriptions sourced from `resources-edge-config.json` and a cross-link
back to the central `/resources` hub.

**Adapter packages**

- Mirrors the same Resources sections into the Slack, Discord, and
GitHub READMEs (so they surface on npm) and into their AGENTS.md files
(so coding agents see them alongside the API notes).
- Expands `keywords` on every published adapter and state package — adds
`chat-sdk`, `chatbot`, `ai-agent`, `ai-sdk`, `vercel`, plus
platform-specific terms like `slack-bot`, `block-kit`, `slash-commands`,
`github-app`, `whatsapp-business`, `state-adapter`.

**Resources registry**

- Registers four new entries in `resources-edge-config.json`
(Human-in-the-Loop guide, Liveblocks AI agent guide, Slack + Vercel Blob
guide, Durable iMessage Agent template) and runs `pnpm sync-resources`
so the bundled `chat` package guides, `templates.json`, and
`skills/chat/SKILL.md` all pick them up.
- Fixes the synced Slack AI agent guide to import `toAiMessages` from
`chat/ai` instead of the deprecated `chat` re-export path (the upstream
KB source has also been updated, so future syncs will preserve this).

**Drive-by fixes**

- Resend adapter doc quick start: corrects `MemoryStateAdapter` class
import to the `createMemoryState()` factory (matching every other
adapter doc).
- Zalo adapter doc: drops the "community adapter" callout that
duplicated frontmatter.

**Tooling / CI**

- Adds `tsx` as a root devDependency so `pnpm sync-resources` works out
of the box (it previously relied on `npx tsx`, which hung when not
pre-cached).
- Loosens the CI changeset gate to also skip `packages/chat/resources/`
(generated data), matching the existing `*.md` carve-out.

---------

Co-authored-by: Ben Sabic <bensabic@users.noreply.github.com>
2026-05-29 11:41:23 +10:00
..
2026-03-05 16:13:33 -08:00

chat

npm version npm downloads

Core SDK for building multi-platform chat bots. Provides the Chat class, event handlers, JSX card runtime, emoji helpers, and type-safe message formatting.

Installation

npm install chat

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({
      botToken: process.env.SLACK_BOT_TOKEN!,
      signingSecret: process.env.SLACK_SIGNING_SECRET!,
    }),
  },
  state: createRedisState({ url: process.env.REDIS_URL! }),
  dedupeTtlMs: 600_000, // 10 minutes (default: 5 min)
});

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}`);
});

Tip: PostgreSQL and ioredis adapters are also available for production. See State Adapters for all options.

Configuration

Option Type Default Description
userName string required Default bot username across all adapters
adapters Record<string, Adapter> required Map of adapter name to adapter instance
state StateAdapter required State adapter for subscriptions, locking, and dedup
logger Logger | LogLevel "info" Logger instance or log level ("silent" to disable)
streamingUpdateIntervalMs number 500 Update interval for fallback streaming (post + edit) in ms
dedupeTtlMs number 300000 TTL for message deduplication entries in ms. Increase if webhook cold starts cause platform retries (e.g., Slack's http_timeout retry) that arrive after the default window

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.

  • Usage — event handlers, threads, messages, channels
  • Chat API — full Chat class reference
  • Cards — JSX-based interactive cards
  • Streaming — AI SDK integration
  • Emoji — cross-platform emoji helpers

License

MIT