GitHub
Build bots that respond to pull request and issue comment threads. Treats issues and PRs as threads, comments as messages.
Install
pnpm add @chat-adapter/githubQuick start
The adapter auto-detects credentials from GITHUB_TOKEN (or GITHUB_APP_ID/GITHUB_PRIVATE_KEY), GITHUB_WEBHOOK_SECRET, and GITHUB_BOT_USERNAME.
import { Chat } from "chat";
import { createGitHubAdapter } from "@chat-adapter/github";
const bot = new Chat({
userName: "my-bot",
adapters: {
github: createGitHubAdapter(),
},
});
bot.onNewMention(async (thread, message) => {
await thread.post("Hello from GitHub!");
});Configuration
Prop
Type
Either token or appId+privateKey is required, plus webhookSecret.
Authentication
Option A — Personal Access Token
Best for personal projects, testing, or single-repo bots.
- Go to Settings then Developer settings then Personal access tokens.
- Create a token with
reposcope. - Set
GITHUB_TOKEN.
createGitHubAdapter({
token: process.env.GITHUB_TOKEN!,
});Option B — GitHub App (recommended)
Better rate limits, security, and supports multiple installations.
Create the app:
- Go to Settings then Developer settings then GitHub Apps then New GitHub App.
- Set Webhook URL to
https://your-domain.com/api/webhooks/github. - Set a Webhook secret.
- Permissions: Issues — Read & write, Pull requests — Read & write, Metadata — Read-only.
- Subscribe to events: Issue comment, Pull request review comment.
- Click Create GitHub App and generate a private key.
Install the app:
- From your app's settings click Install App and choose repositories.
- Note the Installation ID in the URL:
https://github.com/settings/installations/12345678.
Single-tenant config:
createGitHubAdapter({
appId: process.env.GITHUB_APP_ID!,
privateKey: process.env.GITHUB_PRIVATE_KEY!,
installationId: parseInt(process.env.GITHUB_INSTALLATION_ID!, 10),
});Multi-tenant (omit installationId):
createGitHubAdapter({
appId: process.env.GITHUB_APP_ID!,
privateKey: process.env.GITHUB_PRIVATE_KEY!,
});The adapter automatically extracts installation IDs from webhooks and caches API clients per-installation.
Advanced
Installation lookup
Resolve the GitHub App installation ID associated with a Thread or Message:
bot.onNewMention(async (thread, message) => {
const installationIdFromThread = await github.getInstallationId(thread);
const installationIdFromMessage = await github.getInstallationId(
message.threadId
);
});- PAT mode — returns
undefined. - Single-tenant GitHub App — returns the configured installation ID.
- Multi-tenant — only succeeds after the adapter has received a webhook for that repository and cached the mapping. Use a persistent state adapter so the mapping survives restarts.
Direct API client
Access the underlying Octokit instance via .octokit:
const github = bot.getAdapter("github").octokit;
const { data: pulls } = await github.rest.pulls.list({
owner: "vercel",
repo: "chat",
state: "open",
});PAT and single-tenant App modes return the same client anywhere. Multi-tenant mode requires webhook-handler context — calling .octokit outside a handler throws.
The previous
.clientgetter still works as a deprecated alias for.octokit.
Webhook setup
For repository or organization webhooks:
- Settings then Webhooks then Add webhook.
- Set payload URL to
https://your-domain.com/api/webhooks/github. - Set Content type to
application/json(the defaultapplication/x-www-form-urlencodeddoes not work). - Set Secret to match
webhookSecret. - Select events: Issue comments, Pull request review comments.
GitHub App webhooks are configured during app creation — make sure to select application/json.
Thread model
| Type | Context | Thread ID format |
|---|---|---|
| PR-level | PR Conversation tab | github:{owner}/{repo}:{prNumber} |
| Review comments | PR Files Changed tab | github:{owner}/{repo}:{prNumber}:rc:{commentId} |
| Issue comments | Issue thread | github:{owner}/{repo}:issue:{issueNumber} |
Reactions
| SDK emoji | GitHub reaction |
|---|---|
thumbs_up | +1 |
thumbs_down | -1 |
laugh | laugh |
confused | confused |
heart | heart |
hooray | hooray |
rocket | rocket |
eyes | eyes |
Feature support
Messaging
| Feature | Supported |
|---|---|
| Post message | |
| Edit message | |
| Delete message | |
| File uploads | |
| Streaming | Buffered |
| Scheduled messages |
Rich content
| Feature | Supported |
|---|---|
| Card format | GFM Markdown |
| Buttons | |
| Link buttons | |
| Select menus | |
| Tables | GFM |
| Fields | |
| Images in cards | |
| Modals |
Conversations
| Feature | Supported |
|---|---|
| Slash commands | |
| Mentions | |
| Add reactions | |
| Remove reactions | Partial |
| Typing indicator | |
| DMs | |
| Ephemeral messages | |
| User lookup | |
| Parent subject | |
| Native client | |
| Custom API endpoint |
Message history
| Feature | Supported |
|---|---|
| Fetch messages | |
| Fetch single message | |
| Fetch thread info | |
| Fetch channel messages | |
| List threads | |
| Fetch channel info | |
| Post channel message |