Wait...what?
"Wicked smart" is a phrase you'll hear a lot around Boston. It's our way of saying someone is extremely intelligent. It's like if Albert Einstein, Tom Brady, Ketanji Brown Jackson and HAL 9000 had a baby, that kid would be "wicked smaaht".
W'kid Smaaht Slack brings the power of GPT4 to Slack. It's like having an expert in any topic available 24/7.
GPT-powered: Get intelligent, human-like responses thanks to GPT-4
Serverless: Runs on AWS Fargate. This means it's always on and there's no infrastructure to manage
Easy to use: Just invite the app to any Slack channel and type @Wkid Smaaht.
You can also DM as you would any Slack user
Slack
OpenAI
AWS
Docker
Python 3.10 or greater
Ability to execute bash shell scripts
jq
There are three major components to this application: the code, the AWS environment to run it and the Slack app itself. Start by downloading the codebase:
Note these instructions are for a Mac. You may have to tweak if running on Windows or other systems
Download latest release or clone this repo into a local folder with a python virtual environment
git clone https://github.com/jbdamask/wkid-smaaht.git
Set shell scripts to executable
cd wkid_smaaht
chmod +x scripts/*.sh
Follow Slack's Basic app setup guide
Click the Create a new Slack app button on the page above.
This will take you to the https://api.slack.com site for configuring your app.
Click "Create New App" button
Choose to create an app from an app manifest.
Choose a Slack workspace for your app
Select YAML and paste the contents of `slack-app-manifest.yml' in the input field. Click Next
In order to enable DM's to your app you'll need to check the box under App Home (Note: If Slack tells you that "Sending messages to this app has been turned off" after completing this full installation, restart Slack)
To set the Slack App icon, look for the Add App Icon under Basic Information. Upload images/wkid_smaaht_small.jpg
Click Install to Workspace (or Request to Install if you're not a Slack admin)
Click Allow
Get Slack App and Bot tokens
Next, you need to invite your app to a channel. Go to a channel of your choice and type /invite
Search for Wkid Smaaht and click Add
@Wkid Smaaht
. It won't do anything yet.Verify the app can write to the channel.
Open a Terminal window on your computer and post a message from Wkid Smaaht
curl -X POST -F channel=<channel ID> -F text="Wkid Smaaht ready to go" \
https://slack.com/api/chat.postMessage \
-H "Authorization: Bearer <Slack bot token>"
If all looks good, move on to the next section.
It's a good idea to try your application locally. Go back to your computer terminal and make sure you're in the wkid_smaaht folder.
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
Open .env_TEMPLATE and save as .env. Then set the values accordingly. IMPORTANT: The .gitignore file for this project specifies that the file ".env" be excluded from upload. But if you add your keys to the .env_TEMPLATE file and check in your code, your keys will be in your git repo!
Set an environment variable so that W'kid Smaaht runs locally.
export ENV=development
Now run the app
python wkid_smaaht.py
If everything went well, you'll now be able to call the app from Slack
Did you make it here? Sweet. Go ahead and stop the app by hitting Ctrl c and read on...or just keep asking it things; some responses are pretty funny.
A production Slack application shouldn't run on your laptop, but it can run in a container in your AWS account. This section will walk you through creating a Docker image, publishing it to an AWS Elastic Container Registry (ECR) repository and running it as a serverless application that's always on.
Start Docker Desktop
Create your AWS Elastic Container Repository (ECR), your Docker image and push the image to your new repo
./scripts/create_ECR_repo_and_push_container.sh
Enter your AWS account ID: <your account id>
Enter your AWS region: \<your AWS region\>
This will:
1. Create an Elastic Container Registry repo called "wkid-smaaht-slack"
2. Build an image from the dockerfile
3. Push the image to the ECR repo
Be patient, this takes 10-20 mins to build. When finished, note the URI for the repo and save it for later
aws ecr describe-repositories --repository-names wkid-smaaht-slack --query 'repositories[0].repositoryUri' --output text
Write your OpenAI API key and Slack bot and app tokens to AWS Secrets Manager. Use the same values you put into your .env (that file is only used for local testing)
./scripts/create_secrets.sh
Copy the ARNs for each secret, you'll need them later
You're now ready to create an AWS Elastic Container Service that will pull your image from ECR and run it. We use AWS Fargate so there's no need to manage EC2s.
Open the AWS Management Console and login
Navigate to CloudFormation and create a stack with new resources using the file cloudformation/wkid_smaaht_fargate.yml
AppName:Wkid Smaaht Slack
, otherwise just leave the defaults and keep clicking NextMonitor Events in the CloudFormation console. After a few minutes, the status should read CREATE_COMPLETE. If you see errors, go through the Events that caused them and ensure you didn't have any missteps. One common error is that the ARN for your secrets was wrong.
Write the provided system prompts to DynamoDB
./scripts/load_system_prompts_into_ddb.sh
It's time to start the service
./scripts/start_ECS_service.sh
You can monitor the startup from your AWS Console under Elastic Container Service.
When the ECS Task is Running, you're read to use the app.
You can use Wkid Smaaht for almost anything you'd use ChatGPT for, as well as some things that ChatGPT doesn't currently offer (see below).
If you've been part of a long Slack thread that you want to summarize, just ask Wkid Smaaht:
Or if the thread is really long, and you're feeling lazy, just say tl;dr.
Or let's say you've jumped into a fascinating Slack thread where colleagues are talking about things out of your comfort zone. You can hit it with something like this:
Sometimes you just want an expert at your fingertips. You can DM W'kid Smaaht just like any other Slack user and get immediate help
You can even use it to create images using OpenAI's DALL E 2:
W'kid Smaaht comes with several commands. You can see the list by typing :help
As shown above, this command calls the Dall E 2 image generation API from OpenAI (hopefully, we'll update to Dall E 3 soon).
This uses an AI Agent so search the web based on your input. TBH, it has potential but ain't great yet. Stick with Google or Bing for now.
Eventually this may be upgraded to a research agent.
Use this when you want to summarize a long web page and make it available in your Slack thread for Q&A
To use this command in a DM, simply upload a file. If using in a Channel or Thread, you'll need to specifiy @W'kid Smaaht when uploading the file.
W'kid Smaaht will register the file internally and this command will create an abstract and some options for follow-up questions. Note that large documents can take several minutes to summarize.
This feature lets you chat with your document (uploaded into Slack) or URL (by first running :webchat). It is especially useful if you know what you want.
Experience shows this feature has a ways to go. It's great for certain things but lacking in others. For example, it isn't aware of document structure and doesn't handle tables well. This makes it so-so for Q&A against scientific articles. We expect this feature to improve over time.
When used together, these commands can be a real time saver.
This bot can change! When using GPT4 you can steer how it thinks and responds using something called "System messages". System messages are meant to provide additional context or instructions for the AI model. They can be used to specify certain behaviors or to provide additional context that may not be clear from the user's input alone.
It's important to note that while system messages can provide useful context and direction, they may not always perfectly control the AI's behavior. The AI doesn't understand these instructions in the way a human would, but instead treats them as part of the overall pattern of input it uses to generate a response. It's also worth noting that very specific or complex instructions might be more difficult for the AI to follow accurately.
Wkid Smaaht is a good testing ground for creating and refining System messages to see what works. This app stores several System messages in DynamoDB and exposes them to Slack via slash commands.
When changed, the personality of the new bot will be specific to your user and channel and persist until you change it again.
You can add your own system prompts to the DynamoDB table and they'll automatically appear in Slack.
Resources to learn more about "prompt engineering" and system messages.
scripts/create_ECR_repo_and_push_container.sh
gpt4_system_prompts
folder and re-run ./scripts/load_system_prompts_into_dbb.sh
. See the Advanced section of this README for more info../scripts/start_ECS_service.sh
if the bot stops responding in SlackKeep an eye on the Issues section of this repo
This project leverages the Bolt-Python framework for building Slack applications, and uses code from the Slack GPT Bot project and the deeplearning.ai course, Building Systems with the ChatGPT API.
LangChain is responsible for taking W'kid Smaaht to the next level. The learning curve may be steep but it's worth it!
Glad to see you want to make this project better!
Please follow (GitHub guidelines)[https://docs.github.com/en/get-started/quickstart/contributing-to-projects].
When contributing, make sure you run the following user tests: