chat 4.13.1 → 4.13.3
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.
- package/README.md +19 -31
- package/dist/{chunk-WKJEG4FE.js → chunk-THM4ACIE.js} +12 -4
- package/dist/chunk-THM4ACIE.js.map +1 -0
- package/dist/index.d.ts +410 -415
- package/dist/index.js +65 -29
- package/dist/index.js.map +1 -1
- package/dist/{jsx-runtime-COVsDskT.d.ts → jsx-runtime-Bdt1Dwzf.d.ts} +71 -71
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/docs/actions.mdx +98 -0
- package/docs/adapters/discord.mdx +217 -0
- package/docs/adapters/gchat.mdx +232 -0
- package/docs/adapters/github.mdx +225 -0
- package/docs/adapters/index.mdx +110 -0
- package/docs/adapters/linear.mdx +207 -0
- package/docs/adapters/meta.json +12 -0
- package/docs/adapters/slack.mdx +293 -0
- package/docs/adapters/teams.mdx +225 -0
- package/docs/api/cards.mdx +217 -0
- package/docs/api/channel.mdx +176 -0
- package/docs/api/chat.mdx +469 -0
- package/docs/api/index.mdx +29 -0
- package/docs/api/markdown.mdx +235 -0
- package/docs/api/message.mdx +163 -0
- package/docs/api/meta.json +14 -0
- package/docs/api/modals.mdx +222 -0
- package/docs/api/postable-message.mdx +166 -0
- package/docs/api/thread.mdx +186 -0
- package/docs/cards.mdx +213 -0
- package/docs/direct-messages.mdx +56 -0
- package/docs/emoji.mdx +77 -0
- package/docs/ephemeral-messages.mdx +77 -0
- package/docs/error-handling.mdx +147 -0
- package/docs/files.mdx +77 -0
- package/docs/getting-started.mdx +12 -0
- package/docs/guides/code-review-hono.mdx +248 -0
- package/docs/guides/discord-nuxt.mdx +237 -0
- package/docs/guides/meta.json +4 -0
- package/docs/guides/slack-nextjs.mdx +245 -0
- package/docs/index.mdx +92 -0
- package/docs/meta.json +20 -0
- package/docs/modals.mdx +208 -0
- package/docs/posting-messages.mdx +177 -0
- package/docs/slash-commands.mdx +110 -0
- package/docs/state/index.mdx +31 -0
- package/docs/state/ioredis.mdx +81 -0
- package/docs/state/memory.mdx +52 -0
- package/docs/state/meta.json +9 -0
- package/docs/state/redis.mdx +93 -0
- package/docs/streaming.mdx +99 -0
- package/docs/usage.mdx +338 -0
- package/package.json +10 -10
- package/dist/chunk-WKJEG4FE.js.map +0 -1
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Google Chat
|
|
3
|
+
description: Configure the Google Chat adapter with service account authentication and optional Pub/Sub.
|
|
4
|
+
type: integration
|
|
5
|
+
prerequisites:
|
|
6
|
+
- /docs/getting-started
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```sh title="Terminal"
|
|
12
|
+
pnpm add @chat-adapter/gchat
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```typescript title="lib/bot.ts" lineNumbers
|
|
18
|
+
import { Chat } from "chat";
|
|
19
|
+
import { createGoogleChatAdapter } from "@chat-adapter/gchat";
|
|
20
|
+
|
|
21
|
+
const bot = new Chat({
|
|
22
|
+
userName: "mybot",
|
|
23
|
+
adapters: {
|
|
24
|
+
gchat: createGoogleChatAdapter({
|
|
25
|
+
credentials: JSON.parse(process.env.GOOGLE_CHAT_CREDENTIALS!),
|
|
26
|
+
}),
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
bot.onNewMention(async (thread, message) => {
|
|
31
|
+
await thread.post("Hello from Google Chat!");
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Google Chat setup
|
|
36
|
+
|
|
37
|
+
### 1. Create a GCP project
|
|
38
|
+
|
|
39
|
+
1. Go to [console.cloud.google.com](https://console.cloud.google.com)
|
|
40
|
+
2. Click the project dropdown then **New Project**
|
|
41
|
+
3. Enter project name and click **Create**
|
|
42
|
+
|
|
43
|
+
### 2. Enable required APIs
|
|
44
|
+
|
|
45
|
+
Go to **APIs & Services** then **Library** and enable:
|
|
46
|
+
|
|
47
|
+
- **Google Chat API**
|
|
48
|
+
- **Google Workspace Events API** (for receiving all messages)
|
|
49
|
+
- **Cloud Pub/Sub API** (for receiving all messages)
|
|
50
|
+
|
|
51
|
+
### 3. Create a service account
|
|
52
|
+
|
|
53
|
+
1. Go to **IAM & Admin** then **Service Accounts**
|
|
54
|
+
2. Click **Create Service Account**
|
|
55
|
+
3. Enter name and description
|
|
56
|
+
4. Click **Create and Continue**
|
|
57
|
+
5. Skip the optional steps, click **Done**
|
|
58
|
+
|
|
59
|
+
### 4. Create service account key
|
|
60
|
+
|
|
61
|
+
1. Click on your service account
|
|
62
|
+
2. Go to **Keys** tab
|
|
63
|
+
3. Click **Add Key** then **Create new key**
|
|
64
|
+
4. Select **JSON** and click **Create**
|
|
65
|
+
5. Copy the entire JSON content as `GOOGLE_CHAT_CREDENTIALS`
|
|
66
|
+
|
|
67
|
+
<Callout type="info">
|
|
68
|
+
If your organization has the `iam.disableServiceAccountKeyCreation` constraint enabled, you need to relax it or add an exception for your project in **IAM & Admin** then **Organization Policies**.
|
|
69
|
+
</Callout>
|
|
70
|
+
|
|
71
|
+
### 5. Configure Google Chat app
|
|
72
|
+
|
|
73
|
+
1. Go to the [Chat API configuration](https://console.cloud.google.com/apis/api/chat.googleapis.com/hangouts-chat)
|
|
74
|
+
2. Click **Configuration** and fill in:
|
|
75
|
+
- **App name**: Your bot's display name
|
|
76
|
+
- **Avatar URL**: URL to your bot's avatar
|
|
77
|
+
- **Description**: What your bot does
|
|
78
|
+
- **Interactive features**: Enable **Receive 1:1 messages** and **Join spaces and group conversations**
|
|
79
|
+
- **Connection settings**: Select **App URL**
|
|
80
|
+
- **App URL**: `https://your-domain.com/api/webhooks/gchat`
|
|
81
|
+
- **Visibility**: Choose who can discover your app
|
|
82
|
+
3. Click **Save**
|
|
83
|
+
|
|
84
|
+
### 6. Add bot to a space
|
|
85
|
+
|
|
86
|
+
1. Open Google Chat
|
|
87
|
+
2. Create or open a Space
|
|
88
|
+
3. Click the space name then **Manage apps & integrations**
|
|
89
|
+
4. Click **Add apps**, search for your app, and click **Add**
|
|
90
|
+
|
|
91
|
+
## Pub/Sub for all messages (optional)
|
|
92
|
+
|
|
93
|
+
By default, Google Chat only sends webhooks for @mentions. To receive all messages in a space, set up Workspace Events with Pub/Sub.
|
|
94
|
+
|
|
95
|
+
```typescript title="lib/bot.ts" lineNumbers
|
|
96
|
+
createGoogleChatAdapter({
|
|
97
|
+
credentials: JSON.parse(process.env.GOOGLE_CHAT_CREDENTIALS!),
|
|
98
|
+
pubsubTopic: process.env.GOOGLE_CHAT_PUBSUB_TOPIC,
|
|
99
|
+
impersonateUser: process.env.GOOGLE_CHAT_IMPERSONATE_USER,
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 1. Create Pub/Sub topic
|
|
104
|
+
|
|
105
|
+
1. Go to **Pub/Sub** then **Topics**
|
|
106
|
+
2. Click **Create Topic**
|
|
107
|
+
3. Enter topic ID (e.g., `chat-events`)
|
|
108
|
+
4. Uncheck **Add a default subscription**
|
|
109
|
+
5. Click **Create**
|
|
110
|
+
6. Copy the full topic name as `GOOGLE_CHAT_PUBSUB_TOPIC` (format: `projects/your-project-id/topics/chat-events`)
|
|
111
|
+
|
|
112
|
+
### 2. Grant Chat service account access
|
|
113
|
+
|
|
114
|
+
1. Go to your Pub/Sub topic
|
|
115
|
+
2. Click **Permissions** tab
|
|
116
|
+
3. Click **Add Principal**
|
|
117
|
+
4. Enter `chat-api-push@system.gserviceaccount.com`
|
|
118
|
+
5. Select role **Pub/Sub Publisher**
|
|
119
|
+
6. Click **Save**
|
|
120
|
+
|
|
121
|
+
### 3. Create push subscription
|
|
122
|
+
|
|
123
|
+
1. Go to **Pub/Sub** then **Subscriptions**
|
|
124
|
+
2. Click **Create Subscription**
|
|
125
|
+
3. Select your topic
|
|
126
|
+
4. Set **Delivery type** to Push
|
|
127
|
+
5. Set **Endpoint URL** to `https://your-domain.com/api/webhooks/gchat`
|
|
128
|
+
6. Click **Create**
|
|
129
|
+
|
|
130
|
+
### 4. Enable domain-wide delegation
|
|
131
|
+
|
|
132
|
+
Domain-wide delegation is required for creating Workspace Events subscriptions and initiating DMs.
|
|
133
|
+
|
|
134
|
+
**Step 1 — Enable delegation on the service account:**
|
|
135
|
+
|
|
136
|
+
1. Go to **IAM & Admin** then **Service Accounts**
|
|
137
|
+
2. Click on your service account
|
|
138
|
+
3. Check **Enable Google Workspace Domain-wide Delegation** and save
|
|
139
|
+
4. Copy the **Client ID** (a numeric ID, not the email)
|
|
140
|
+
|
|
141
|
+
**Step 2 — Authorize in Google Admin Console:**
|
|
142
|
+
|
|
143
|
+
1. Go to [Google Admin Console](https://admin.google.com)
|
|
144
|
+
2. Go to **Security** then **Access and data control** then **API controls**
|
|
145
|
+
3. Click **Manage Domain Wide Delegation** then **Add new**
|
|
146
|
+
4. Enter the numeric **Client ID** from Step 1
|
|
147
|
+
5. Add OAuth scopes (comma-separated, on one line):
|
|
148
|
+
```
|
|
149
|
+
https://www.googleapis.com/auth/chat.spaces.readonly,https://www.googleapis.com/auth/chat.messages.readonly,https://www.googleapis.com/auth/chat.spaces,https://www.googleapis.com/auth/chat.spaces.create
|
|
150
|
+
```
|
|
151
|
+
6. Click **Authorize**
|
|
152
|
+
|
|
153
|
+
**Step 3 — Set environment variable:**
|
|
154
|
+
|
|
155
|
+
Set `GOOGLE_CHAT_IMPERSONATE_USER` to an admin user email in your domain (e.g., `admin@yourdomain.com`).
|
|
156
|
+
|
|
157
|
+
## Configuration
|
|
158
|
+
|
|
159
|
+
| Option | Required | Description |
|
|
160
|
+
|--------|----------|-------------|
|
|
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.
|
|
167
|
+
|
|
168
|
+
## Environment variables
|
|
169
|
+
|
|
170
|
+
```bash title=".env.local"
|
|
171
|
+
GOOGLE_CHAT_CREDENTIALS={"type":"service_account",...}
|
|
172
|
+
|
|
173
|
+
# Optional: for receiving all messages
|
|
174
|
+
GOOGLE_CHAT_PUBSUB_TOPIC=projects/your-project/topics/chat-events
|
|
175
|
+
GOOGLE_CHAT_IMPERSONATE_USER=admin@yourdomain.com
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Features
|
|
179
|
+
|
|
180
|
+
| Feature | Supported |
|
|
181
|
+
|---------|-----------|
|
|
182
|
+
| Mentions | Yes |
|
|
183
|
+
| Reactions (add/remove) | Yes (via Workspace Events) |
|
|
184
|
+
| Cards (Google Chat Cards) | Yes |
|
|
185
|
+
| Modals | No |
|
|
186
|
+
| Streaming | Post+Edit fallback |
|
|
187
|
+
| DMs | Yes (requires delegation) |
|
|
188
|
+
| Ephemeral messages | Yes (native) |
|
|
189
|
+
| File uploads | Yes |
|
|
190
|
+
| Typing indicator | No |
|
|
191
|
+
| Message history | Yes |
|
|
192
|
+
|
|
193
|
+
## Limitations
|
|
194
|
+
|
|
195
|
+
- **Typing indicators**: Not supported by Google Chat API. `startTyping()` is a no-op.
|
|
196
|
+
- **Adding reactions**: The Google Chat API doesn't support service account (app) authentication for adding reactions. To use `addReaction()` or `removeReaction()`, you need domain-wide delegation with `impersonateUser` configured — but the reaction appears as coming from the impersonated user, not the bot.
|
|
197
|
+
|
|
198
|
+
### Message history (`fetchMessages`)
|
|
199
|
+
|
|
200
|
+
Fetching message history requires domain-wide delegation with the `impersonateUser` config option set. The impersonated user must have access to the spaces you want to read from. See the [Pub/Sub setup](#4-enable-domain-wide-delegation) above for configuring delegation and OAuth scopes.
|
|
201
|
+
|
|
202
|
+
## Troubleshooting
|
|
203
|
+
|
|
204
|
+
### No webhook received
|
|
205
|
+
|
|
206
|
+
- Verify the App URL is correct in Google Chat configuration
|
|
207
|
+
- Check that the Chat API is enabled
|
|
208
|
+
- Ensure the service account has the necessary permissions
|
|
209
|
+
|
|
210
|
+
### Pub/Sub not working
|
|
211
|
+
|
|
212
|
+
- Verify `chat-api-push@system.gserviceaccount.com` has Pub/Sub Publisher role
|
|
213
|
+
- Check that the push subscription URL is correct
|
|
214
|
+
- Verify domain-wide delegation is configured with correct scopes
|
|
215
|
+
- Check `GOOGLE_CHAT_IMPERSONATE_USER` is a valid admin email
|
|
216
|
+
|
|
217
|
+
### "Permission denied" for Workspace Events
|
|
218
|
+
|
|
219
|
+
- Ensure domain-wide delegation is configured
|
|
220
|
+
- Verify the OAuth scopes are exactly as specified
|
|
221
|
+
- Check that the impersonated user has access to the spaces
|
|
222
|
+
|
|
223
|
+
### "Insufficient Permission" for DMs
|
|
224
|
+
|
|
225
|
+
- DMs require domain-wide delegation with `chat.spaces` and `chat.spaces.create` scopes
|
|
226
|
+
- Scope changes can take up to 24 hours to propagate
|
|
227
|
+
|
|
228
|
+
### Button clicks not received
|
|
229
|
+
|
|
230
|
+
- Verify **Interactive features** is enabled in the Google Chat app configuration
|
|
231
|
+
- Check that the App URL is correctly set and accessible
|
|
232
|
+
- Button clicks go to the same webhook URL as messages
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: GitHub
|
|
3
|
+
description: Configure the GitHub adapter to respond to @mentions in PR and issue comment threads.
|
|
4
|
+
type: integration
|
|
5
|
+
prerequisites:
|
|
6
|
+
- /docs/getting-started
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
The GitHub adapter treats issue and pull request comments as messages, and issues/PRs as threads.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```sh title="Terminal"
|
|
14
|
+
pnpm add @chat-adapter/github
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```typescript title="lib/bot.ts" lineNumbers
|
|
20
|
+
import { Chat } from "chat";
|
|
21
|
+
import { createGitHubAdapter } from "@chat-adapter/github";
|
|
22
|
+
|
|
23
|
+
const bot = new Chat({
|
|
24
|
+
userName: "my-bot",
|
|
25
|
+
adapters: {
|
|
26
|
+
github: createGitHubAdapter({
|
|
27
|
+
token: process.env.GITHUB_TOKEN!,
|
|
28
|
+
webhookSecret: process.env.GITHUB_WEBHOOK_SECRET!,
|
|
29
|
+
userName: "my-bot",
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
bot.onNewMention(async (thread, message) => {
|
|
35
|
+
await thread.post("Hello from GitHub!");
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Authentication
|
|
40
|
+
|
|
41
|
+
### Option A: Personal Access Token
|
|
42
|
+
|
|
43
|
+
Best for personal projects, testing, or single-repo bots.
|
|
44
|
+
|
|
45
|
+
1. Go to [Settings > Developer settings > Personal access tokens](https://github.com/settings/tokens)
|
|
46
|
+
2. Create a new token with `repo` scope
|
|
47
|
+
3. Set `GITHUB_TOKEN` environment variable
|
|
48
|
+
|
|
49
|
+
```typescript title="lib/bot.ts" lineNumbers
|
|
50
|
+
createGitHubAdapter({
|
|
51
|
+
token: process.env.GITHUB_TOKEN!,
|
|
52
|
+
webhookSecret: process.env.GITHUB_WEBHOOK_SECRET!,
|
|
53
|
+
userName: "my-bot",
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Option B: GitHub App (recommended)
|
|
58
|
+
|
|
59
|
+
Better rate limits, security, and supports multiple installations.
|
|
60
|
+
|
|
61
|
+
**1. Create the app:**
|
|
62
|
+
|
|
63
|
+
1. Go to [Settings > Developer settings > GitHub Apps > New GitHub App](https://github.com/settings/apps/new)
|
|
64
|
+
2. Set **Webhook URL** to `https://your-domain.com/api/webhooks/github`
|
|
65
|
+
3. Generate and set a **Webhook secret**
|
|
66
|
+
4. Set permissions:
|
|
67
|
+
- Repository > Issues: Read & write
|
|
68
|
+
- Repository > Pull requests: Read & write
|
|
69
|
+
- Repository > Metadata: Read-only
|
|
70
|
+
5. Subscribe to events: Issue comment, Pull request review comment
|
|
71
|
+
6. Click **Create GitHub App**
|
|
72
|
+
7. Note the **App ID** and click **Generate a private key**
|
|
73
|
+
|
|
74
|
+
**2. Install the app:**
|
|
75
|
+
|
|
76
|
+
1. Go to your app's settings then **Install App**
|
|
77
|
+
2. Click **Install** and choose repositories
|
|
78
|
+
3. Note the **Installation ID** from the URL:
|
|
79
|
+
```
|
|
80
|
+
https://github.com/settings/installations/12345678
|
|
81
|
+
^^^^^^^^
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Single-tenant:**
|
|
85
|
+
|
|
86
|
+
```typescript title="lib/bot.ts" lineNumbers
|
|
87
|
+
createGitHubAdapter({
|
|
88
|
+
appId: process.env.GITHUB_APP_ID!,
|
|
89
|
+
privateKey: process.env.GITHUB_PRIVATE_KEY!,
|
|
90
|
+
installationId: parseInt(process.env.GITHUB_INSTALLATION_ID!),
|
|
91
|
+
webhookSecret: process.env.GITHUB_WEBHOOK_SECRET!,
|
|
92
|
+
userName: "my-bot[bot]",
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Multi-tenant (omit `installationId`):**
|
|
97
|
+
|
|
98
|
+
```typescript title="lib/bot.ts" lineNumbers
|
|
99
|
+
createGitHubAdapter({
|
|
100
|
+
appId: process.env.GITHUB_APP_ID!,
|
|
101
|
+
privateKey: process.env.GITHUB_PRIVATE_KEY!,
|
|
102
|
+
webhookSecret: process.env.GITHUB_WEBHOOK_SECRET!,
|
|
103
|
+
userName: "my-bot[bot]",
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The adapter automatically extracts installation IDs from webhooks and caches API clients per-installation.
|
|
108
|
+
|
|
109
|
+
## Webhook setup
|
|
110
|
+
|
|
111
|
+
For repository or organization webhooks:
|
|
112
|
+
|
|
113
|
+
1. Go to repository/org **Settings** then **Webhooks** then **Add webhook**
|
|
114
|
+
2. Set **Payload URL** to `https://your-domain.com/api/webhooks/github`
|
|
115
|
+
3. Set **Content type** to `application/json` (required — the default `application/x-www-form-urlencoded` does not work)
|
|
116
|
+
4. Set **Secret** to match your `webhookSecret`
|
|
117
|
+
5. Select events: Issue comments, Pull request review comments
|
|
118
|
+
|
|
119
|
+
<Callout type="warn">
|
|
120
|
+
GitHub App webhooks are configured during app creation. Make sure to select `application/json` as the content type.
|
|
121
|
+
</Callout>
|
|
122
|
+
|
|
123
|
+
## Thread model
|
|
124
|
+
|
|
125
|
+
GitHub has two types of comment threads:
|
|
126
|
+
|
|
127
|
+
| Type | Tab | Thread ID format |
|
|
128
|
+
|------|-----|-----------------|
|
|
129
|
+
| PR-level | Conversation | `github:{owner}/{repo}:{prNumber}` |
|
|
130
|
+
| Review comments | Files Changed | `github:{owner}/{repo}:{prNumber}:rc:{commentId}` |
|
|
131
|
+
|
|
132
|
+
## Reactions
|
|
133
|
+
|
|
134
|
+
Supports GitHub's reaction emoji:
|
|
135
|
+
|
|
136
|
+
| SDK emoji | GitHub reaction |
|
|
137
|
+
|-----------|----------------|
|
|
138
|
+
| `thumbs_up` | 👍 (+1) |
|
|
139
|
+
| `thumbs_down` | 👎 (-1) |
|
|
140
|
+
| `laugh` | 😄 |
|
|
141
|
+
| `confused` | 😕 |
|
|
142
|
+
| `heart` | ❤️ |
|
|
143
|
+
| `hooray` | 🎉 |
|
|
144
|
+
| `rocket` | 🚀 |
|
|
145
|
+
| `eyes` | 👀 |
|
|
146
|
+
|
|
147
|
+
## Configuration
|
|
148
|
+
|
|
149
|
+
| Option | Required | Description |
|
|
150
|
+
|--------|----------|-------------|
|
|
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 |
|
|
157
|
+
| `botUserId` | No | Bot's numeric user ID (auto-detected if not provided) |
|
|
158
|
+
|
|
159
|
+
*Either `token` or `appId`/`privateKey` is required.
|
|
160
|
+
|
|
161
|
+
## Environment variables
|
|
162
|
+
|
|
163
|
+
```bash title=".env.local"
|
|
164
|
+
# Personal Access Token auth
|
|
165
|
+
GITHUB_TOKEN=ghp_xxxxxxxxxxxx
|
|
166
|
+
|
|
167
|
+
# OR GitHub App auth
|
|
168
|
+
GITHUB_APP_ID=123456
|
|
169
|
+
GITHUB_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----..."
|
|
170
|
+
GITHUB_INSTALLATION_ID=12345678 # Optional for multi-tenant
|
|
171
|
+
|
|
172
|
+
# Required
|
|
173
|
+
GITHUB_WEBHOOK_SECRET=your-webhook-secret
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Features
|
|
177
|
+
|
|
178
|
+
| Feature | Supported |
|
|
179
|
+
|---------|-----------|
|
|
180
|
+
| Mentions | Yes |
|
|
181
|
+
| Reactions (add/remove) | Yes |
|
|
182
|
+
| Cards | GFM Markdown |
|
|
183
|
+
| Modals | No |
|
|
184
|
+
| Streaming | No |
|
|
185
|
+
| DMs | No |
|
|
186
|
+
| File uploads | No |
|
|
187
|
+
| Typing indicator | No |
|
|
188
|
+
| Message history | Yes |
|
|
189
|
+
| Multi-tenant | Yes (GitHub App) |
|
|
190
|
+
|
|
191
|
+
## Limitations
|
|
192
|
+
|
|
193
|
+
- **No typing indicators** — GitHub doesn't support typing indicators
|
|
194
|
+
- **No streaming** — Messages posted in full (editing supported for updates)
|
|
195
|
+
- **No DMs** — GitHub doesn't have direct messages
|
|
196
|
+
- **No modals** — GitHub doesn't support interactive modals
|
|
197
|
+
- **Action buttons** — Rendered as text; use link buttons for clickable actions
|
|
198
|
+
|
|
199
|
+
## Troubleshooting
|
|
200
|
+
|
|
201
|
+
### "Invalid signature" error
|
|
202
|
+
|
|
203
|
+
- Verify `GITHUB_WEBHOOK_SECRET` matches your webhook configuration
|
|
204
|
+
- Ensure the request body isn't modified before verification
|
|
205
|
+
|
|
206
|
+
### "Invalid JSON" error
|
|
207
|
+
|
|
208
|
+
- Change webhook **Content type** to `application/json`
|
|
209
|
+
|
|
210
|
+
### Bot not responding to mentions
|
|
211
|
+
|
|
212
|
+
- Verify webhook events are configured (issue_comment, pull_request_review_comment)
|
|
213
|
+
- Check the webhook URL is correct and accessible
|
|
214
|
+
- Ensure the `userName` config matches your bot's GitHub username
|
|
215
|
+
|
|
216
|
+
### "Installation ID required" error
|
|
217
|
+
|
|
218
|
+
- This occurs when making API calls outside webhook context in multi-tenant mode
|
|
219
|
+
- Use a persistent state adapter (Redis) to store installation mappings
|
|
220
|
+
- The first interaction must come from a webhook to establish the mapping
|
|
221
|
+
|
|
222
|
+
### Rate limiting
|
|
223
|
+
|
|
224
|
+
- PATs have lower rate limits than GitHub Apps
|
|
225
|
+
- Consider switching to a GitHub App for production use
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Overview
|
|
3
|
+
description: Platform-specific adapters for Slack, Teams, Google Chat, Discord, GitHub, and Linear.
|
|
4
|
+
type: overview
|
|
5
|
+
prerequisites:
|
|
6
|
+
- /docs/getting-started
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Adapters handle webhook verification, message parsing, and API calls for each platform. Install only the adapters you need.
|
|
10
|
+
|
|
11
|
+
## Feature matrix
|
|
12
|
+
|
|
13
|
+
### Messaging
|
|
14
|
+
|
|
15
|
+
| Feature | [Slack](/docs/adapters/slack) | [Teams](/docs/adapters/teams) | [Google Chat](/docs/adapters/gchat) | [Discord](/docs/adapters/discord) | [GitHub](/docs/adapters/github) | [Linear](/docs/adapters/linear) |
|
|
16
|
+
|---------|-------|-------|-------------|---------|--------|--------|
|
|
17
|
+
| Post message | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
18
|
+
| Edit message | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
19
|
+
| Delete message | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
20
|
+
| File uploads | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
|
|
21
|
+
| Streaming | ✅ Native | ⚠️ Post+Edit | ⚠️ Post+Edit | ⚠️ Post+Edit | ❌ | ❌ |
|
|
22
|
+
|
|
23
|
+
### Rich content
|
|
24
|
+
|
|
25
|
+
| Feature | Slack | Teams | Google Chat | Discord | GitHub | Linear |
|
|
26
|
+
|---------|-------|-------|-------------|---------|--------|--------|
|
|
27
|
+
| Card format | Block Kit | Adaptive Cards | Google Chat Cards | Embeds | GFM Markdown | Markdown |
|
|
28
|
+
| Buttons | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ |
|
|
29
|
+
| Link buttons | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ |
|
|
30
|
+
| Select menus | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ |
|
|
31
|
+
| Fields | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
32
|
+
| Images in cards | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
33
|
+
| Modals | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
34
|
+
|
|
35
|
+
### Conversations
|
|
36
|
+
|
|
37
|
+
| Feature | Slack | Teams | Google Chat | Discord | GitHub | Linear |
|
|
38
|
+
|---------|-------|-------|-------------|---------|--------|--------|
|
|
39
|
+
| Mentions | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
40
|
+
| Add reactions | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ |
|
|
41
|
+
| Remove reactions | ✅ | ❌ | ✅ | ✅ | ⚠️ | ⚠️ |
|
|
42
|
+
| Typing indicator | ❌ | ✅ | ❌ | ✅ | ❌ | ❌ |
|
|
43
|
+
| DMs | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ |
|
|
44
|
+
| Ephemeral messages | ✅ Native | ❌ | ✅ Native | ❌ | ❌ | ❌ |
|
|
45
|
+
|
|
46
|
+
### Message history
|
|
47
|
+
|
|
48
|
+
| Feature | Slack | Teams | Google Chat | Discord | GitHub | Linear |
|
|
49
|
+
|---------|-------|-------|-------------|---------|--------|--------|
|
|
50
|
+
| Fetch messages | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
51
|
+
| Fetch single message | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
|
52
|
+
| Fetch thread info | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
53
|
+
| Fetch channel messages | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
54
|
+
| List threads | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
55
|
+
| Fetch channel info | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
56
|
+
| Post channel message | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ |
|
|
57
|
+
|
|
58
|
+
<Callout type="info">
|
|
59
|
+
⚠️ indicates partial support — the feature works with limitations. See individual adapter pages for details.
|
|
60
|
+
</Callout>
|
|
61
|
+
|
|
62
|
+
## Packages
|
|
63
|
+
|
|
64
|
+
| Platform | Package |
|
|
65
|
+
|----------|---------|
|
|
66
|
+
| [Slack](/docs/adapters/slack) | `@chat-adapter/slack` |
|
|
67
|
+
| [Microsoft Teams](/docs/adapters/teams) | `@chat-adapter/teams` |
|
|
68
|
+
| [Google Chat](/docs/adapters/gchat) | `@chat-adapter/gchat` |
|
|
69
|
+
| [Discord](/docs/adapters/discord) | `@chat-adapter/discord` |
|
|
70
|
+
| [GitHub](/docs/adapters/github) | `@chat-adapter/github` |
|
|
71
|
+
| [Linear](/docs/adapters/linear) | `@chat-adapter/linear` |
|
|
72
|
+
|
|
73
|
+
## How adapters work
|
|
74
|
+
|
|
75
|
+
Each adapter implements a standard interface that the `Chat` class uses to route events and send messages. When a webhook arrives:
|
|
76
|
+
|
|
77
|
+
1. The adapter verifies the request signature
|
|
78
|
+
2. Parses the platform-specific payload into a normalized `Message`
|
|
79
|
+
3. Routes to your handlers via the `Chat` class
|
|
80
|
+
4. Converts outgoing messages from markdown/AST/cards to the platform's native format
|
|
81
|
+
|
|
82
|
+
## Using multiple adapters
|
|
83
|
+
|
|
84
|
+
Register multiple adapters and your event handlers work across all of them:
|
|
85
|
+
|
|
86
|
+
```typescript title="lib/bot.ts" lineNumbers
|
|
87
|
+
import { Chat } from "chat";
|
|
88
|
+
import { createSlackAdapter } from "@chat-adapter/slack";
|
|
89
|
+
import { createTeamsAdapter } from "@chat-adapter/teams";
|
|
90
|
+
import { createGoogleChatAdapter } from "@chat-adapter/gchat";
|
|
91
|
+
import { createRedisState } from "@chat-adapter/state-redis";
|
|
92
|
+
|
|
93
|
+
const bot = new Chat({
|
|
94
|
+
userName: "mybot",
|
|
95
|
+
adapters: {
|
|
96
|
+
slack: createSlackAdapter({ /* ... */ }),
|
|
97
|
+
teams: createTeamsAdapter({ /* ... */ }),
|
|
98
|
+
gchat: createGoogleChatAdapter({ /* ... */ }),
|
|
99
|
+
},
|
|
100
|
+
state: createRedisState({ url: process.env.REDIS_URL! }),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// This handler fires for mentions on any platform
|
|
104
|
+
bot.onNewMention(async (thread) => {
|
|
105
|
+
await thread.subscribe();
|
|
106
|
+
await thread.post("Hello!");
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Each adapter creates a webhook handler accessible via `bot.webhooks.slack`, `bot.webhooks.teams`, etc.
|