chat 4.29.0 → 4.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +31 -5
  2. package/dist/adapters/index.d.ts +594 -0
  3. package/dist/adapters/index.js +751 -0
  4. package/dist/ai/index.d.ts +3 -3
  5. package/dist/{chat-D9UYaaNO.d.ts → chat-BjhJs_sP.d.ts} +10 -8
  6. package/dist/{chunk-V25FKIIL.js → chunk-LNXHNIFE.js} +2 -0
  7. package/dist/index.d.ts +4 -4
  8. package/dist/index.js +15 -10
  9. package/dist/{jsx-runtime-CFq1K_Ve.d.ts → jsx-runtime-CzthIo1o.d.ts} +6 -1
  10. package/dist/jsx-runtime.d.ts +1 -1
  11. package/dist/jsx-runtime.js +1 -1
  12. package/docs/adapters.mdx +140 -127
  13. package/docs/ai/index.mdx +6 -0
  14. package/docs/api/cards.mdx +8 -1
  15. package/docs/api/message.mdx +5 -1
  16. package/docs/cards.mdx +9 -1
  17. package/docs/concurrency.mdx +1 -1
  18. package/docs/contributing/building.mdx +6 -0
  19. package/docs/conversation-history.mdx +1 -1
  20. package/docs/create-chat-sdk.mdx +143 -0
  21. package/docs/error-handling.mdx +1 -1
  22. package/docs/getting-started.mdx +7 -3
  23. package/docs/index.mdx +3 -1
  24. package/docs/meta.json +5 -1
  25. package/docs/platform-adapters.mdx +148 -0
  26. package/docs/slack-primitives.mdx +320 -0
  27. package/docs/slash-commands.mdx +6 -1
  28. package/docs/streaming.mdx +1 -1
  29. package/docs/teams-primitives.mdx +255 -0
  30. package/docs/testing.mdx +1 -1
  31. package/docs/threads-messages-channels.mdx +2 -2
  32. package/docs/usage.mdx +3 -3
  33. package/package.json +24 -5
  34. package/resources/guides/create-a-discord-support-bot-with-nuxt-and-redis.md +5 -1
  35. package/resources/guides/how-to-build-a-slack-bot-with-next-js-and-redis.md +5 -1
  36. package/resources/guides/human-in-the-loop-with-chat-sdk-and-workflow-sdk.md +176 -0
  37. package/resources/guides/liveblocks-chat-sdk-ai-sdk.md +165 -0
  38. package/resources/guides/run-and-track-deploys-from-slack.md +7 -5
  39. package/resources/guides/ship-a-github-code-review-bot-with-hono-and-redis.md +5 -1
  40. package/resources/guides/slack-bot-vercel-blob.md +254 -0
  41. package/resources/guides/triage-form-submissions-with-chat-sdk.md +3 -1
  42. package/resources/templates.json +5 -0
  43. /package/docs/{state.mdx → state-adapters.mdx} +0 -0
@@ -5,7 +5,7 @@ type: guide
5
5
  prerequisites:
6
6
  - /docs/handling-events
7
7
  related:
8
- - /docs/state
8
+ - /docs/state-adapters
9
9
  - /docs/streaming
10
10
  ---
11
11
 
@@ -36,6 +36,10 @@ Chat SDK ships with Vercel-maintained adapters for Slack, Teams, Google Chat, Di
36
36
  - Documentation of the adapter in primary vendor docs.
37
37
  - Announcement of the adapter in blog post or changelog and social media.
38
38
 
39
+ <Callout type="info">
40
+ Vendor-official adapters should include a Chat SDK docs PR that adds the adapter to the vendor-official listing and the [`chat/adapters` catalog](/docs/adapters#adapter-catalog-chatadapters). Include the package name, peer dependencies, environment variables, credential modes, and any constructor-only config so setup UIs and onboarding tools can discover the adapter without importing its package.
41
+ </Callout>
42
+
39
43
  ## Project setup
40
44
 
41
45
  This guide uses a hypothetical **Matrix** adapter as a running example. Replace "matrix" with your platform name throughout.
@@ -339,6 +343,8 @@ async handleWebhook(
339
343
 
340
344
  Convert the raw platform message into a normalized `Message` instance. The `author` fields use `userId` and `userName`, and `isBot` accepts `boolean | "unknown"`. Include a `metadata` object with `dateSent` and `edited` instead of a top-level `createdAt`.
341
345
 
346
+ Set `author.isMe` only when the message was sent by this adapter runtime and should be ignored by Chat SDK's handler dispatch. Do not map a platform "sent from my account" flag directly to `isMe` unless that account is the bot identity. For user-owned account adapters, keep user-authored messages as `isMe: false` and track message IDs returned by `postMessage`; if the platform echoes one of those IDs through the webhook, mark that echo as `isMe: true` and `isBot: true`.
347
+
342
348
  ```typescript title="src/adapter.ts" lineNumbers
343
349
  parseMessage(raw: unknown): Message<unknown> {
344
350
  const payload = raw as Record<string, unknown>;
@@ -3,7 +3,7 @@ title: Conversation History
3
3
  description: Persist messages per user across every platform — for LLM context, audit, or compliance.
4
4
  type: guide
5
5
  prerequisites:
6
- - /docs/state
6
+ - /docs/state-adapters
7
7
  related:
8
8
  - /docs/handling-events
9
9
  - /docs/api/transcripts
@@ -0,0 +1,143 @@
1
+ ---
2
+ title: CLI
3
+ description: Scaffold a Chat SDK bot app with a single command.
4
+ ---
5
+
6
+ `create-chat-sdk` creates a minimal Next.js app for Chat SDK bots.
7
+
8
+ The CLI will generate your `Chat` configuration, webhook route, `.env.example` file, dependencies, and optional Web adapter route from the adapter catalog.
9
+
10
+ ## Quick start
11
+
12
+ <CodeBlockTabs defaultValue="npm">
13
+ <CodeBlockTabsList>
14
+ <CodeBlockTabsTrigger value="npm">npm</CodeBlockTabsTrigger>
15
+ <CodeBlockTabsTrigger value="pnpm">pnpm</CodeBlockTabsTrigger>
16
+ <CodeBlockTabsTrigger value="yarn">yarn</CodeBlockTabsTrigger>
17
+ <CodeBlockTabsTrigger value="bun">bun</CodeBlockTabsTrigger>
18
+ </CodeBlockTabsList>
19
+ <CodeBlockTab value="npm">
20
+ ```bash
21
+ npm create chat-sdk@latest my-bot
22
+ ```
23
+ </CodeBlockTab>
24
+ <CodeBlockTab value="pnpm">
25
+ ```bash
26
+ pnpm create chat-sdk@latest my-bot
27
+ ```
28
+ </CodeBlockTab>
29
+ <CodeBlockTab value="yarn">
30
+ ```bash
31
+ yarn create chat-sdk my-bot
32
+ ```
33
+ </CodeBlockTab>
34
+ <CodeBlockTab value="bun">
35
+ ```bash
36
+ bunx create-chat-sdk@latest my-bot
37
+ ```
38
+ </CodeBlockTab>
39
+ </CodeBlockTabs>
40
+
41
+ <Callout type="info">
42
+ `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.
43
+ </Callout>
44
+
45
+ ## Non-interactive usage
46
+
47
+ Pass platform and state adapters with `--adapter`:
48
+
49
+ ```bash
50
+ npm create chat-sdk@latest -- my-bot --adapter slack redis -y
51
+ ```
52
+
53
+ <Callout type="warn">
54
+ 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.
55
+ </Callout>
56
+
57
+ 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`.
58
+
59
+ 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.
60
+
61
+ <AdapterSlugList />
62
+
63
+ Examples:
64
+
65
+ ```bash
66
+ npm create chat-sdk@latest -- slack-bot --adapter slack memory -y --skip-install
67
+ npm create chat-sdk@latest -- gchat-bot --adapter gchat redis -y --pm pnpm
68
+ npm create chat-sdk@latest -- email-bot --adapter resend postgres -y --no-git
69
+ npm create chat-sdk@latest -- my-bot --adapter slack memory -y --force
70
+ ```
71
+
72
+ ## What gets generated
73
+
74
+ The scaffolded app is webhook-only. It does not include pages, layouts, or a client UI.
75
+
76
+ ```txt
77
+ src/
78
+ lib/bot.ts Bot configuration and handlers
79
+ app/api/webhooks/[platform]/route.ts Dynamic platform webhook route
80
+ app/api/chat/route.ts Web adapter route, only when selected
81
+ app/api/discord/gateway/route.ts Discord Gateway listener, only when selected
82
+ .env.example Required environment variables
83
+ next.config.ts Next.js server config
84
+ vercel.json Cron schedules, only when needed
85
+ .chat-sdk.json Generated file ownership for safe reruns
86
+ package.json Adapter dependencies
87
+ ```
88
+
89
+ Webhook endpoints use the selected adapter slug:
90
+
91
+ ```txt
92
+ /api/webhooks/slack
93
+ /api/webhooks/gchat
94
+ /api/webhooks/discord
95
+ ```
96
+
97
+ When the [Web adapter](/adapters/official/web) 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.
98
+
99
+ When the [Discord adapter](/adapters/official/discord) 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](https://vercel.com/docs/cron-jobs/usage-and-pricing) because it runs every nine minutes.
100
+
101
+ ## Reference
102
+
103
+ | Option | Description |
104
+ | --- | --- |
105
+ | `[name]` | Name of the project. |
106
+ | `-d, --description <text>` | Project description. |
107
+ | `--adapter <values...>` | Platform or state adapters to include. |
108
+ | `--vendor` | List only vendor-official adapters in the interactive prompt. |
109
+ | `--pm <manager>` | Package manager to use: `npm`, `yarn`, `pnpm`, or `bun`. |
110
+ | `-y, --yes` | Skip prompts and accept defaults. |
111
+ | `--interactive` | Always prompt, even when a coding agent environment is detected. |
112
+ | `-f, --force` | Overwrite generated files in an existing directory. |
113
+ | `-s, --skip-install` | Skip dependency installation. |
114
+ | `--no-git` | Skip git repository initialization. |
115
+ | `-q, --quiet` | Suppress non-essential output. |
116
+
117
+ Color output follows the [NO_COLOR standard](https://no-color.org/) — set `NO_COLOR=1` to disable colors.
118
+
119
+ ## Customize your bot
120
+
121
+ Most bot behavior lives in `src/lib/bot.ts`. Start there when you want to:
122
+
123
+ - Add or change handlers like `onNewMention`, `onSubscribedMessage`, `onNewMessage`, reactions, actions, or slash commands.
124
+ - Adjust adapter configuration, for example passing explicit credentials or platform-specific options instead of relying only on environment variables.
125
+ - If you selected the memory state adapter, switch to Redis, ioredis, or PostgreSQL before deploying to production.
126
+
127
+ The generated file includes starter handlers for mentions and subscribed thread replies.
128
+
129
+ ## Next steps
130
+
131
+ After scaffolding:
132
+
133
+ ```bash
134
+ cd my-bot
135
+ cp .env.example .env.local
136
+ npm run dev
137
+ ```
138
+
139
+ Fill in the generated environment variables, expose your local server, and configure each selected platform to call its `/api/webhooks/{adapter}` endpoint.
140
+
141
+ ## Resources
142
+
143
+ See guides, templates, and examples on the [resources](/resources) page.
@@ -105,7 +105,7 @@ try {
105
105
  }}
106
106
  />
107
107
 
108
- See the [feature matrix](/docs/adapters) for which features are supported on each platform.
108
+ See the [feature matrix](/docs/platform-adapters) for which features are supported on each platform.
109
109
 
110
110
  ### LockError
111
111
 
@@ -19,10 +19,14 @@ Learn the core patterns for handling incoming events and posting messages back t
19
19
  Connect your bot to chat platforms and persist state across restarts.
20
20
 
21
21
  <Cards>
22
- <Card title="Platform Adapters" description="Platform-specific adapters for Slack, Teams, Google Chat, Discord, Telegram, GitHub, and Linear." href="/docs/adapters" />
23
- <Card title="State Adapters" description="Pluggable state adapters for thread subscriptions, distributed locking, and caching." href="/docs/state" />
22
+ <Card title="Platform Adapters" description="Platform-specific adapters for Slack, Teams, Google Chat, Discord, Telegram, GitHub, and Linear." href="/docs/platform-adapters" />
23
+ <Card title="State Adapters" description="Pluggable state adapters for thread subscriptions, distributed locking, and caching." href="/docs/state-adapters" />
24
24
  </Cards>
25
25
 
26
26
  Browse all official and community adapters on the [Adapters](/adapters) page.
27
27
 
28
- Step-by-step guides and starter templates are available on the [Resources](/resources) page.
28
+ ## Resources
29
+
30
+ - [The Complete Guide to Chat SDK](https://vercel.com/kb/guide/the-complete-guide-to-chat-sdk?utm_source=chat-sdk_site&utm_medium=docs&utm_campaign=getting-started&utm_content=the-complete-guide-to-chat-sdk) — End-to-end walkthrough that takes you from zero to a deployed multi-platform bot, covering adapters, state, handlers, cards, and streaming.
31
+
32
+ See all guides and templates on the [resources](/resources?utm_source=chat-sdk_site&utm_medium=docs&utm_campaign=getting-started&utm_content=resources) page.
package/docs/index.mdx CHANGED
@@ -55,10 +55,11 @@ Each adapter factory auto-detects credentials from environment variables (`SLACK
55
55
  | Microsoft Teams | `@chat-adapter/teams` | Yes | Read-only | Yes | Yes | Native (DMs) / Buffered | Yes |
56
56
  | Google Chat | `@chat-adapter/gchat` | Yes | Yes | Yes | No | Post+Edit | Yes |
57
57
  | Discord | `@chat-adapter/discord` | Yes | Yes | Yes | No | Post+Edit | Yes |
58
- | Telegram | `@chat-adapter/telegram` | Yes | Yes | Partial | No | Post+Edit | Yes |
58
+ | Telegram | `@chat-adapter/telegram` | Yes | Yes | Partial | No | Rich drafts / Post+Edit | Yes |
59
59
  | GitHub | `@chat-adapter/github` | Yes | Yes | No | No | Buffered | No |
60
60
  | Linear | `@chat-adapter/linear` | Yes | Yes | No | No | Agent sessions / Post+Edit | No |
61
61
  | WhatsApp | `@chat-adapter/whatsapp` | N/A | Yes | Partial | No | Buffered | Yes |
62
+ | Twilio | `@chat-adapter/twilio` | N/A | No | Fallback | No | Buffered | Yes |
62
63
  | Messenger | `@chat-adapter/messenger` | Yes | Receive-only | Partial | No | Buffered | Yes |
63
64
 
64
65
  ## AI coding agent support
@@ -87,6 +88,7 @@ The SDK is distributed as a set of packages you install based on your needs:
87
88
  | `@chat-adapter/github` | GitHub Issues adapter |
88
89
  | `@chat-adapter/linear` | Linear Issues adapter |
89
90
  | `@chat-adapter/whatsapp` | WhatsApp Business adapter |
91
+ | `@chat-adapter/twilio` | Twilio SMS and MMS adapter |
90
92
  | `@chat-adapter/messenger` | Facebook Messenger adapter |
91
93
  | `@chat-adapter/state-redis` | Redis state adapter (production) |
92
94
  | `@chat-adapter/state-ioredis` | ioredis state adapter (alternative) |
package/docs/meta.json CHANGED
@@ -3,6 +3,7 @@
3
3
  "pages": [
4
4
  "index",
5
5
  "getting-started",
6
+ "create-chat-sdk",
6
7
  "---Usage---",
7
8
  "usage",
8
9
  "threads-messages-channels",
@@ -14,7 +15,10 @@
14
15
  "...ai",
15
16
  "---Adapters---",
16
17
  "adapters",
17
- "state",
18
+ "platform-adapters",
19
+ "slack-primitives",
20
+ "teams-primitives",
21
+ "state-adapters",
18
22
  "---Messaging---",
19
23
  "streaming",
20
24
  "direct-messages",
@@ -0,0 +1,148 @@
1
+ ---
2
+ title: Platform Adapters
3
+ description: Platform-specific adapters that connect your bot to any messaging platform.
4
+ type: overview
5
+ prerequisites:
6
+ - /docs/getting-started
7
+ - /docs/adapters
8
+ ---
9
+
10
+ Platform adapters handle webhook verification, message parsing, and API calls for each messaging platform. Install only the adapters you need. Browse all available adapters, including community-built ones, on the [Adapters](/adapters) page.
11
+
12
+ Need a browser chat UI? See the [Web adapter](/adapters/official/web). It speaks the AI SDK UI stream protocol and works with React (`@ai-sdk/react`), Vue (`@ai-sdk/vue`), and Svelte (`@ai-sdk/svelte`), so the same bot serves Slack, Teams, and any browser framework out of the box.
13
+
14
+ Ready to build your own? Follow the [building](/docs/contributing/building) guide.
15
+
16
+ ## Feature matrix
17
+
18
+ <GlobalFeatureMatrix type="platform" />
19
+
20
+ ### Messaging
21
+
22
+ | Feature | [Slack](/adapters/slack) | [Teams](/adapters/teams) | [Google Chat](/adapters/gchat) | [Discord](/adapters/discord) | [Telegram](/adapters/telegram) | [GitHub](/adapters/github) | [Linear](/adapters/linear) | [WhatsApp](/adapters/whatsapp) | [Messenger](/adapters/messenger) |
23
+ |---------|-------|-------|-------------|---------|---------|--------|--------|-----------|-----------|
24
+ | Post message | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
25
+ | Edit message | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Warn /> Partial | <Cross /> | <Cross /> |
26
+ | Delete message | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Warn /> Partial | <Cross /> | <Cross /> |
27
+ | File uploads | <Check /> | <Check /> | <Cross /> | <Check /> | <Warn /> Single file/media | <Cross /> | <Cross /> | <Check /> Images, audio, docs | <Cross /> |
28
+ | Streaming | <Check /> Native | <Warn /> Native (DMs) / Buffered | <Warn /> Post+Edit | <Warn /> Post+Edit | <Warn /> Rich drafts / Post+Edit | <Warn /> Buffered | <Warn /> Agent sessions / Post+Edit | <Warn /> Buffered | <Warn /> Buffered |
29
+ | Scheduled messages | <Check /> Native | <Cross /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> |
30
+
31
+ ### Rich content
32
+
33
+ | Feature | Slack | Teams | Google Chat | Discord | Telegram | GitHub | Linear | WhatsApp | Messenger |
34
+ |---------|-------|-------|-------------|---------|----------|--------|--------|-----------|-----------|
35
+ | Card format | Block Kit | Adaptive Cards | Google Chat Cards | Embeds | Markdown + inline keyboard buttons | GFM Markdown | Markdown | WhatsApp templates | Generic/Button Templates |
36
+ | Buttons | <Check /> | <Check /> | <Check /> | <Check /> | <Warn /> Inline keyboard callbacks | <Cross /> | <Cross /> | <Check /> Interactive replies | <Warn /> Max 3, postback |
37
+ | Link buttons | <Check /> | <Check /> | <Check /> | <Check /> | <Warn /> Inline keyboard URLs | <Cross /> | <Cross /> | <Cross /> | <Check /> |
38
+ | Select menus | <Check /> | <Cross /> | <Check /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> |
39
+ | Tables | <Check /> Block Kit | <Check /> GFM | <Warn /> ASCII | <Check /> GFM | <Warn /> Native messages / ASCII cards | <Check /> GFM | <Check /> GFM | <Cross /> | <Warn /> ASCII |
40
+ | Fields | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Warn /> Template variables | <Warn /> ASCII |
41
+ | Images in cards | <Check /> | <Check /> | <Check /> | <Check /> | <Cross /> | <Check /> | <Cross /> | <Check /> | <Check /> |
42
+ | Modals | <Check /> | <Check /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> |
43
+
44
+ ### Conversations
45
+
46
+ | Feature | Slack | Teams | Google Chat | Discord | Telegram | GitHub | Linear | WhatsApp | Messenger |
47
+ |---------|-------|-------|-------------|---------|----------|--------|--------|-----------|-----------|
48
+ | Slash commands | <Check /> | <Cross /> | <Cross /> | <Check /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> |
49
+ | Mentions | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Cross /> | <Check /> |
50
+ | Add reactions | <Check /> | <Cross /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Cross /> |
51
+ | Remove reactions | <Check /> | <Cross /> | <Check /> | <Check /> | <Check /> | <Warn /> | <Warn /> | <Check /> | <Cross /> |
52
+ | Typing indicator | <Check /> | <Check /> | <Cross /> | <Check /> | <Check /> | <Cross /> | <Warn /> Agent sessions | <Warn /> | <Check /> |
53
+ | DMs | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Cross /> | <Cross /> | <Check /> | <Check /> |
54
+ | Ephemeral messages | <Check /> Native | <Cross /> | <Check /> Native | <Cross /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> |
55
+ | User lookup ([`getUser`](/docs/api/chat#getuser)) | <Check /> | <Warn /> Cached | <Warn /> Cached | <Check /> | <Warn /> Seen users | <Check /> | <Check /> | <Cross /> | <Cross /> |
56
+ | Parent subject ([`message.subject`](/docs/subject)) | <Cross /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> | <Check /> | <Check /> | <Cross /> | <Cross /> |
57
+ | Native client ([`.webClient` / `.octokit` / `.linearClient`](/docs/api/chat#getadapter)) | <Check /> | <Cross /> | <Cross /> | <Cross /> | <Cross /> | <Check /> | <Check /> | <Cross /> | <Cross /> |
58
+ | Custom API endpoint (`apiUrl`) | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
59
+
60
+ ### Message history
61
+
62
+ | Feature | Slack | Teams | Google Chat | Discord | Telegram | GitHub | Linear | WhatsApp | Messenger |
63
+ |---------|-------|-------|-------------|---------|----------|--------|--------|-----------|-----------|
64
+ | Fetch messages | <Check /> | <Check /> | <Check /> | <Check /> | <Warn /> Cached | <Check /> | <Check /> | <Warn /> Cached sent messages only | <Warn /> Cached sent messages only |
65
+ | Fetch single message | <Check /> | <Cross /> | <Cross /> | <Cross /> | <Warn /> Cached | <Cross /> | <Cross /> | <Cross /> | <Warn /> Cached |
66
+ | Fetch thread info | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> |
67
+ | Fetch channel messages | <Check /> | <Check /> | <Check /> | <Check /> | <Warn /> Cached | <Check /> | <Cross /> | <Cross /> | <Warn /> Cached |
68
+ | List threads | <Check /> | <Check /> | <Check /> | <Check /> | <Cross /> | <Check /> | <Cross /> | <Cross /> | <Cross /> |
69
+ | Fetch channel info | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Cross /> | <Cross /> | <Check /> |
70
+ | Post channel message | <Check /> | <Check /> | <Check /> | <Check /> | <Check /> | <Cross /> | <Cross /> | <Check /> | <Check /> |
71
+
72
+ <Callout type="info">
73
+ <Warn /> indicates partial support. The feature works with limitations. See individual adapter pages for details.
74
+ </Callout>
75
+
76
+ ## How adapters work
77
+
78
+ Each adapter implements a standard interface that the `Chat` class uses to route events and send messages. When a webhook arrives:
79
+
80
+ 1. The adapter verifies the request signature
81
+ 2. Parses the platform-specific payload into a normalized `Message`
82
+ 3. Routes to your handlers via the `Chat` class
83
+ 4. Converts outgoing messages from markdown/AST/cards to the platform's native format
84
+
85
+ ## Using multiple adapters
86
+
87
+ Register multiple [adapters](/adapters) and your event handlers work across all of them:
88
+
89
+ ```typescript title="lib/bot.ts" lineNumbers
90
+ import { Chat } from "chat";
91
+ import { createSlackAdapter } from "@chat-adapter/slack";
92
+ import { createTeamsAdapter } from "@chat-adapter/teams";
93
+ import { createGoogleChatAdapter } from "@chat-adapter/gchat";
94
+ import { createRedisState } from "@chat-adapter/state-redis";
95
+
96
+ const bot = new Chat({
97
+ userName: "mybot",
98
+ adapters: {
99
+ slack: createSlackAdapter(),
100
+ teams: createTeamsAdapter(),
101
+ gchat: createGoogleChatAdapter(),
102
+ },
103
+ state: createRedisState(),
104
+ });
105
+
106
+ // This handler fires for mentions on any platform
107
+ bot.onNewMention(async (thread) => {
108
+ await thread.subscribe();
109
+ await thread.post("Hello!");
110
+ });
111
+ ```
112
+
113
+ Each adapter auto-detects credentials from environment variables, so you only need to pass config when overriding defaults.
114
+
115
+ <Callout type="info">
116
+ The examples above use Redis for state. See [State Adapters](/docs/state-adapters) for all available options.
117
+ </Callout>
118
+
119
+ Each adapter creates a webhook handler accessible via `bot.webhooks.<name>`.
120
+
121
+ ## Customizing an adapter via subclassing
122
+
123
+ Each official adapter exposes its extension surface as `protected` members so you can subclass it to override or extend platform-specific behavior without forking the package. Use this when you need to handle a payload type the built-in adapter doesn't cover, intercept verification, or wrap an existing handler.
124
+
125
+ ```typescript title="lib/custom-telegram.ts" lineNumbers
126
+ import { TelegramAdapter, type TelegramUpdate } from "@chat-adapter/telegram";
127
+ import type { WebhookOptions } from "chat";
128
+
129
+ export class CustomTelegramAdapter extends TelegramAdapter {
130
+ protected override processUpdate(
131
+ update: TelegramUpdate,
132
+ options?: WebhookOptions
133
+ ): void {
134
+ // Handle a payload type the base adapter doesn't, e.g. chat_join_request.
135
+ if ("chat_join_request" in update) {
136
+ this.logger.info("Received chat_join_request", { update });
137
+ return;
138
+ }
139
+ super.processUpdate(update, options);
140
+ }
141
+ }
142
+ ```
143
+
144
+ Construct your subclass anywhere you'd construct the base adapter, for example, `adapters: { telegram: new CustomTelegramAdapter({ ... }) }`. Members marked `private` intentionally remain inaccessible. If you find a hook you need that isn't `protected`, please open an issue.
145
+
146
+ <Callout type="warn">
147
+ The `protected` extension surface is intentionally broader than the public API but is not yet considered fully stable. Method signatures may evolve in minor releases as we learn from real-world subclasses. Pin the adapter version you build against, watch the changelog for the affected adapter, and prefer overriding the smallest hook that solves your problem so upgrades stay easy. If you rely on a particular hook, please open an issue so we can promote it to a stable, documented extension point.
148
+ </Callout>