Skip to content

ibrunner/linear-slack-bot

Repository files navigation

Linear AI Slackbot

Deploy with Vercel

An AI-powered chatbot for Slack that integrates with Linear to help manage your project workspace. This project is based on the Vercel AI SDK Slackbot and uses the AI SDK by Vercel.

Features

  • Integrates with Slack's API for easy Slack communication
  • Connects to Linear's API to manage your project workspace
  • Use any LLM with the AI SDK (easily switch between providers)
  • Works both with app mentions and as an assistant in direct messages
  • Maintains conversation context within both threads and direct messages

Prerequisites

Setup

1. Install Dependencies

npm install
# or
pnpm install

2. Create a Slack App

  1. Go to https://api.slack.com/apps and click "Create New App"
  2. Choose "From scratch" and give your app a name
  3. Select your workspace

3. Configure Slack App Settings

Basic Information

  • Under "App Credentials", note down your "Signing Secret"

OAuth & Permissions

  • Add the following Bot Token Scopes:

    • app_mentions:read
    • assistant:write
    • chat:write
    • im:history
    • im:read
    • im:write
  • Install the app to your workspace and note down the "Bot User OAuth Token"

4. Set Environment Variables

Create a .env file in the root of your project with the following:

# Slack Credentials
SLACK_BOT_TOKEN=xoxb-your-bot-token
SLACK_SIGNING_SECRET=your-signing-secret

# OpenAI Credentials
OPENAI_API_KEY=your-openai-api-key

# Linear Credentials
LINEAR_API_KEY=your-linear-api-key

Replace the placeholder values with your actual tokens.

5. Deploy your app

  • If building locally, follow steps in the Local Development section to tunnel your local environment and then copy the tunnel URL.
  • If deploying to Vercel, follow the instructions in the Production Deployment section and copy your deployment URL.

6. Update your Slack App configuration:

Go to your Slack App settings

  • Select your app
  • Go to "Event Subscriptions"
  • Enable Events
  • Set the Request URL to either your local URL or your deployment URL: (e.g. https://your-app.vercel.app/api/events)
  • Save Changes
  • Under "Subscribe to bot events", add:
    • app_mention
    • assistant_thread_started
    • message.im

Remember to include /api/events in the Request URL.

Local Development

Use the Vercel CLI and untun to test out this project locally:

pnpm i -g vercel
pnpm vercel dev --listen 3000 --yes
npx untun@latest tunnel http://localhost:3000

Make sure to modify the subscription URL to the untun URL.

Note: you may encounter issues locally with waitUntil. This is being investigated.

Production Deployment

Deploying to Vercel

  1. Push your code to a GitHub repository

  2. Deploy to Vercel:

    • Go to vercel.com
    • Create New Project
    • Import your GitHub repository
  3. Add your environment variables in the Vercel project settings:

    • SLACK_BOT_TOKEN
    • SLACK_SIGNING_SECRET
    • OPENAI_API_KEY
    • LINEAR_API_KEY
  4. After deployment, Vercel will provide you with a production URL

  5. Update your Slack App configuration:

    • Go to your Slack App settings
    • Select your app
    • Go to "Event Subscriptions"
    • Enable Events
    • Set the Request URL to: https://your-app.vercel.app/api/events
    • Save Changes
    • Under "Subscribe to bot events", add:
      • app_mention
      • assistant_thread_started
      • message:im

Usage

The bot will respond to:

  1. Direct messages - Send a DM to your bot
  2. Mentions - Mention your bot in a channel using @YourBotName

The bot maintains context within both threads and direct messages, so it can follow along with the conversation.

Linear Integration

The bot can help you manage your Linear workspace through natural language commands. (More details coming soon as features are added)

License

MIT

About

linear slack bot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published