@chat-adapter/linear
Linear adapter for Chat SDK. Respond to @mentions in issue comment threads and Linear app-actor agent sessions.
The Linear adapter treats issue comments as messages and issues as threads.
Installation
Usage
The adapter auto-detects credentials from LINEAR_API_KEY, LINEAR_ACCESS_TOKEN, LINEAR_CLIENT_CREDENTIALS_CLIENT_ID/LINEAR_CLIENT_CREDENTIALS_CLIENT_SECRET, or LINEAR_CLIENT_ID/LINEAR_CLIENT_SECRET, plus LINEAR_WEBHOOK_SECRET and LINEAR_BOT_USERNAME:
By default, the adapter runs in mode: "comments" and treats Comment webhooks as the inbound message source. For Linear app-actor installs, set mode: "agent-sessions" so inbound handling is driven by AgentSessionEvent.
Authentication
Option A: Personal API key
Best for personal projects, testing, or single-workspace bots. Actions are attributed to you as an individual.
- Go to Settings > Security & Access
- Under Personal API keys, click Create key
- Select Only select permissions and enable Create issues, Create comments
- Choose team access
- Click Create and set
LINEAR_API_KEY
Option B: Pre-obtained OAuth access token
Use this when your app already manages the OAuth flow and you just want the adapter to operate with a single workspace token.
Option C: Multi-tenant OAuth installs
Use top-level clientId / clientSecret for Slack-style multi-tenant installs. Each Linear workspace installation is stored separately, webhook requests resolve the correct workspace token by organizationId, and withInstallation() lets you target a specific organization outside webhook handling.
- Go to Settings > API > Applications
- Create an OAuth2 application with your bot's name and icon
- Note the Client ID and Client Secret
Example callback route:
Example background job:
Option D: Single-tenant client credentials
If you want app identity without multi-tenant installs, use the explicit clientCredentials config. The adapter fetches and refreshes the token automatically.
Making the bot @-mentionable (optional)
To make the bot appear in Linear's @ mention dropdown as an Agent:
- In your OAuth app settings, enable Agent session events under webhooks
- Have a workspace admin install the app with
actor=appand theapp:mentionablescope:
If you use single-tenant client credentials, request the same scopes there:
Once installed with actor=app, set mode: "agent-sessions" so the adapter treats AgentSessionEvent as the entrypoint for mentions:
onNewMentionfires from the session-created eventthread.startTyping()sends an ephemeral Linearthoughtthread.post(stream)uses agent activities and session plan updates- Session threads are append-only, so
sent.edit()/sent.delete()are not supported there
See the Linear Agents docs for full details.
Webhook setup
Note: Webhook management requires workspace admin access. If you don't see the API settings page, ask a workspace admin to create the webhook for you.
- Go to Settings > API and click Create webhook
- Fill in:
- Label: A descriptive name (e.g., "Chat Bot")
- URL:
https://your-domain.com/api/webhooks/linear
- Copy the Signing secret as
LINEAR_WEBHOOK_SECRET - Under Data change events, select:
- Comments (required for
mode: "comments") - Agent session events (required for
mode: "agent-sessions") - Issues (recommended)
- Emoji reactions (optional)
- Comments (required for
- Under Team selection, choose All public teams or a specific team
- Click Create webhook
Thread model
Linear has four thread variants:
When a user writes a comment, the bot replies within the same comment thread.
Reactions
Configuration
All options are auto-detected from environment variables when not provided.
*One of apiKey, accessToken, top-level clientId/clientSecret, or clientCredentials is required (via config or env vars).
**webhookSecret is required — either via config or LINEAR_WEBHOOK_SECRET env var.
Environment variables
Features
Messaging
Rich content
Conversations
Message history
Limitations
- Comment threads are still comment-based — typing indicators and native streaming only exist for app-actor agent sessions
- Agent session threads are append-only —
editMessageanddeleteMessagework for normal comments, but not for session activities - No DMs — Linear doesn't have direct messages
- No modals — Linear doesn't support interactive modals
- Action buttons — Rendered as text; use link buttons for clickable actions
- Remove reaction — Requires reaction ID lookup (not directly supported)
Troubleshooting
"Invalid signature" error
- Verify
LINEAR_WEBHOOK_SECRETmatches the secret from your webhook configuration - The webhook secret is shown only once at creation — regenerate if lost
Bot not responding to mentions
- Verify webhook events are configured with Comments resource type
- For app-actor mode, also enable Agent session events
- Check that the webhook URL is correct and accessible
- Ensure the
userNameconfig matches how users mention the bot - If using app-actor installs, ensure the app was installed with
actor=appandapp:mentionable - Linear may auto-disable webhooks after repeated failures
"Webhook expired" error
- Webhook timestamp is too old (> 5 minutes)
- Usually indicates a delivery delay or clock skew
- Check that your server time is synchronized
License
MIT