GoldMiner is a tool for finding interesting* messages in a Slack channel and turning them into a blog post for the thoughtbot blog.
It uses the Slack API to search for messages in a channel, then it groups and formats them into a markdown blog post.
* At this point, "interesting" means "messages that contain 'TIL', 'tip' or have been reacted with the :rupee-gold: emoji".
First, clone the repo:
git clone git@github.com:thoughtbot/gold_miner.git
Then, run the setup script:
bin/setup
You'll need a Slack API token. You can get it on 1Password (search for "Slack API Token"). If that doesn't work, ask someone on the team for help.
Alternatively, see the "Register your own app with Slack" section below for the steps to create your own app and User Token.
After setting the token on the .env
file, rerun the setup script to finish the
installation.
If you'd like the help of an AI to generate a blog post, you can set the
OPEN_AI_API_TOKEN
environment variable. To get one, create an account and
generate a token on the OpenAI website.
To generate a blog post, run the following command:
exe/gold_miner
GoldMiner will search on the #dev channel by default. You can also specify a different channel:
# Search on the #design channel
exe/gold_miner design
This will output a markdown article. Use that as a basis for opening a new blog post PR.
Note In the future, GoldMiner will open a PR for you.
After checking out the repo, run bin/setup
to install dependencies. Then, run
rake spec
to run the tests. You can also run bin/console
for an interactive
prompt that will allow you to experiment.
Bug reports and pull requests are welcome on GitHub at https://github.com/thoughtbot/gold_miner.
To register an app with Slack you just need to give it a name and select a workspace to develop it. After that, you will be able to generate Bot and User Tokens from your App settings page. A User Token is needed instead of a Bot Token because Gold Miner uses Slack's search.messages API which is only available for User Tokens.
- Go to https://api.slack.com/apps and click on "Create New App" and then click "From scratch"
- Give it a name, select your workspace, and click "Create App"
- After that, go to "Add features and functionality > Permissions"
- Scroll down to "Scopes > User Token Scopes" and give your app the
following scopes:
search:read
to have access to search.messagesusers:read
to have access to users.info
- Then scroll back up to "OAuth Tokens for Your Workspace" and click "Install to Workspace"
- You will be redirected to a page asking you to allow your app to be installed to the workspace and listing the scopes/permissions you've selected
- Click "Allow"
Now you have your personal app installed to the workspace and with Bot and User Tokens generated.
Go back to you App settings page, click "Add features and functionality >
Permissions", then copy the "User OAuth Token" and set it to SLACK_API_TOKEN
in your .env
file.
This repo is maintained and funded by thoughtbot, inc. The names and logos for thoughtbot are trademarks of thoughtbot, inc.
We love open source software! See our other projects. We are available for hire.