The instuctions in the original readme are good to go. A couple of extra useful things:
-
For local usage, Slack Bolt is used with socket mode.
- Prepare the environment
$ python3 -m venv .venv $ source .venv/bin/activate $ pip install -r requirements.txt
- Set the env variables (prepare the
env.sh
file and do not setSLACK_CLIENT_ID
,SLACK_CLIENT_SECRET
,SLACK_SIGNING_SECRET
, otherwise Slack Bolt will not use socket mode):
$ source env.sh
- Start the app
$ python main.py
-
For prod usage, the CloudFront deployment hasn't succeeded so the bot is deployed in our k8s cluster without any persistent storage (thus it doesn't provide home page and fancy configuration page, but at least it works).
prod
tag is used by default.- Build the image with
$ ./authenticate_ecr.sh $ docker build . -t 781124778026.dkr.ecr.eu-west-1.amazonaws.com/yap/hackday/ai:prod --platform amd64 $ docker push 781124778026.dkr.ecr.eu-west-1.amazonaws.com/yap/hackday/ai:prod
- Use
chat-gpt-bot-env.yaml
to create the secrets (if they do not already exist)
$ kubectl -n hackday apply -f chat-gpt-bot-env.yaml
- Use
chat-gpt-bot-pod.yaml
to deploy the pod itself
$ kubectl -n hackday apply -f chat-gpt-bot-pod.yaml
Introducing a transformative app for Slack users, specifically designed to enhance your communication with ChatGPT! This app enables seamless interaction with ChatGPT via Slack channels, optimizing your planning and writing processes by leveraging AI technology.
Discover the app's functionality by installing the live demo from https://bit.ly/chat-gpt-in-slack. Keep in mind that the live demo is personally hosted by @seratch. For corporate Slack workspaces, we strongly advise deploying the app on your own infrastructure using the guidelines provided below.
If you're looking for a sample app operating on Slack's next-generation hosted platform, check out https://github.com/seratch/chatgpt-on-deno 🙌
You can interact with ChatGPT like you do in the website. In the same thread, the bot remember what you already said.
Consider this realistic scenario: ask the bot to generate a business email for communication with your manager.
With ChatGPT, you don't need to ask a perfectly formulated question at first. Adjusting the details after receiving the bot's initial response is a great approach.
Doesn't that sound cool? 😎
To run this app on your local machine, you only need to follow these simple steps:
- Create a new Slack app using the manifest-dev.yml file
- Install the app into your Slack workspace
- Retrieve your OpenAI API key at https://platform.openai.com/account/api-keys
- Start the app
# Create an app-level token with connections:write scope
export SLACK_APP_TOKEN=xapp-1-...
# Install the app into your workspace to grab this token
export SLACK_BOT_TOKEN=xoxb-...
# Visit https://platform.openai.com/account/api-keys for this token
export OPENAI_API_KEY=sk-...
# Optional: gpt-3.5-turbo and gpt-4 are currently supported (default: gpt-3.5-turbo)
export OPENAI_MODEL=gpt-4
# Optional: You can adjust the timeout seconds for OpenAI calls (default: 30)
export OPENAI_TIMEOUT_SECONDS=60
# Optional: You can include priming instructions for ChatGPT to fine tune the bot purpose
export OPENAI_SYSTEM_TEXT="You proofread text. When you receive a message, you will check
for mistakes and make suggestion to improve the language of the given text"
# Optional: When the string is "true", this app translates ChatGPT prompts into a user's preferred language (default: true)
export USE_SLACK_LANGUAGE=true
# Optional: Adjust the app's logging level (default: DEBUG)
export SLACK_APP_LOG_LEVEL=INFO
# Optional: When the string is "true", translate between OpenAI markdown and Slack mrkdwn format (default: false)
export TRANSLATE_MARKDOWN=true
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python main.py
Confidentiality of information is top priority for businesses.
This app is open-sourced! so please feel free to fork it and deploy the app onto the infrastructure that you manage.
After going through the above local development process, you can deploy the app using Dockerfile
, which is placed at the root directory of this project.
The Dockerfile
is designed to establish a WebSocket connection with Slack via Socket Mode.
This means that there's no need to provide a public URL for communication with Slack.
You're always welcome to contribute! 🙌 When you make changes to the code in this project, please keep these points in mind:
- When making changes to the app, please avoid anything that could cause breaking behavior. If such changes are absolutely necessary due to critical reasons, like security issues, please start a discussion in GitHub Issues before making significant alterations.
- When you have the chance, please write some unit tests. Especially when you touch
internals.py
and add/edit the code that do not call any web APIs, writing tests should be relatively easy. - Before committing your changes, be sure to run
./validate.sh
. The script runs black (code formatter), flake8 and pytype (static code analyzers).
The MIT License