GithubHelp home page GithubHelp logo

slack-gpt's Introduction

Slack ChatGPT Bot

This document was written by ChatGPT and directed by Aaron Ng (@localghost).

Introduction

This script creates a Slack bot that uses ChatGPT to respond to direct messages and mentions in a Slack workspace. It functions as a general question-answering bot for your company.

Environment Variables

Required:

  1. OPENAI_API_KEY: Your OpenAI API key, which starts with "sk-".
  2. SLACK_APP_TOKEN: Your Slack App Token, which starts with "xapp-".
  3. SLACK_BOT_TOKEN: Your Slack Bot Token, which starts with "xoxb-".

Optional:

  1. MODEL: The OpenAI model to use. Can be "gpt-3.5-turbo" or "gpt-4". Default is "gpt-3.5-turbo".
  2. PROMPT: A custom prompt for the bot. Default is a predefined prompt for a friendly company assistant.

Setup

  1. Go to https://api.slack.com/apps?new_app=1.
  2. Click "Create New App".
  3. Click "Basic", then name your Slack bot and select a workspace.

Configuration

  1. In "Settings" → "Socket Mode", enable both Socket Mode and Event Subscriptions.
  2. In "Settings" → "Basic Information", install your app to the workspace by following the instructions.
  3. In "Settings" → "Basic Information", scroll to "App-Level Tokens" and create one with the permission connections:write. Set the resulting token that starts with xapp- as your SLACK_APP_TOKEN.
  4. In "Features" → "OAuth and Permissions", copy the "Bot User OAuth Token" and set it as the SLACK_BOT_TOKEN in your environment.
  5. In "Features" → "OAuth and Permissions" → "Scopes", add the following permissions: app_mentions:read, channels:history, channels:read, chat:write, chat:write.public, groups:history, groups:read, im:history, im:read, mpim:history, mpim:read, users:read.
  6. In "Features" → "Event Subscriptions" → "Subscribe to Bot Events", add the following bot user events: app_mentions:read, message.im.
  7. In "Features" → "App Home", turn on the "Messages Tab" switch, and enable the Allow users to send Slash commands and messages from the messages tab feature.

Now your Slack bot should be ready to use!

Deployment

Cloud Deployment:

  1. If deploying to a cloud service, check out and reconfigure setup.sh and start.sh.

Local Deployment:

  1. If running locally, install dependencies with poetry.
  2. Comment out these two lines in the script:
# from dotenv import load_dotenv
# load_dotenv()

Start the bot and enjoy using it in your Slack workspace.

slack-gpt's People

Contributors

zajas avatar aaronn 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.