chat 4.13.2 → 4.13.4

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.
@@ -14,6 +14,8 @@ pnpm add @chat-adapter/discord
14
14
 
15
15
  ## Usage
16
16
 
17
+ The adapter auto-detects `DISCORD_BOT_TOKEN`, `DISCORD_PUBLIC_KEY`, `DISCORD_APPLICATION_ID`, and `DISCORD_MENTION_ROLE_IDS` from environment variables:
18
+
17
19
  ```typescript title="lib/bot.ts" lineNumbers
18
20
  import { Chat } from "chat";
19
21
  import { createDiscordAdapter } from "@chat-adapter/discord";
@@ -21,12 +23,7 @@ import { createDiscordAdapter } from "@chat-adapter/discord";
21
23
  const bot = new Chat({
22
24
  userName: "mybot",
23
25
  adapters: {
24
- discord: createDiscordAdapter({
25
- botToken: process.env.DISCORD_BOT_TOKEN!,
26
- publicKey: process.env.DISCORD_PUBLIC_KEY!,
27
- applicationId: process.env.DISCORD_APPLICATION_ID!,
28
- mentionRoleIds: process.env.DISCORD_MENTION_ROLE_IDS?.split(","),
29
- }),
26
+ discord: createDiscordAdapter(),
30
27
  },
31
28
  });
32
29
 
@@ -143,23 +140,25 @@ By default, only direct user mentions (`@BotName`) trigger `onNewMention` handle
143
140
 
144
141
  ```typescript title="lib/bot.ts" lineNumbers
145
142
  createDiscordAdapter({
146
- botToken: process.env.DISCORD_BOT_TOKEN!,
147
- publicKey: process.env.DISCORD_PUBLIC_KEY!,
148
- applicationId: process.env.DISCORD_APPLICATION_ID!,
149
143
  mentionRoleIds: ["1457473602180878604"],
150
144
  });
151
145
  ```
152
146
 
153
- Or set `DISCORD_MENTION_ROLE_IDS` as a comma-separated string.
147
+ Or set `DISCORD_MENTION_ROLE_IDS` as a comma-separated string in your environment variables.
154
148
 
155
149
  ## Configuration
156
150
 
151
+ All options are auto-detected from environment variables when not provided.
152
+
157
153
  | Option | Required | Description |
158
154
  |--------|----------|-------------|
159
- | `botToken` | Yes | Discord bot token |
160
- | `publicKey` | Yes | Application public key (for webhook signature verification) |
161
- | `applicationId` | Yes | Discord application ID |
162
- | `mentionRoleIds` | No | Array of role IDs that trigger mention handlers |
155
+ | `botToken` | No* | Discord bot token. Auto-detected from `DISCORD_BOT_TOKEN` |
156
+ | `publicKey` | No* | Application public key. Auto-detected from `DISCORD_PUBLIC_KEY` |
157
+ | `applicationId` | No* | Discord application ID. Auto-detected from `DISCORD_APPLICATION_ID` |
158
+ | `mentionRoleIds` | No | Array of role IDs that trigger mention handlers. Auto-detected from `DISCORD_MENTION_ROLE_IDS` (comma-separated) |
159
+ | `logger` | No | Logger instance (defaults to `ConsoleLogger("info")`) |
160
+
161
+ *`botToken`, `publicKey`, and `applicationId` are required — either via config or env vars.
163
162
 
164
163
  ## Environment variables
165
164
 
@@ -14,6 +14,8 @@ pnpm add @chat-adapter/gchat
14
14
 
15
15
  ## Usage
16
16
 
17
+ The adapter auto-detects credentials from `GOOGLE_CHAT_CREDENTIALS` or `GOOGLE_CHAT_USE_ADC` environment variables:
18
+
17
19
  ```typescript title="lib/bot.ts" lineNumbers
18
20
  import { Chat } from "chat";
19
21
  import { createGoogleChatAdapter } from "@chat-adapter/gchat";
@@ -21,9 +23,7 @@ import { createGoogleChatAdapter } from "@chat-adapter/gchat";
21
23
  const bot = new Chat({
22
24
  userName: "mybot",
23
25
  adapters: {
24
- gchat: createGoogleChatAdapter({
25
- credentials: JSON.parse(process.env.GOOGLE_CHAT_CREDENTIALS!),
26
- }),
26
+ gchat: createGoogleChatAdapter(),
27
27
  },
28
28
  });
29
29
 
@@ -94,12 +94,13 @@ By default, Google Chat only sends webhooks for @mentions. To receive all messag
94
94
 
95
95
  ```typescript title="lib/bot.ts" lineNumbers
96
96
  createGoogleChatAdapter({
97
- credentials: JSON.parse(process.env.GOOGLE_CHAT_CREDENTIALS!),
98
97
  pubsubTopic: process.env.GOOGLE_CHAT_PUBSUB_TOPIC,
99
98
  impersonateUser: process.env.GOOGLE_CHAT_IMPERSONATE_USER,
100
99
  });
101
100
  ```
102
101
 
102
+ `GOOGLE_CHAT_PUBSUB_TOPIC` and `GOOGLE_CHAT_IMPERSONATE_USER` are also auto-detected from env vars, so you can omit them from config if the env vars are set.
103
+
103
104
  ### 1. Create Pub/Sub topic
104
105
 
105
106
  1. Go to **Pub/Sub** then **Topics**
@@ -156,14 +157,18 @@ Set `GOOGLE_CHAT_IMPERSONATE_USER` to an admin user email in your domain (e.g.,
156
157
 
157
158
  ## Configuration
158
159
 
160
+ All options are auto-detected from environment variables when not provided.
161
+
159
162
  | Option | Required | Description |
160
163
  |--------|----------|-------------|
161
- | `credentials` | Yes* | Service account credentials JSON |
162
- | `useADC` | No | Use Application Default Credentials instead |
163
- | `pubsubTopic` | No | Pub/Sub topic for Workspace Events |
164
- | `impersonateUser` | No | User email for domain-wide delegation |
165
-
166
- *Either `credentials` or `useADC: true` is required.
164
+ | `credentials` | No* | Service account credentials JSON. Auto-detected from `GOOGLE_CHAT_CREDENTIALS` |
165
+ | `useApplicationDefaultCredentials` | No | Use Application Default Credentials. Auto-detected from `GOOGLE_CHAT_USE_ADC` |
166
+ | `pubsubTopic` | No | Pub/Sub topic for Workspace Events. Auto-detected from `GOOGLE_CHAT_PUBSUB_TOPIC` |
167
+ | `impersonateUser` | No | User email for domain-wide delegation. Auto-detected from `GOOGLE_CHAT_IMPERSONATE_USER` |
168
+ | `auth` | No | Custom auth object (advanced) |
169
+ | `logger` | No | Logger instance (defaults to `ConsoleLogger("info")`) |
170
+
171
+ *Either `credentials`, `GOOGLE_CHAT_CREDENTIALS` env var, `useApplicationDefaultCredentials`, or `GOOGLE_CHAT_USE_ADC=true` is required.
167
172
 
168
173
  ## Environment variables
169
174
 
@@ -16,6 +16,8 @@ pnpm add @chat-adapter/github
16
16
 
17
17
  ## Usage
18
18
 
19
+ The adapter auto-detects credentials from `GITHUB_TOKEN` (or `GITHUB_APP_ID`/`GITHUB_PRIVATE_KEY`), `GITHUB_WEBHOOK_SECRET`, and `GITHUB_BOT_USERNAME` environment variables:
20
+
19
21
  ```typescript title="lib/bot.ts" lineNumbers
20
22
  import { Chat } from "chat";
21
23
  import { createGitHubAdapter } from "@chat-adapter/github";
@@ -23,11 +25,7 @@ import { createGitHubAdapter } from "@chat-adapter/github";
23
25
  const bot = new Chat({
24
26
  userName: "my-bot",
25
27
  adapters: {
26
- github: createGitHubAdapter({
27
- token: process.env.GITHUB_TOKEN!,
28
- webhookSecret: process.env.GITHUB_WEBHOOK_SECRET!,
29
- userName: "my-bot",
30
- }),
28
+ github: createGitHubAdapter(),
31
29
  },
32
30
  });
33
31
 
@@ -49,8 +47,6 @@ Best for personal projects, testing, or single-repo bots.
49
47
  ```typescript title="lib/bot.ts" lineNumbers
50
48
  createGitHubAdapter({
51
49
  token: process.env.GITHUB_TOKEN!,
52
- webhookSecret: process.env.GITHUB_WEBHOOK_SECRET!,
53
- userName: "my-bot",
54
50
  });
55
51
  ```
56
52
 
@@ -88,8 +84,6 @@ createGitHubAdapter({
88
84
  appId: process.env.GITHUB_APP_ID!,
89
85
  privateKey: process.env.GITHUB_PRIVATE_KEY!,
90
86
  installationId: parseInt(process.env.GITHUB_INSTALLATION_ID!),
91
- webhookSecret: process.env.GITHUB_WEBHOOK_SECRET!,
92
- userName: "my-bot[bot]",
93
87
  });
94
88
  ```
95
89
 
@@ -99,8 +93,6 @@ createGitHubAdapter({
99
93
  createGitHubAdapter({
100
94
  appId: process.env.GITHUB_APP_ID!,
101
95
  privateKey: process.env.GITHUB_PRIVATE_KEY!,
102
- webhookSecret: process.env.GITHUB_WEBHOOK_SECRET!,
103
- userName: "my-bot[bot]",
104
96
  });
105
97
  ```
106
98
 
@@ -146,17 +138,22 @@ Supports GitHub's reaction emoji:
146
138
 
147
139
  ## Configuration
148
140
 
141
+ All options are auto-detected from environment variables when not provided.
142
+
149
143
  | Option | Required | Description |
150
144
  |--------|----------|-------------|
151
- | `token` | Yes* | Personal Access Token with `repo` scope |
152
- | `appId` | Yes* | GitHub App ID |
153
- | `privateKey` | For Apps | GitHub App private key (PEM format) |
154
- | `installationId` | No | Installation ID (omit for multi-tenant) |
155
- | `webhookSecret` | Yes | Webhook secret for signature verification |
156
- | `userName` | Yes | Bot username for @mention detection |
145
+ | `token` | No* | Personal Access Token. Auto-detected from `GITHUB_TOKEN` |
146
+ | `appId` | No* | GitHub App ID. Auto-detected from `GITHUB_APP_ID` |
147
+ | `privateKey` | No | GitHub App private key (PEM). Auto-detected from `GITHUB_PRIVATE_KEY` |
148
+ | `installationId` | No | Installation ID (omit for multi-tenant). Auto-detected from `GITHUB_INSTALLATION_ID` |
149
+ | `webhookSecret` | No** | Webhook secret. Auto-detected from `GITHUB_WEBHOOK_SECRET` |
150
+ | `userName` | No | Bot username for @mention detection. Auto-detected from `GITHUB_BOT_USERNAME` (default: `"github-bot"`) |
157
151
  | `botUserId` | No | Bot's numeric user ID (auto-detected if not provided) |
152
+ | `logger` | No | Logger instance (defaults to `ConsoleLogger("info")`) |
153
+
154
+ *Either `token`/`GITHUB_TOKEN` or `appId`+`privateKey`/`GITHUB_APP_ID`+`GITHUB_PRIVATE_KEY` is required.
158
155
 
159
- *Either `token` or `appId`/`privateKey` is required.
156
+ **`webhookSecret` is required — either via config or `GITHUB_WEBHOOK_SECRET` env var.
160
157
 
161
158
  ## Environment variables
162
159
 
@@ -93,11 +93,11 @@ import { createRedisState } from "@chat-adapter/state-redis";
93
93
  const bot = new Chat({
94
94
  userName: "mybot",
95
95
  adapters: {
96
- slack: createSlackAdapter({ /* ... */ }),
97
- teams: createTeamsAdapter({ /* ... */ }),
98
- gchat: createGoogleChatAdapter({ /* ... */ }),
96
+ slack: createSlackAdapter(),
97
+ teams: createTeamsAdapter(),
98
+ gchat: createGoogleChatAdapter(),
99
99
  },
100
- state: createRedisState({ url: process.env.REDIS_URL! }),
100
+ state: createRedisState(),
101
101
  });
102
102
 
103
103
  // This handler fires for mentions on any platform
@@ -107,4 +107,6 @@ bot.onNewMention(async (thread) => {
107
107
  });
108
108
  ```
109
109
 
110
+ Each adapter auto-detects credentials from environment variables, so you only need to pass config when overriding defaults.
111
+
110
112
  Each adapter creates a webhook handler accessible via `bot.webhooks.slack`, `bot.webhooks.teams`, etc.
@@ -16,6 +16,8 @@ pnpm add @chat-adapter/linear
16
16
 
17
17
  ## Usage
18
18
 
19
+ The adapter auto-detects credentials from `LINEAR_API_KEY` (or `LINEAR_CLIENT_ID`/`LINEAR_CLIENT_SECRET`), `LINEAR_WEBHOOK_SECRET`, and `LINEAR_BOT_USERNAME` environment variables:
20
+
19
21
  ```typescript title="lib/bot.ts" lineNumbers
20
22
  import { Chat } from "chat";
21
23
  import { createLinearAdapter } from "@chat-adapter/linear";
@@ -23,11 +25,7 @@ import { createLinearAdapter } from "@chat-adapter/linear";
23
25
  const bot = new Chat({
24
26
  userName: "my-bot",
25
27
  adapters: {
26
- linear: createLinearAdapter({
27
- apiKey: process.env.LINEAR_API_KEY!,
28
- webhookSecret: process.env.LINEAR_WEBHOOK_SECRET!,
29
- userName: "my-bot",
30
- }),
28
+ linear: createLinearAdapter(),
31
29
  },
32
30
  });
33
31
 
@@ -51,8 +49,6 @@ Best for personal projects, testing, or single-workspace bots. Actions are attri
51
49
  ```typescript title="lib/bot.ts" lineNumbers
52
50
  createLinearAdapter({
53
51
  apiKey: process.env.LINEAR_API_KEY!,
54
- webhookSecret: process.env.LINEAR_WEBHOOK_SECRET!,
55
- userName: "my-bot",
56
52
  });
57
53
  ```
58
54
 
@@ -69,8 +65,6 @@ The bot gets its own identity in Linear. The adapter handles token management in
69
65
  createLinearAdapter({
70
66
  clientId: process.env.LINEAR_CLIENT_ID!,
71
67
  clientSecret: process.env.LINEAR_CLIENT_SECRET!,
72
- webhookSecret: process.env.LINEAR_WEBHOOK_SECRET!,
73
- userName: "my-bot",
74
68
  });
75
69
  ```
76
70
 
@@ -138,16 +132,21 @@ When a user writes a comment, the bot replies within the same comment thread.
138
132
 
139
133
  ## Configuration
140
134
 
135
+ All options are auto-detected from environment variables when not provided.
136
+
141
137
  | Option | Required | Description |
142
138
  |--------|----------|-------------|
143
- | `apiKey` | Yes* | Personal API key |
144
- | `clientId` | Yes* | OAuth app client ID |
145
- | `clientSecret` | Yes* | OAuth app client secret |
146
- | `accessToken` | Yes* | Pre-obtained OAuth access token |
147
- | `webhookSecret` | Yes | Webhook signing secret for verification |
148
- | `userName` | Yes | Bot display name for @mention detection |
149
-
150
- *One of `apiKey`, `clientId`/`clientSecret`, or `accessToken` is required.
139
+ | `apiKey` | No* | Personal API key. Auto-detected from `LINEAR_API_KEY` |
140
+ | `clientId` | No* | OAuth app client ID. Auto-detected from `LINEAR_CLIENT_ID` |
141
+ | `clientSecret` | No* | OAuth app client secret. Auto-detected from `LINEAR_CLIENT_SECRET` |
142
+ | `accessToken` | No* | Pre-obtained OAuth access token. Auto-detected from `LINEAR_ACCESS_TOKEN` |
143
+ | `webhookSecret` | No** | Webhook signing secret. Auto-detected from `LINEAR_WEBHOOK_SECRET` |
144
+ | `userName` | No | Bot display name. Auto-detected from `LINEAR_BOT_USERNAME` (default: `"linear-bot"`) |
145
+ | `logger` | No | Logger instance (defaults to `ConsoleLogger("info")`) |
146
+
147
+ *One of `apiKey`, `clientId`/`clientSecret`, or `accessToken` is required (via config or env vars).
148
+
149
+ **`webhookSecret` is required — either via config or `LINEAR_WEBHOOK_SECRET` env var.
151
150
 
152
151
  ## Environment variables
153
152
 
@@ -14,7 +14,7 @@ pnpm add @chat-adapter/slack
14
14
 
15
15
  ## Single-workspace mode
16
16
 
17
- For bots deployed to a single Slack workspace:
17
+ For bots deployed to a single Slack workspace. The adapter auto-detects `SLACK_BOT_TOKEN` and `SLACK_SIGNING_SECRET` from environment variables:
18
18
 
19
19
  ```typescript title="lib/bot.ts" lineNumbers
20
20
  import { Chat } from "chat";
@@ -23,10 +23,7 @@ import { createSlackAdapter } from "@chat-adapter/slack";
23
23
  const bot = new Chat({
24
24
  userName: "mybot",
25
25
  adapters: {
26
- slack: createSlackAdapter({
27
- botToken: process.env.SLACK_BOT_TOKEN!,
28
- signingSecret: process.env.SLACK_SIGNING_SECRET!,
29
- }),
26
+ slack: createSlackAdapter(),
30
27
  },
31
28
  });
32
29
 
@@ -39,21 +36,21 @@ bot.onNewMention(async (thread, message) => {
39
36
 
40
37
  For apps installed across multiple Slack workspaces via OAuth, omit `botToken` and provide OAuth credentials instead. The adapter resolves tokens dynamically from your state adapter using the `team_id` from incoming webhooks.
41
38
 
39
+ When you pass any auth-related config (like `clientId`), the adapter won't fall back to env vars for other auth fields, preventing accidental mixing of auth modes.
40
+
42
41
  ```typescript title="lib/bot.ts" lineNumbers
43
42
  import { createSlackAdapter } from "@chat-adapter/slack";
44
43
  import { createRedisState } from "@chat-adapter/state-redis";
45
44
 
46
45
  const slackAdapter = createSlackAdapter({
47
- signingSecret: process.env.SLACK_SIGNING_SECRET!,
48
46
  clientId: process.env.SLACK_CLIENT_ID!,
49
47
  clientSecret: process.env.SLACK_CLIENT_SECRET!,
50
- encryptionKey: process.env.SLACK_ENCRYPTION_KEY,
51
48
  });
52
49
 
53
50
  const bot = new Chat({
54
51
  userName: "mybot",
55
52
  adapters: { slack: slackAdapter },
56
- state: createRedisState({ url: process.env.REDIS_URL! }),
53
+ state: createRedisState(),
57
54
  });
58
55
  ```
59
56
 
@@ -181,13 +178,18 @@ After creating the app, go to **Basic Information** → **App Credentials** and
181
178
 
182
179
  ## Configuration
183
180
 
181
+ All options are auto-detected from environment variables when not provided. You can call `createSlackAdapter()` with no arguments if the env vars are set.
182
+
184
183
  | Option | Required | Description |
185
184
  |--------|----------|-------------|
186
- | `botToken` | No | Bot token (`xoxb-...`). Required for single-workspace, omit for multi-workspace |
187
- | `signingSecret` | Yes | Signing secret for webhook verification |
188
- | `clientId` | No | App client ID (required for multi-workspace OAuth) |
189
- | `clientSecret` | No | App client secret (required for multi-workspace OAuth) |
190
- | `encryptionKey` | No | Base64-encoded 32-byte AES-256-GCM key for encrypting stored tokens |
185
+ | `botToken` | No | Bot token (`xoxb-...`). Auto-detected from `SLACK_BOT_TOKEN` |
186
+ | `signingSecret` | No* | Signing secret for webhook verification. Auto-detected from `SLACK_SIGNING_SECRET` |
187
+ | `clientId` | No | App client ID for multi-workspace OAuth. Auto-detected from `SLACK_CLIENT_ID` |
188
+ | `clientSecret` | No | App client secret for multi-workspace OAuth. Auto-detected from `SLACK_CLIENT_SECRET` |
189
+ | `encryptionKey` | No | AES-256-GCM key for encrypting stored tokens. Auto-detected from `SLACK_ENCRYPTION_KEY` |
190
+ | `logger` | No | Logger instance (defaults to `ConsoleLogger("info")`) |
191
+
192
+ *`signingSecret` is required — either via config or `SLACK_SIGNING_SECRET` env var.
191
193
 
192
194
  ## Environment variables
193
195
 
@@ -14,6 +14,8 @@ pnpm add @chat-adapter/teams
14
14
 
15
15
  ## Usage
16
16
 
17
+ The adapter auto-detects `TEAMS_APP_ID`, `TEAMS_APP_PASSWORD`, and `TEAMS_APP_TENANT_ID` from environment variables:
18
+
17
19
  ```typescript title="lib/bot.ts" lineNumbers
18
20
  import { Chat } from "chat";
19
21
  import { createTeamsAdapter } from "@chat-adapter/teams";
@@ -22,10 +24,7 @@ const bot = new Chat({
22
24
  userName: "mybot",
23
25
  adapters: {
24
26
  teams: createTeamsAdapter({
25
- appId: process.env.TEAMS_APP_ID!,
26
- appPassword: process.env.TEAMS_APP_PASSWORD!,
27
27
  appType: "SingleTenant",
28
- appTenantId: process.env.TEAMS_APP_TENANT_ID!,
29
28
  }),
30
29
  },
31
30
  });
@@ -136,12 +135,17 @@ Create icon files (32x32 `outline.png` and 192x192 `color.png`), then zip all th
136
135
 
137
136
  ## Configuration
138
137
 
138
+ All options are auto-detected from environment variables when not provided.
139
+
139
140
  | Option | Required | Description |
140
141
  |--------|----------|-------------|
141
- | `appId` | Yes | Azure Bot App ID |
142
- | `appPassword` | Yes | Azure Bot App Password |
142
+ | `appId` | No* | Azure Bot App ID. Auto-detected from `TEAMS_APP_ID` |
143
+ | `appPassword` | No* | Azure Bot App Password. Auto-detected from `TEAMS_APP_PASSWORD` |
143
144
  | `appType` | No | `"MultiTenant"` or `"SingleTenant"` (default: `"MultiTenant"`) |
144
- | `appTenantId` | For SingleTenant | Azure AD Tenant ID |
145
+ | `appTenantId` | For SingleTenant | Azure AD Tenant ID. Auto-detected from `TEAMS_APP_TENANT_ID` |
146
+ | `logger` | No | Logger instance (defaults to `ConsoleLogger("info")`) |
147
+
148
+ *`appId` and `appPassword` are required — either via config or env vars.
145
149
 
146
150
  ## Environment variables
147
151
 
package/docs/api/chat.mdx CHANGED
@@ -31,8 +31,9 @@ const bot = new Chat(config);
31
31
  type: 'StateAdapter',
32
32
  },
33
33
  logger: {
34
- description: 'Logger instance or log level.',
34
+ description: 'Logger instance or log level. Defaults to ConsoleLogger("info") if omitted.',
35
35
  type: 'Logger | "debug" | "info" | "warn" | "error" | "silent"',
36
+ default: 'ConsoleLogger("info")',
36
37
  },
37
38
  streamingUpdateIntervalMs: {
38
39
  description: 'Throttle interval for fallback streaming (post + edit) in milliseconds.',
@@ -160,6 +160,33 @@ Get a platform-specific @-mention string for a user.
160
160
  await thread.post(`Hey ${thread.mentionUser(userId)}, check this out!`);
161
161
  ```
162
162
 
163
+ ## Serialization
164
+
165
+ Threads can be serialized for workflow engines and external systems. The serialized thread includes the current message if one is available.
166
+
167
+ ```typescript
168
+ // Serialize
169
+ const json = thread.toJSON();
170
+
171
+ // Pass to a workflow
172
+ await workflow.start("my-workflow", {
173
+ thread: thread.toJSON(),
174
+ });
175
+ ```
176
+
177
+ The serialized format includes the thread ID, channel ID, adapter name, DM status, and the current message (if present).
178
+
179
+ ### Deserialization
180
+
181
+ Use `bot.reviver()` as a `JSON.parse` reviver to automatically restore `Thread` and `Message` objects from serialized payloads:
182
+
183
+ ```typescript
184
+ const data = JSON.parse(payload, bot.reviver());
185
+ await data.thread.post("Hello from workflow!");
186
+ ```
187
+
188
+ Under the hood, the reviver calls `ThreadImpl.fromJSON()` and `Message.fromJSON()` for any serialized objects it encounters.
189
+
163
190
  ## SentMessage
164
191
 
165
192
  Returned by `thread.post()`. Extends `Message` with mutation methods.
@@ -150,15 +150,9 @@ const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
150
150
  export const bot = new Chat({
151
151
  userName: process.env.BOT_USERNAME!,
152
152
  adapters: {
153
- github: createGitHubAdapter({
154
- token: process.env.GITHUB_TOKEN!,
155
- webhookSecret: process.env.GITHUB_WEBHOOK_SECRET!,
156
- userName: process.env.BOT_USERNAME!,
157
- }),
153
+ github: createGitHubAdapter(),
158
154
  },
159
- state: createRedisState({
160
- url: process.env.REDIS_URL!,
161
- }),
155
+ state: createRedisState(),
162
156
  });
163
157
 
164
158
  bot.onNewMention(async (thread, message) => {
@@ -69,29 +69,18 @@ ANTHROPIC_API_KEY=your_anthropic_api_key
69
69
  Create `server/lib/bot.ts` with a `Chat` instance configured with the Discord adapter. This bot uses AI SDK to answer support questions:
70
70
 
71
71
  ```typescript title="server/lib/bot.tsx" lineNumbers
72
- import { Chat, ConsoleLogger, Card, CardText as Text, Actions, Button, Divider } from "chat";
72
+ import { Chat, Card, CardText as Text, Actions, Button, Divider } from "chat";
73
73
  import { createDiscordAdapter } from "@chat-adapter/discord";
74
74
  import { createRedisState } from "@chat-adapter/state-redis";
75
75
  import { generateText } from "ai";
76
76
  import { anthropic } from "@ai-sdk/anthropic";
77
77
 
78
- const logger = new ConsoleLogger();
79
-
80
78
  export const bot = new Chat({
81
79
  userName: "support-bot",
82
80
  adapters: {
83
- discord: createDiscordAdapter({
84
- botToken: process.env.DISCORD_BOT_TOKEN!,
85
- publicKey: process.env.DISCORD_PUBLIC_KEY!,
86
- applicationId: process.env.DISCORD_APPLICATION_ID!,
87
- logger,
88
- }),
81
+ discord: createDiscordAdapter(),
89
82
  },
90
- state: createRedisState({
91
- url: process.env.REDIS_URL!,
92
- logger,
93
- }),
94
- logger,
83
+ state: createRedisState(),
95
84
  });
96
85
 
97
86
  bot.onNewMention(async (thread) => {
@@ -109,17 +109,9 @@ import { createRedisState } from "@chat-adapter/state-redis";
109
109
  export const bot = new Chat({
110
110
  userName: "mybot",
111
111
  adapters: {
112
- slack: createSlackAdapter({
113
- botToken: process.env.SLACK_BOT_TOKEN!,
114
- signingSecret: process.env.SLACK_SIGNING_SECRET!,
115
- logger: new ConsoleLogger(),
116
- }),
112
+ slack: createSlackAdapter(),
117
113
  },
118
- state: createRedisState({
119
- url: process.env.REDIS_URL!,
120
- logger: new ConsoleLogger(),
121
- }),
122
- logger: new ConsoleLogger(),
114
+ state: createRedisState(),
123
115
  });
124
116
 
125
117
  // Respond when someone @mentions the bot
@@ -134,6 +126,8 @@ bot.onSubscribedMessage(async (thread, message) => {
134
126
  });
135
127
  ```
136
128
 
129
+ The adapter auto-detects `SLACK_BOT_TOKEN` and `SLACK_SIGNING_SECRET` from your environment, and `createRedisState()` reads `REDIS_URL` automatically.
130
+
137
131
  `onNewMention` fires when a user @mentions your bot. Calling `thread.subscribe()` tells the SDK to track that thread, so subsequent messages trigger `onSubscribedMessage`.
138
132
 
139
133
  ## Create the webhook route
@@ -186,17 +180,9 @@ import { createRedisState } from "@chat-adapter/state-redis";
186
180
  export const bot = new Chat({
187
181
  userName: "mybot",
188
182
  adapters: {
189
- slack: createSlackAdapter({
190
- botToken: process.env.SLACK_BOT_TOKEN!,
191
- signingSecret: process.env.SLACK_SIGNING_SECRET!,
192
- logger: new ConsoleLogger(),
193
- }),
183
+ slack: createSlackAdapter(),
194
184
  },
195
- state: createRedisState({
196
- url: process.env.REDIS_URL!,
197
- logger: new ConsoleLogger(),
198
- }),
199
- logger: new ConsoleLogger(),
185
+ state: createRedisState(),
200
186
  });
201
187
 
202
188
  bot.onNewMention(async (thread) => {
package/docs/index.mdx CHANGED
@@ -34,17 +34,9 @@ import { createRedisState } from "@chat-adapter/state-redis";
34
34
  const bot = new Chat({
35
35
  userName: "mybot",
36
36
  adapters: {
37
- slack: createSlackAdapter({
38
- botToken: process.env.SLACK_BOT_TOKEN!,
39
- signingSecret: process.env.SLACK_SIGNING_SECRET!,
40
- logger: new ConsoleLogger(),
41
- }),
37
+ slack: createSlackAdapter(),
42
38
  },
43
- state: createRedisState({
44
- url: process.env.REDIS_URL!,
45
- logger: new ConsoleLogger(),
46
- }),
47
- logger: new ConsoleLogger(),
39
+ state: createRedisState(),
48
40
  });
49
41
 
50
42
  bot.onNewMention(async (thread) => {
@@ -53,6 +45,8 @@ bot.onNewMention(async (thread) => {
53
45
  });
54
46
  ```
55
47
 
48
+ Each adapter factory auto-detects credentials from environment variables (`SLACK_BOT_TOKEN`, `SLACK_SIGNING_SECRET`, `REDIS_URL`, etc.), so you can get started with zero config. Pass explicit values to override.
49
+
56
50
  ## Supported platforms
57
51
 
58
52
  | Platform | Package | Mentions | Reactions | Cards | Modals | Streaming | DMs |
@@ -16,6 +16,8 @@ pnpm add @chat-adapter/state-redis
16
16
 
17
17
  ## Usage
18
18
 
19
+ `createRedisState()` auto-detects the `REDIS_URL` environment variable, so you can call it with no arguments:
20
+
19
21
  ```typescript title="lib/bot.ts" lineNumbers
20
22
  import { Chat } from "chat";
21
23
  import { createRedisState } from "@chat-adapter/state-redis";
@@ -23,12 +25,16 @@ import { createRedisState } from "@chat-adapter/state-redis";
23
25
  const bot = new Chat({
24
26
  userName: "mybot",
25
27
  adapters: { /* ... */ },
26
- state: createRedisState({
27
- url: process.env.REDIS_URL!,
28
- }),
28
+ state: createRedisState(),
29
29
  });
30
30
  ```
31
31
 
32
+ To provide a URL explicitly:
33
+
34
+ ```typescript title="lib/bot.ts"
35
+ const state = createRedisState({ url: "redis://localhost:6379" });
36
+ ```
37
+
32
38
  ### Using an existing client
33
39
 
34
40
  If you already have a connected Redis client, pass it directly:
@@ -57,11 +63,12 @@ const state = createRedisState({
57
63
 
58
64
  | Option | Required | Description |
59
65
  |--------|----------|-------------|
60
- | `url` | Yes* | Redis connection URL |
66
+ | `url` | No* | Redis connection URL (auto-detected from `REDIS_URL`) |
61
67
  | `client` | No | Existing `redis` client instance |
62
68
  | `keyPrefix` | No | Prefix for all keys (default: `"chat-sdk"`) |
69
+ | `logger` | No | Logger instance (defaults to `ConsoleLogger("info")`) |
63
70
 
64
- *Either `url` or `client` is required.
71
+ *Either `url`, `REDIS_URL` env var, or `client` is required.
65
72
 
66
73
  ## Environment variables
67
74
 
package/docs/usage.mdx CHANGED
@@ -309,16 +309,21 @@ You typically don't need to construct these yourself — they're provided by the
309
309
 
310
310
  ## Logging
311
311
 
312
- Configure logging when creating the `Chat` instance:
312
+ The `logger` option is optional — if omitted, Chat SDK uses `ConsoleLogger("info")` by default. Each adapter also creates its own child logger automatically.
313
313
 
314
314
  ```typescript title="lib/bot.ts" lineNumbers
315
- // Use a built-in log level
315
+ // Use defaults (ConsoleLogger at "info" level)
316
+ const bot = new Chat({
317
+ // ...
318
+ });
319
+
320
+ // Or set a specific log level
316
321
  const bot = new Chat({
317
322
  // ...
318
323
  logger: "debug", // "debug" | "info" | "warn" | "error" | "silent"
319
324
  });
320
325
 
321
- // Or use ConsoleLogger for child loggers
326
+ // Or use a custom ConsoleLogger for child loggers
322
327
  import { ConsoleLogger } from "chat";
323
328
 
324
329
  const logger = new ConsoleLogger("info");
@@ -328,11 +333,10 @@ const bot = new Chat({
328
333
  });
329
334
  ```
330
335
 
331
- Pass child loggers to adapters for prefixed log output:
336
+ You can pass child loggers to adapters for prefixed log output, but adapters create their own child loggers by default:
332
337
 
333
338
  ```typescript title="lib/bot.ts"
334
339
  createSlackAdapter({
335
- // ...
336
- logger: logger.child("slack"),
340
+ logger: logger.child("slack"), // optional — auto-created if omitted
337
341
  });
338
342
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chat",
3
- "version": "4.13.2",
3
+ "version": "4.13.4",
4
4
  "description": "Unified chat abstraction for Slack, Teams, Google Chat, and Discord",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",