惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

O
OpenAI News
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园_首页
博客园 - 三生石上(FineUI控件)
美团技术团队
博客园 - 叶小钗
博客园 - 司徒正美
Jina AI
Jina AI
Apple Machine Learning Research
Apple Machine Learning Research
The Cloudflare Blog
博客园 - 聂微东
博客园 - 【当耐特】
罗磊的独立博客
月光博客
月光博客
WordPress大学
WordPress大学
Last Week in AI
Last Week in AI
小众软件
小众软件
P
Privacy International News Feed
V
V2EX
T
The Exploit Database - CXSecurity.com
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
A
Arctic Wolf
T
Threatpost
博客园 - Franky
The Hacker News
The Hacker News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
GRAHAM CLULEY
H
Hacker News: Front Page
雷峰网
雷峰网
C
Cybersecurity and Infrastructure Security Agency CISA
J
Java Code Geeks
P
Palo Alto Networks Blog
H
Heimdal Security Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Vulnerabilities – Threatpost
The Last Watchdog
The Last Watchdog
T
Tor Project blog
爱范儿
爱范儿
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
C
Cisco Blogs
www.infosecurity-magazine.com
www.infosecurity-magazine.com
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
腾讯CDC
V
Visual Studio Blog
S
Schneier on Security
大猫的无限游戏
大猫的无限游戏
T
Threat Research - Cisco Blogs

Chat SDK Documentation

Teams Low-Level APIs Platform Adapters | Chat SDK State Adapters | Chat SDK Cards | Chat SDK Getting Started | Chat SDK Introduction | Chat SDK Modals | Chat SDK Slack Low-Level APIs | Chat SDK Streaming | Chat SDK Testing | Chat SDK Overview | Chat SDK toAiMessages | Chat SDK Cards | Chat SDK Overview | Chat SDK Markdown | Chat SDK Modals | Chat SDK AI SDK Tools | Chat SDK Types | Chat SDK Message Subject | Chat SDK Conversation History | Chat SDK Transcripts | Chat SDK Slack bot with Next.js and Redis Actions | Chat SDK Direct Messages | Chat SDK Emoji | Chat SDK Error Handling | Chat SDK File Uploads | Chat SDK Handling Events | Chat SDK Posting Messages | Chat SDK Slash Commands | Chat SDK State Adapters | Chat SDK Threads, Messages, and Channels | Chat SDK Creating a Chat Instance | Chat SDK WhatsApp Business Cloud Channel | Chat SDK Chat | Chat SDK Platform Adapters | Chat SDK Overlapping Messages | Chat SDK Ephemeral Messages | Chat SDK Message | Chat SDK Thread | Chat SDK Building a community adapter | Chat SDK Documenting your adapter | Chat SDK Publishing your adapter | Chat SDK Testing adapters | Chat SDK Code review GitHub bot with Hono and Redis Discord support bot with Nuxt and Redis Durable chat sessions with Next.js, Workflow, and Redis Schedule Slack posts with Next.js, Workflow, and Neon PostableMessage | Chat SDK
CLI | Chat SDK
Vercel · 2026-06-16 · via Chat SDK Documentation

Scaffold a Chat SDK bot app with a single command.

create-chat-sdk creates a minimal Next.js app for Chat SDK bots.

The CLI will generate your Chat configuration, webhook route, .env.example file, dependencies, and optional Web adapter route from the adapter catalog.

create-chat-sdk automatically detects when it is being run by Cursor, Claude Code, or another coding agent. In agent environments, pass at least one platform adapter with --adapter; the state adapter defaults to memory. The CLI runs non-interactively and uses my-bot when no project name is provided. Pass --interactive to force prompts.

Pass platform and state adapters with --adapter:

npm create chat-sdk@latest -- my-bot --adapter slack redis -y

With npm, the -- separator is required because npm consumes flags before it (-y is npm's own --yes) instead of forwarding them to the CLI. pnpm create and yarn create forward flags without it.

The interactive prompt lists official adapters by default. Pass --vendor to list only vendor-official adapters instead. Automation and coding agents can install any CLI-supported official or vendor adapter directly with --adapter.

Adapters that require a long-running process, including Matrix and Lark, cannot run on the webhook-only serverless runtime and are not available through the CLI. Add them to an existing project manually instead.

View available adapter slugs

Examples:

npm create chat-sdk@latest -- slack-bot --adapter slack memory -y --skip-install
npm create chat-sdk@latest -- gchat-bot --adapter gchat redis -y --pm pnpm
npm create chat-sdk@latest -- email-bot --adapter resend postgres -y --no-git
npm create chat-sdk@latest -- my-bot --adapter slack memory -y --force

The scaffolded app is webhook-only. It does not include pages, layouts, or a client UI.

src/
  lib/bot.ts                              Bot configuration and handlers
  app/api/webhooks/[platform]/route.ts    Dynamic platform webhook route
  app/api/chat/route.ts                   Web adapter route, only when selected
  app/api/discord/gateway/route.ts        Discord Gateway listener, only when selected
.env.example                              Required environment variables
next.config.ts                            Next.js server config
vercel.json                               Cron schedules, only when needed
.chat-sdk.json                            Generated file ownership for safe reruns
package.json                              Adapter dependencies

Webhook endpoints use the selected adapter slug:

/api/webhooks/slack
/api/webhooks/gchat
/api/webhooks/discord

When the Web adapter is selected, the CLI also creates /api/chat for browser chat requests and a small getUser auth stub. Replace the stub with your app's real authentication logic so each web conversation can be associated with the correct user.

When the Discord adapter is selected, the CLI also creates a Gateway listener at /api/discord/gateway and a vercel.json cron that calls it. Discord delivers slash commands and button clicks to the webhook route, but regular messages and reactions only arrive over the Gateway WebSocket, so the cron keeps that connection alive and forwards events to /api/webhooks/discord. Set a CRON_SECRET environment variable to authenticate the cron requests. The generated serverless Gateway cron requires Vercel Pro or Enterprise because it runs every nine minutes.

OptionDescription
[name]Name of the project.
-d, --description <text>Project description.
--adapter <values...>Platform or state adapters to include.
--vendorList only vendor-official adapters in the interactive prompt.
--pm <manager>Package manager to use: npm, yarn, pnpm, or bun.
-y, --yesSkip prompts and accept defaults.
--interactiveAlways prompt, even when a coding agent environment is detected.
-f, --forceOverwrite generated files in an existing directory.
-s, --skip-installSkip dependency installation.
--no-gitSkip git repository initialization.
-q, --quietSuppress non-essential output.

Color output follows the NO_COLOR standard — set NO_COLOR=1 to disable colors.

Most bot behavior lives in src/lib/bot.ts. Start there when you want to:

  • Add or change handlers like onNewMention, onSubscribedMessage, onNewMessage, reactions, actions, or slash commands.
  • Adjust adapter configuration, for example passing explicit credentials or platform-specific options instead of relying only on environment variables.
  • If you selected the memory state adapter, switch to Redis, ioredis, or PostgreSQL before deploying to production.

The generated file includes starter handlers for mentions and subscribed thread replies.

After scaffolding:

cd my-bot
cp .env.example .env.local
npm run dev

Fill in the generated environment variables, expose your local server, and configure each selected platform to call its /api/webhooks/{adapter} endpoint.

See guides, templates, and examples on the resources page.