Repository for a slack bot app connected to the OpenAI API. Our method is inspired by this blogpost.
Update (09/03/2023) 📢: added the latest Chat Completion engine gpt-3.5-turbo!
$ git clone https://github.com/ggendro/slack-gpt.git
$ cd slack-gpt
$ pip install -r requirements.txt
To connect the bot to Slack and OpenAI, you need a <slack_app_token>
, a <slack_bot_token>
, and an <openai_api_key>
. Follow the following steps to generate them:
To obtain the <slack_app_token>, you need to create an app with the Slack API.
You need to give your app the following permissions:
- app_mentions:read
- channels:history
- channels:read
- chat:write
- files:write
Enable socket mode and copy the generated token, this is your <slack_app_token>
.
Stay in Slack API. Enable "Event Subscription" and subscribe to the "app_mention" bot event.
Generate a Bot User OAuth Token in OAuth & Permissions, this is the <slack_bot_token>
.
An OpenAI API key is also required and can be obtained on the OpenAI API page. Once obtained, it must be pasted under <openai_api_key>
as described in the usage section.
To launch the server, run the following script:
python app.py --slack_app_token <slack_app_token> --slack_bot_token <slack_bot_token> --openai_api_key <openai_api_key>
You will be able to communicate with the bot in your slack workspace using the name given in your app.