GithubHelp home page GithubHelp logo

slack-bot's Introduction

Slack Bot

Slack bot built with Node.js and Express.js that leverages anthropic for chat completion, Slack Web API for sending messages, Slack Events API for listening to messages and Trigger.dev for background tasks.

Features

  • Chat completion using anthropic
  • Send messages to Slack
  • Listen to messages from Slack
  • Background tasks using Trigger.dev

Setup Instructions

Installation

  1. Clone the repository
git clone https://github.com/Kritik-J/slack-bot
  1. Install dependencies
npm install
  1. Copy the .env.example file to .env
cp .env.example .env

Trigger.dev setup

Grab Trigger.dev credentials from the dashboard and update the .env file

  1. Navigate to the Trigger.dev dashboard Trigger.dev
  2. Create a new project v3, If you don't have one
  3. Navigate to the project settings page and grab the project id and set it in the .env file as TRIGGER_PROJECT_ID
  4. Navigate to the API keys page and grab the api key and set it in the .env file as TRIGGER_SECRET_KEY

Note: As of now Trigger.dev v3 is still in developer preview.

Anthropic setup

Navigate to Anthropic and create an account. Grab the api key and set it in the .env file as ANTHROPIC_API_KEY

Start the server

  1. Start the server
npm run dev
  1. Start Trigger.dev
npm run dev:trigger
  1. Start ngrok
ngrok http your_port

Setup Slack

  1. Create a Slack app

Navigate to Slack API click on Create New App and choose From scratch. Fill in the required details and click on Create App.

  1. Install the app to your workspace

Navigate to OAuth & Permissions, scroll down to Scopes and add the following scopes to bot token scopes: chat:write. Click on Install to Workspace.

  1. Get the Bot User OAuth Token

Once the app is installed to your workspace, You will find the Bot User OAuth Token under OAuth & Permissions section. Copy the token and paste it in the .env file as SLACK_BOT_TOKEN

  1. Subscribe to the events

Navigate to Event Subscriptions, enable events and paste the ngrok URL followed by /slack/events in the Request URL field. Subscribe to the following bot events: app_mention

  1. Signing Secret

Navigate to Basic Information and copy the Signing Secret and paste it in the .env file as SLACK_SIGNING_SECRET

Deployment

  1. Deploy trigger.dev tasks
npx trigger.dev@beta deploy

Note: Make sure to set environment variables in the Trigger.dev dashboard

  1. Deploy your server to a cloud provider like railway, heroku, etc.

Note: Make sure to set environment variables in the cloud provider dashboard as well, Also replace the ngrok URL with the deployed server URL in the Slack app settings.

slack-bot's People

Contributors

kritik-j avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.