- Set up your Slack Platform account (full instructions @ https://api.slack.com/future/quickstart)
- Accept the terms of service: https://slack.com/admin/settings#hermes_permissions
- Install the CLI by running on your terminal
curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash
- Authorize your CLI to interact with Slack on your workspace with by running this command on your terminal and follow the prompts
slack login
- Take the last line from your terminal (e.g.
/slackauthticket ABC123defABC123defABC123defABC123defXYZ
and paste that in your Slack message bar for your workspace)
- Fork the repo
git clone [email protected]:fxchen/SlackGPT
- Get an OpenAI API key (https://beta.openai.com/account/api-keys). Make sure to add billing information.
You can test your token validity with this command that executes a completion on "hello world"
TOKEN=YOUR_TOKEN_HERE
completion_openai() {curl -X POST https://api.openai.com/v1/completions -H 'Content-Type: application/json' -H "Authorization: Bearer $TOKEN" -d "{ \"model\": \"text-davinci-003\", \"prompt\": \"$1\", \"n\": 1}" | tr -d '\n' | jq '.choices[0].text'}
completion_openai "hello world"
- Save this secret. Create a new file in your
SlackGPT
folder called.env
. Replace the string in this env file with your actual OpenAI token. Details: https://beta.openai.com/docs/api-reference/introduction
openai_token = "YOUR_TOKEN_HERE"
Alternatively, use this command at the root directory to add this secret at run time.
slack env add openai_token "YOUR_TOKEN_HERE"
- Deploy the SlackGPT application
Run the command slack deploy
- Get channel ids for your bot to watch for by clicking the channel name in
Slack. In this screenshot, I have a channel called
#hello-slackgpt
. Details: https://api.slack.com/future/apicalls/third-party
- Set up your bot to watch for mentions!
- Open
triggers/gpt_mentioned_trigger.ts
- Update
channel_ids
to include channels where you want SlackGPT to respond to - Run the command below
slack trigger create --trigger-def "triggers/gpt_mentioned_trigger.ts"
- 🎉 Use ChatGPT through a Slack interface